#[repr(C)]pub struct Envelope {
pub message_id: u128,
pub source: AddrHash,
pub destination: AddrHash,
pub type_tag: u64,
pub payload_len: u32,
pub flags: u32,
pub correlation_id: u64,
}Expand description
Fixed-size #[repr(C)] message header used for routing and wire framing.
SIZE bytes on the wire: the envelope is always serialized as a
little-endian byte array of exactly Envelope::SIZE bytes, followed by
payload_len bytes of payload.
Fields§
§message_id: u128§source: AddrHash§destination: AddrHash§type_tag: u64§payload_len: u32§flags: u32§correlation_id: u64Implementations§
Source§impl Envelope
impl Envelope
Sourcepub const SIZE: usize = 80
pub const SIZE: usize = 80
In-memory and wire size of the envelope.
The struct fields occupy 72 bytes of meaningful data; #[repr(C)]
pads to the next multiple of 16 (the alignment of u128) = 80 bytes.
The final 8 bytes are padding zeros in the wire format.
Sourcepub const WIRE_SIZE: usize = 41
pub const WIRE_SIZE: usize = 41
Compact wire size for remote frames (destination, source, correlation, priority).
pub const FLAG_RESPONSE: u32
pub const FLAG_PRIORITY_MASK: u32
pub fn new( source: AddrHash, destination: AddrHash, type_tag: u64, payload_len: u32, ) -> Self
Sourcepub fn response(&self, payload_len: u32) -> Self
pub fn response(&self, payload_len: u32) -> Self
Construct a response envelope by swapping source/destination and setting the response flag and correlation id.
pub fn with_priority(self, priority: u8) -> Self
pub fn priority(&self) -> u8
pub fn is_response(&self) -> bool
Sourcepub fn to_bytes(&self) -> [u8; 80]
pub fn to_bytes(&self) -> [u8; 80]
Serialize to a fixed [u8; SIZE] array in little-endian byte order.
Bytes 72–79 are padding zeros (required by #[repr(C)] alignment).
Sourcepub fn from_bytes(buf: &[u8; 80]) -> Self
pub fn from_bytes(buf: &[u8; 80]) -> Self
Deserialize from a fixed [u8; SIZE] array. Bytes 72–79 are ignored.