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 decrypt the message.
Implementations§
source§impl MegolmMessage
impl MegolmMessage
sourcepub fn ciphertext(&self) -> &[u8] ⓘ
pub fn ciphertext(&self) -> &[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: &[u8]) -> Result<Self, DecodeError>
pub fn from_bytes(message: &[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> ⓘ
pub fn to_bytes(&self) -> Vec<u8> ⓘ
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§
source§impl Clone for MegolmMessage
impl Clone for MegolmMessage
source§fn clone(&self) -> MegolmMessage
fn clone(&self) -> MegolmMessage
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for MegolmMessage
impl Debug for MegolmMessage
source§impl<'de> Deserialize<'de> for MegolmMessage
impl<'de> Deserialize<'de> for MegolmMessage
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 PartialEq for MegolmMessage
impl PartialEq for MegolmMessage
source§fn eq(&self, other: &MegolmMessage) -> bool
fn eq(&self, other: &MegolmMessage) -> bool
self
and other
values to be equal, and is used
by ==
.