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
sourceimpl Message
impl Message
sourcepub fn ratchet_key(&self) -> Curve25519PublicKey
pub fn ratchet_key(&self) -> Curve25519PublicKey
The public part of the ratchet key, that was used when the message was encrypted.
sourcepub fn chain_index(&self) -> u64
pub fn chain_index(&self) -> u64
The index of the chain that was used when the message was encrypted.
sourcepub fn ciphertext(&self) -> &[u8]ⓘNotable traits for &[u8]impl<'_> Read for &[u8]impl<'_> Write for &mut [u8]
pub fn ciphertext(&self) -> &[u8]ⓘNotable traits for &[u8]impl<'_> Read for &[u8]impl<'_> Write for &mut [u8]
The actual ciphertext of the 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>ⓘ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 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
sourceimpl<'de> Deserialize<'de> for Message
impl<'de> Deserialize<'de> for Message
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<Message> for OlmMessage
impl From<Message> for OlmMessage
impl Eq for Message
impl StructuralEq for Message
impl StructuralPartialEq for Message
Auto Trait Implementations
impl RefUnwindSafe for Message
impl Send for Message
impl Sync for Message
impl Unpin for Message
impl UnwindSafe for Message
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