Struct vodozemac::olm::PreKeyMessage
source · pub struct PreKeyMessage { /* private fields */ }
Expand description
Implementations§
source§impl PreKeyMessage
impl PreKeyMessage
sourcepub const fn one_time_key(&self) -> Curve25519PublicKey
pub const 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 const fn base_key(&self) -> Curve25519PublicKey
pub const 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 const fn identity_key(&self) -> Curve25519PublicKey
pub const fn identity_key(&self) -> Curve25519PublicKey
The long term identity key of the sender of the message. Should be used
to establish a Session
sourcepub const fn session_keys(&self) -> SessionKeys
pub const 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 session_id(&self) -> String
pub fn session_id(&self) -> String
Returns the globally unique session ID, in base64-encoded form.
This is a shorthand helper of the SessionKeys::session_id()
method.
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> ⓘ
pub fn to_bytes(&self) -> Vec<u8> ⓘ
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§
source§impl Clone for PreKeyMessage
impl Clone for PreKeyMessage
source§fn clone(&self) -> PreKeyMessage
fn clone(&self) -> PreKeyMessage
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for PreKeyMessage
impl Debug for PreKeyMessage
source§impl<'de> Deserialize<'de> for PreKeyMessage
impl<'de> Deserialize<'de> for PreKeyMessage
source§fn deserialize<D: Deserializer<'de>>(d: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(d: D) -> Result<Self, D::Error>
source§impl From<PreKeyMessage> for OlmMessage
impl From<PreKeyMessage> for OlmMessage
source§fn from(m: PreKeyMessage) -> Self
fn from(m: PreKeyMessage) -> Self
source§impl PartialEq for PreKeyMessage
impl PartialEq for PreKeyMessage
source§fn eq(&self, other: &PreKeyMessage) -> bool
fn eq(&self, other: &PreKeyMessage) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl Serialize for PreKeyMessage
impl Serialize for PreKeyMessage
source§impl TryFrom<&[u8]> for PreKeyMessage
impl TryFrom<&[u8]> for PreKeyMessage
source§impl TryFrom<&str> for PreKeyMessage
impl TryFrom<&str> for PreKeyMessage
impl Eq for PreKeyMessage
impl StructuralPartialEq for PreKeyMessage
Auto Trait Implementations§
impl Freeze for PreKeyMessage
impl RefUnwindSafe for PreKeyMessage
impl Send for PreKeyMessage
impl Sync for PreKeyMessage
impl Unpin for PreKeyMessage
impl UnwindSafe for PreKeyMessage
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)