pub struct Message { /* private fields */ }
Expand description
An encrypted Olm message.
Contains metadata that is required to find the correct ratchet state of a
Session
necessary to decrypt the message.
Implementations§
source§impl Message
impl Message
sourcepub const fn ratchet_key(&self) -> Curve25519PublicKey
pub const fn ratchet_key(&self) -> Curve25519PublicKey
The public part of the ratchet key, that was used when the message was encrypted.
sourcepub const fn chain_index(&self) -> u64
pub const fn chain_index(&self) -> u64
The index of the chain that was used when the message was encrypted.
sourcepub fn ciphertext(&self) -> &[u8] ⓘ
pub fn ciphertext(&self) -> &[u8] ⓘ
The actual ciphertext of the message.
sourcepub const fn mac_truncated(&self) -> bool
pub const fn mac_truncated(&self) -> bool
Has the MAC been truncated in this Olm message.
sourcepub fn from_bytes(bytes: &[u8]) -> Result<Self, DecodeError>
pub fn from_bytes(bytes: &[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
Message::to_bytes()
method.
sourcepub fn to_bytes(&self) -> Vec<u8> ⓘ
pub fn to_bytes(&self) -> Vec<u8> ⓘ
Encode the Message
as an array of bytes.
Olm Message
s consist of a one-byte version, followed by a variable
length payload and a fixed length message authentication code.
+--------------+------------------------------------+-----------+
| Version Byte | Payload Bytes | MAC Bytes |
+--------------+------------------------------------+-----------+
The payload uses a format based on the Protocol Buffers encoding. It consists of the following key-value pairs:
Name | Tag | Type | Meaning |
---|---|---|---|
Ratchet-Key | 0x0A | String | The public part of the ratchet key |
Chain-Index | 0x10 | Integer | The chain index, of the message |
Cipher-Text | 0x22 | String | The cipher-text of the 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 Message
.
The string needs to be a base64 encoded byte array that follows the
format described in the Message::to_bytes()
method.
sourcepub fn to_base64(&self) -> String
pub fn to_base64(&self) -> String
Encode the Message
as a string.
This method first calls Message::to_bytes()
and then encodes the
resulting byte array as a string using base64 encoding.
Trait Implementations§
source§impl<'de> Deserialize<'de> for Message
impl<'de> Deserialize<'de> for Message
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<Message> for OlmMessage
impl From<Message> for OlmMessage
source§impl PartialEq for Message
impl PartialEq for Message
impl Eq for Message
impl StructuralPartialEq for Message
Auto Trait Implementations§
impl Freeze for Message
impl RefUnwindSafe for Message
impl Send for Message
impl Sync for Message
impl Unpin for Message
impl UnwindSafe for Message
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
)