Struct vodozemac::megolm::MegolmMessage
source · [−]pub struct MegolmMessage { /* private fields */ }
Expand description
An encrypted Megolm message.
Contains metadata that is required to find the correct ratchet state of a
InboundGroupSession
necessary to decryp the message.
Implementations
sourceimpl MegolmMessage
impl MegolmMessage
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 message_index(&self) -> u32
pub fn message_index(&self) -> u32
The index of the message that was used when the message was encrypted.
sourcepub fn signature(&self) -> &Ed25519Signature
pub fn signature(&self) -> &Ed25519Signature
Get a reference to the megolm message’s signature.
sourcepub fn from_bytes(message: Vec<u8>) -> Result<Self, DecodeError>
pub fn from_bytes(message: Vec<u8>) -> Result<Self, DecodeError>
Try to decode the given byte slice as a MegolmMessage
.
The expected format of the byte array is described in the
MegolmMessage::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 MegolmMessage
as an array of bytes.
Megolm messages consist of a one byte version, followed by a variable length payload, a fixed length message authentication code, and a fixed length signature.
+---+------------------------------------+-----------+------------------+
| V | Payload Bytes | MAC Bytes | Signature Bytes |
+---+------------------------------------+-----------+------------------+
0 1 N N+8 N+72 bytes
The payload uses a format based on the Protocol Buffers encoding. It consists of the following key-value pairs:
Name | Tag | Type | Meaning |
---|---|---|---|
Message-Index | 0x08 | Integer | The index of the ratchet, i |
Cipher-Text | 0x12 | String | The cipher-text, Xi, 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 MegolmMessage
.
The string needs to be a base64 encoded byte array that follows the
format described in the MegolmMessage::to_bytes()
method.
sourcepub fn to_base64(&self) -> String
pub fn to_base64(&self) -> String
Encode the MegolmMessage
as a string.
This method first calls MegolmMessage::to_bytes()
and then encodes
the resulting byte array as a string using base64 encoding.
Trait Implementations
sourceimpl Debug for MegolmMessage
impl Debug for MegolmMessage
sourceimpl<'de> Deserialize<'de> for MegolmMessage
impl<'de> Deserialize<'de> for MegolmMessage
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 PartialEq<MegolmMessage> for MegolmMessage
impl PartialEq<MegolmMessage> for MegolmMessage
sourcefn eq(&self, other: &MegolmMessage) -> bool
fn eq(&self, other: &MegolmMessage) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &MegolmMessage) -> bool
fn ne(&self, other: &MegolmMessage) -> bool
This method tests for !=
.
sourceimpl Serialize for MegolmMessage
impl Serialize for MegolmMessage
sourceimpl TryFrom<&[u8]> for MegolmMessage
impl TryFrom<&[u8]> for MegolmMessage
sourceimpl TryFrom<&str> for MegolmMessage
impl TryFrom<&str> for MegolmMessage
impl Eq for MegolmMessage
impl StructuralEq for MegolmMessage
impl StructuralPartialEq for MegolmMessage
Auto Trait Implementations
impl RefUnwindSafe for MegolmMessage
impl Send for MegolmMessage
impl Sync for MegolmMessage
impl Unpin for MegolmMessage
impl UnwindSafe for MegolmMessage
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