pub struct MessageEnvelope {
pub schema_id: SchemaId,
pub causal_context: CausalContext,
pub payload: Vec<u8>,
}Expand description
Protocol message envelope carried by publish and conversation-message frames.
Fields§
§schema_id: SchemaIdContent type hash identifying the payload schema.
causal_context: CausalContextStructured causal metadata used by the bus for ordering decisions.
payload: Vec<u8>Opaque application payload bytes.
Implementations§
Source§impl MessageEnvelope
impl MessageEnvelope
Sourcepub const fn new(
schema_id: SchemaId,
causal_context: CausalContext,
payload: Vec<u8>,
) -> Self
pub const fn new( schema_id: SchemaId, causal_context: CausalContext, payload: Vec<u8>, ) -> Self
Create a protocol message envelope from all of its fields.
Sourcepub fn encoded_len(&self) -> Result<usize, ProtocolError>
pub fn encoded_len(&self) -> Result<usize, ProtocolError>
Return the deterministic encoded length of this envelope.
§Errors
Returns ProtocolError::CodecError when the causal-context or payload
length cannot fit in the protocol’s u32 length fields, or when the total
length overflows usize.
Sourcepub fn serialize(&self) -> Result<Vec<u8>, ProtocolError>
pub fn serialize(&self) -> Result<Vec<u8>, ProtocolError>
Serialize this envelope with deterministic big-endian field encoding.
§Errors
Returns ProtocolError::CodecError when a length field cannot represent
the encoded envelope.
Sourcepub fn to_wire_bytes(&self) -> Result<Vec<u8>, ProtocolError>
pub fn to_wire_bytes(&self) -> Result<Vec<u8>, ProtocolError>
Serialize this envelope for wire transport.
§Errors
Returns ProtocolError::CodecError when a length field cannot represent
the encoded envelope.
Sourcepub fn deserialize(bytes: &[u8]) -> Result<Self, ProtocolError>
pub fn deserialize(bytes: &[u8]) -> Result<Self, ProtocolError>
Deserialize an envelope from deterministic wire bytes.
§Errors
Returns ProtocolError::CodecError when the bytes are truncated,
contain malformed causal context bytes, or contain trailing bytes.
Sourcepub fn from_wire_bytes(bytes: &[u8]) -> Result<Self, ProtocolError>
pub fn from_wire_bytes(bytes: &[u8]) -> Result<Self, ProtocolError>
Deserialize an envelope from deterministic wire bytes.
§Errors
Returns ProtocolError::CodecError when the bytes are truncated,
contain malformed causal context bytes, or contain trailing bytes.
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
impl Eq for MessageEnvelope
Source§impl PartialEq for MessageEnvelope
impl PartialEq for MessageEnvelope
Source§fn eq(&self, other: &MessageEnvelope) -> bool
fn eq(&self, other: &MessageEnvelope) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for MessageEnvelope
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.