pub struct MessageEnvelope {
pub v: u8,
pub conversation_id: ConversationId,
pub epoch: u64,
pub kind: MessageKind,
pub sender_device: DeviceId,
pub seq: u64,
pub hlc: Hlc,
pub payload: Vec<u8>,
pub content_hash: [u8; 32],
}Expand description
On-the-wire envelope. CBOR-encoded.
Fields§
§v: u8§conversation_id: ConversationId§epoch: u64§kind: MessageKind§sender_device: DeviceId§seq: u64§hlc: Hlc§payload: Vec<u8>§content_hash: [u8; 32]Implementations§
Source§impl MessageEnvelope
impl MessageEnvelope
Sourcepub fn new(
conversation_id: ConversationId,
epoch: u64,
kind: MessageKind,
sender_device: DeviceId,
seq: u64,
hlc: Hlc,
payload: Vec<u8>,
) -> Self
pub fn new( conversation_id: ConversationId, epoch: u64, kind: MessageKind, sender_device: DeviceId, seq: u64, hlc: Hlc, payload: Vec<u8>, ) -> Self
Build an envelope for a handshake message (Commit / Welcome / Proposal /
KeyPackage). The content_hash is computed over SHA-256(kind || payload) —
unchanged across the v=1 → v=2 transition because handshake payloads have no
“plaintext vs ciphertext” distinction.
For MessageKind::Application use new_application
instead; passing an application kind here is a bug and tagged by debug_assert.
Sourcepub fn new_application(
conversation_id: ConversationId,
epoch: u64,
sender_device: DeviceId,
seq: u64,
hlc: Hlc,
payload: Vec<u8>,
plaintext: &[u8],
) -> Self
pub fn new_application( conversation_id: ConversationId, epoch: u64, sender_device: DeviceId, seq: u64, hlc: Hlc, payload: Vec<u8>, plaintext: &[u8], ) -> Self
Build an envelope for an application message ([CR-6]).
content_hash = SHA-256(plaintext) — keyed to the application bytes, not the MLS
ciphertext. This is what makes rebase-on-409 clean: a message that gets resent
against a new epoch keeps the same content_hash so app-layer dedup tables remain
consistent. It also gives every binding identical hashes for the same
AppEvent because CBOR encoding is canonical.
payload is the MLS ciphertext (what goes on the wire); plaintext is the
application-defined bytes that were encrypted. The constructor uses plaintext
only for hashing and payload for the envelope body.
Trait Implementations§
Source§impl Clone for MessageEnvelope
impl Clone for MessageEnvelope
Source§fn clone(&self) -> MessageEnvelope
fn clone(&self) -> MessageEnvelope
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for MessageEnvelope
impl Debug for MessageEnvelope
Source§impl<'de> Deserialize<'de> for MessageEnvelope
impl<'de> Deserialize<'de> for MessageEnvelope
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for MessageEnvelope
impl RefUnwindSafe for MessageEnvelope
impl Send for MessageEnvelope
impl Sync for MessageEnvelope
impl Unpin for MessageEnvelope
impl UnsafeUnpin for MessageEnvelope
impl UnwindSafe for MessageEnvelope
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more