pub struct ProtocolEnvelope {
pub protocol: String,
pub from_role: RoleName,
pub from_index: Option<u32>,
pub to_role: RoleName,
pub to_index: Option<u32>,
pub message_type: String,
pub sequence: u64,
pub timestamp_ns: u64,
pub correlation_id: Option<String>,
pub payload: Vec<u8>,
}Expand description
A protocol message envelope containing metadata and payload.
Envelopes provide a standard wrapper for messages that includes routing information and can be inspected without deserializing the payload.
Fields§
§protocol: StringName of the protocol this message belongs to.
from_role: RoleNameRole sending the message.
from_index: Option<u32>Role index if the sender is a parameterized role.
to_role: RoleNameRole receiving the message.
to_index: Option<u32>Role index if the receiver is a parameterized role.
message_type: StringType name of the message payload.
sequence: u64Sequence number for ordering (per sender-receiver pair).
timestamp_ns: u64Timestamp when the message was created (nanoseconds since epoch).
correlation_id: Option<String>Correlation ID for tracing across roles.
payload: Vec<u8>The serialized message payload.
Implementations§
Source§impl ProtocolEnvelope
impl ProtocolEnvelope
Sourcepub fn builder() -> EnvelopeBuilder
pub fn builder() -> EnvelopeBuilder
Create a new envelope builder.
Sourcepub fn payload_size(&self) -> usize
pub fn payload_size(&self) -> usize
Get the payload size in bytes.
Sourcepub fn is_protocol(&self, name: &str) -> bool
pub fn is_protocol(&self, name: &str) -> bool
Check if this envelope is for a specific protocol.
Sourcepub fn routing_key(&self) -> String
pub fn routing_key(&self) -> String
Create a routing key for this envelope (useful for message queues).
Sourcepub fn from_bytes(bytes: &[u8]) -> Result<Self, EnvelopeError>
pub fn from_bytes(bytes: &[u8]) -> Result<Self, EnvelopeError>
Deserialize an envelope from bytes.
Trait Implementations§
Source§impl Clone for ProtocolEnvelope
impl Clone for ProtocolEnvelope
Source§fn clone(&self) -> ProtocolEnvelope
fn clone(&self) -> ProtocolEnvelope
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more