Skip to main content

StreamEnvelope

Struct StreamEnvelope 

Source
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

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn version(&self) -> u32

Returns the envelope wire version (always STREAM_ENVELOPE_VERSION).

Source

pub fn stream_id(&self) -> &Symbol

Returns the id of the stream this envelope belongs to.

Source

pub fn packet_id(&self) -> &Symbol

Returns the id of the wrapped packet.

Source

pub fn media(&self) -> StreamMedia

Returns the media type carried by this envelope.

Source

pub fn direction(&self) -> StreamDirection

Returns the direction of flow for this envelope.

Source

pub fn sequence(&self) -> u64

Returns the monotonic sequence number of this envelope within its stream.

Source

pub fn ticks(&self) -> &[Tick]

Returns the Ticks that locate this envelope on its clocks.

Source

pub fn clock_domain(&self) -> ClockDomain

Returns the primary clock domain this envelope is timed against.

Source

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.

Source

pub fn profile(&self) -> &TransportProfile

Returns the transport profile bounding what a carrier may do with this envelope.

Source

pub fn diagnostics(&self) -> &[Symbol]

Returns the diagnostic symbols attached to this envelope.

Source

pub fn packet(&self) -> &StreamPacket

Returns the wrapped packet payload.

Source

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

Source§

fn clone(&self) -> StreamEnvelope

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for StreamEnvelope

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for StreamEnvelope

Source§

impl PartialEq for StreamEnvelope

Source§

fn eq(&self, other: &StreamEnvelope) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for StreamEnvelope

Source§

impl TryFrom<Expr> for StreamEnvelope

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(expr: Expr) -> Result<Self>

Performs the conversion.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.