pub struct EnvelopeBuilder { /* private fields */ }Expand description
Builder for creating protocol envelopes.
§Determinism
By default, envelopes are created with timestamp_ns = 0 for deterministic
simulation. Use timestamp() to set an explicit timestamp, or
timestamp_now() for production use with real wall-clock time.
Implementations§
Source§impl EnvelopeBuilder
impl EnvelopeBuilder
Sourcepub fn sender_role<R: RoleId>(self, role: R) -> Self
pub fn sender_role<R: RoleId>(self, role: R) -> Self
Set the sender role from a typed role identifier.
Sourcepub fn sender_index(self, index: u32) -> Self
pub fn sender_index(self, index: u32) -> Self
Set the sender role index.
Sourcepub fn recipient_role<R: RoleId>(self, role: R) -> Self
pub fn recipient_role<R: RoleId>(self, role: R) -> Self
Set the receiver role from a typed role identifier.
Sourcepub fn recipient_index(self, index: u32) -> Self
pub fn recipient_index(self, index: u32) -> Self
Set the receiver role index.
Sourcepub fn message_type(self, msg_type: impl Into<String>) -> Self
pub fn message_type(self, msg_type: impl Into<String>) -> Self
Set the message type name.
Sourcepub fn timestamp(self, timestamp_ns: u64) -> Self
pub fn timestamp(self, timestamp_ns: u64) -> Self
Set an explicit timestamp (nanoseconds since epoch).
For deterministic simulation, use controlled timestamps (or leave unset
to default to 0). For production contexts with real timestamps, use
SystemClock::timestamp_ns() from the utility layer.
Sourcepub fn timestamp_from<C: WallClock>(self, clock: &C) -> Self
pub fn timestamp_from<C: WallClock>(self, clock: &C) -> Self
Set timestamp from an injected wall-clock source.
Use this instead of reading host time directly to keep determinism under explicit control in simulations/replays.
Sourcepub fn correlation_id(self, id: impl Into<String>) -> Self
pub fn correlation_id(self, id: impl Into<String>) -> Self
Set the correlation ID.
Sourcepub fn payload_from<T: Serialize>(self, msg: &T) -> Result<Self, EnvelopeError>
pub fn payload_from<T: Serialize>(self, msg: &T) -> Result<Self, EnvelopeError>
Serialize a message as the payload.
Sourcepub fn build(self) -> Result<ProtocolEnvelope, EnvelopeError>
pub fn build(self) -> Result<ProtocolEnvelope, EnvelopeError>
Build the envelope.