pub struct StreamEnvelope { /* private fields */ }Expand description
A single packet plus the routing and timing metadata that carries it across the streaming fabric.
Every envelope is constructed through a validating constructor that checks
its Ticks, confirms the declared StreamMedia matches the wrapped
StreamPacket, folds each tick’s clock into the recorded clock-domain set,
and stamps the current STREAM_ENVELOPE_VERSION. The struct fields are
private; read access is through the accessor methods, and the wire form is
produced by StreamEnvelope::to_expr and recovered by TryFrom<Expr>.
Implementations§
Source§impl StreamEnvelope
impl StreamEnvelope
Sourcepub fn new(
stream_id: Symbol,
packet_id: Symbol,
media: StreamMedia,
direction: StreamDirection,
sequence: u64,
ticks: Vec<Tick>,
clock_domain: ClockDomain,
profile: TransportProfile,
diagnostics: Vec<Symbol>,
packet: StreamPacket,
) -> Result<Self>
pub fn new( stream_id: Symbol, packet_id: Symbol, media: StreamMedia, direction: StreamDirection, sequence: u64, ticks: Vec<Tick>, clock_domain: ClockDomain, profile: TransportProfile, diagnostics: Vec<Symbol>, packet: StreamPacket, ) -> Result<Self>
Builds an envelope whose clock-domain set is seeded from the single
primary clock_domain.
Validates the ticks and checks that media matches the packet’s media;
see StreamEnvelope::new_with_clock_domains for the full contract.
Sourcepub fn new_with_clock_domains(
stream_id: Symbol,
packet_id: Symbol,
media: StreamMedia,
direction: StreamDirection,
sequence: u64,
ticks: Vec<Tick>,
clock_domain: ClockDomain,
clock_domains: Vec<ClockDomain>,
profile: TransportProfile,
diagnostics: Vec<Symbol>,
packet: StreamPacket,
) -> Result<Self>
pub fn new_with_clock_domains( stream_id: Symbol, packet_id: Symbol, media: StreamMedia, direction: StreamDirection, sequence: u64, ticks: Vec<Tick>, clock_domain: ClockDomain, clock_domains: Vec<ClockDomain>, profile: TransportProfile, diagnostics: Vec<Symbol>, packet: StreamPacket, ) -> Result<Self>
Builds an envelope with an explicit set of clock domains.
Validates the ticks via the kernel, requires media to equal the
wrapped packet’s media (erroring otherwise), augments clock_domains
with each tick’s clock domain, and normalizes the result so the primary
clock_domain leads and no domain repeats. The stored version is always
STREAM_ENVELOPE_VERSION.
Sourcepub fn from_item(
metadata: &StreamMetadata,
sequence: u64,
item: &StreamItem,
) -> Result<Self>
pub fn from_item( metadata: &StreamMetadata, sequence: u64, item: &StreamItem, ) -> Result<Self>
Builds an envelope from stream metadata and one StreamItem, using
the in-memory-local TransportProfile.
Derives the packet id from the stream id and sequence, and resolves the
clock domain from the metadata’s declared clock. A convenience wrapper
over StreamEnvelope::from_item_with_profile.
Sourcepub fn from_item_with_profile(
metadata: &StreamMetadata,
sequence: u64,
item: &StreamItem,
profile: TransportProfile,
) -> Result<Self>
pub fn from_item_with_profile( metadata: &StreamMetadata, sequence: u64, item: &StreamItem, profile: TransportProfile, ) -> Result<Self>
Builds an envelope from stream metadata and one StreamItem under an
explicit TransportProfile.
Derives the packet id from the stream id and sequence, copies the
item’s ticks and packet, and resolves the clock domain from the
metadata’s clock via ClockDomain::for_stream_clock. No diagnostics
are attached.
Sourcepub fn version(&self) -> u32
pub fn version(&self) -> u32
Returns the envelope wire version (always STREAM_ENVELOPE_VERSION).
Sourcepub fn media(&self) -> StreamMedia
pub fn media(&self) -> StreamMedia
Returns the media type carried by this envelope.
Sourcepub fn direction(&self) -> StreamDirection
pub fn direction(&self) -> StreamDirection
Returns the direction of flow for this envelope.
Sourcepub fn sequence(&self) -> u64
pub fn sequence(&self) -> u64
Returns the monotonic sequence number of this envelope within its stream.
Sourcepub fn clock_domain(&self) -> ClockDomain
pub fn clock_domain(&self) -> ClockDomain
Returns the primary clock domain this envelope is timed against.
Sourcepub fn clock_domains(&self) -> &[ClockDomain]
pub fn clock_domains(&self) -> &[ClockDomain]
Returns every clock domain this envelope rides.
The primary ClockDomain::clock_domain
leads, followed by any additional domains contributed by the ticks, with
no repeats.
Sourcepub fn profile(&self) -> &TransportProfile
pub fn profile(&self) -> &TransportProfile
Returns the transport profile bounding what a carrier may do with this envelope.
Sourcepub fn diagnostics(&self) -> &[Symbol]
pub fn diagnostics(&self) -> &[Symbol]
Returns the diagnostic symbols attached to this envelope.
Sourcepub fn packet(&self) -> &StreamPacket
pub fn packet(&self) -> &StreamPacket
Returns the wrapped packet payload.
Sourcepub fn to_expr(&self) -> Expr
pub fn to_expr(&self) -> Expr
Encodes this envelope into its Expr map wire form.
The map is tagged with stream_envelope_tag_symbol and round-trips
back through the TryFrom<Expr> implementation.
Trait Implementations§
Source§impl Clone for StreamEnvelope
impl Clone for StreamEnvelope
Source§fn clone(&self) -> StreamEnvelope
fn clone(&self) -> StreamEnvelope
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 StreamEnvelope
impl Debug for StreamEnvelope
impl Eq for StreamEnvelope
Source§impl PartialEq for StreamEnvelope
impl PartialEq for StreamEnvelope
Source§fn eq(&self, other: &StreamEnvelope) -> bool
fn eq(&self, other: &StreamEnvelope) -> bool
self and other values to be equal, and is used by ==.