Struct vodozemac::olm::PreKeyMessage
source · [−]pub struct PreKeyMessage { /* private fields */ }
Expand description
Implementations
sourceimpl PreKeyMessage
impl PreKeyMessage
sourcepub fn one_time_key(&self) -> Curve25519PublicKey
pub fn one_time_key(&self) -> Curve25519PublicKey
The single-use key that was uploaded to a public key directory by the
receiver of the message. Should be used to establish a Session
.
sourcepub fn base_key(&self) -> Curve25519PublicKey
pub fn base_key(&self) -> Curve25519PublicKey
The base key, a single use key that was created just in time by the
sender of the message. Should be used to establish a Session
.
sourcepub fn identity_key(&self) -> Curve25519PublicKey
pub fn identity_key(&self) -> Curve25519PublicKey
The long term identity key of the sender of the message. Should be used
to establish a Session
sourcepub fn session_keys(&self) -> SessionKeys
pub fn session_keys(&self) -> SessionKeys
The collection of all keys required for establishing an Olm Session
from this pre-key message.
Other methods on this struct (like PreKeyMessage::identity_key()
)
can be used to retrieve individual keys from this collection.
sourcepub fn from_bytes(message: &[u8]) -> Result<Self, DecodeError>
pub fn from_bytes(message: &[u8]) -> Result<Self, DecodeError>
Try to decode the given byte slice as a Olm Message
.
The expected format of the byte array is described in the
PreKeyMessage::to_bytes()
method.
sourcepub fn to_bytes(&self) -> Vec<u8>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
pub fn to_bytes(&self) -> Vec<u8>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
Encode the PreKeyMessage
as an array of bytes.
Olm PreKeyMessage
s consist of a one-byte version, followed by a
variable length payload.
+--------------+------------------------------------+
| Version Byte | Payload Bytes |
+--------------+------------------------------------+
The payload uses a format based on the Protocol Buffers encoding. It consists of the following key-value pairs:
Name | Tag | Type | Meaning |
---|---|---|---|
One-Time-Key | 0x0A | String | The public part of Bob’s single-use key |
Base-Key | 0x12 | String | The public part of Alice’s single-use key |
Identity-Key | 0x1A | String | The public part of Alice’s identity key |
Message | 0x22 | String | An embedded Olm message |
The last key/value pair in a PreKeyMessage
is a normal Olm
Message
.
sourcepub fn from_base64(message: &str) -> Result<Self, DecodeError>
pub fn from_base64(message: &str) -> Result<Self, DecodeError>
Try to decode the given string as a Olm PreKeyMessage
.
The string needs to be a base64 encoded byte array that follows the
format described in the PreKeyMessage::to_bytes()
method.
sourcepub fn to_base64(&self) -> String
pub fn to_base64(&self) -> String
Encode the PreKeyMessage
as a string.
This method first calls PreKeyMessage::to_bytes()
and then encodes
the resulting byte array as a string using base64 encoding.
Trait Implementations
sourceimpl Clone for PreKeyMessage
impl Clone for PreKeyMessage
sourcefn clone(&self) -> PreKeyMessage
fn clone(&self) -> PreKeyMessage
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for PreKeyMessage
impl Debug for PreKeyMessage
sourceimpl<'de> Deserialize<'de> for PreKeyMessage
impl<'de> Deserialize<'de> for PreKeyMessage
sourcefn deserialize<D: Deserializer<'de>>(d: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(d: D) -> Result<Self, D::Error>
Deserialize this value from the given Serde deserializer. Read more
sourceimpl From<PreKeyMessage> for OlmMessage
impl From<PreKeyMessage> for OlmMessage
sourcefn from(m: PreKeyMessage) -> Self
fn from(m: PreKeyMessage) -> Self
Converts to this type from the input type.
sourceimpl PartialEq<PreKeyMessage> for PreKeyMessage
impl PartialEq<PreKeyMessage> for PreKeyMessage
sourcefn eq(&self, other: &PreKeyMessage) -> bool
fn eq(&self, other: &PreKeyMessage) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &PreKeyMessage) -> bool
fn ne(&self, other: &PreKeyMessage) -> bool
This method tests for !=
.
sourceimpl Serialize for PreKeyMessage
impl Serialize for PreKeyMessage
sourceimpl TryFrom<&[u8]> for PreKeyMessage
impl TryFrom<&[u8]> for PreKeyMessage
sourceimpl TryFrom<&str> for PreKeyMessage
impl TryFrom<&str> for PreKeyMessage
impl Eq for PreKeyMessage
impl StructuralEq for PreKeyMessage
impl StructuralPartialEq for PreKeyMessage
Auto Trait Implementations
impl RefUnwindSafe for PreKeyMessage
impl Send for PreKeyMessage
impl Sync for PreKeyMessage
impl Unpin for PreKeyMessage
impl UnwindSafe for PreKeyMessage
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more