Skip to main content

StreamCassette

Struct StreamCassette 

Source
pub struct StreamCassette { /* private fields */ }
Expand description

A recorded, replayable trace of a single stream.

Holds the stream metadata, the ordered envelopes, derived timing, the deduplicated diagnostic symbols observed, and the final StreamStats. A cassette can be rebuilt into a live StreamValue via replay_stream_value, serialized to an Expr map, and validated as a golden fixture.

Implementations§

Source§

impl StreamCassette

Source

pub fn from_stream_value( stream: &StreamValue, profile: TransportProfile, ) -> Result<Self>

Records a cassette by draining every packet from a live stream.

Pulls packets until the stream is exhausted, snapshots its final stats, and builds the cassette from the metadata, drained items, and the given TransportProfile.

Source

pub fn from_items( metadata: StreamMetadata, items: Vec<StreamItem>, profile: TransportProfile, final_stats: StreamStats, ) -> Result<Self>

Records a cassette from already-drained stream items.

Wraps each item in a sequenced StreamEnvelope under the given TransportProfile, then delegates to from_envelopes.

Source

pub fn from_envelopes( metadata: StreamMetadata, envelopes: Vec<StreamEnvelope>, final_stats: StreamStats, ) -> Result<Self>

Builds a cassette directly from sequenced envelopes.

Derives the timing and the deduplicated diagnostic set from the envelopes, pairing them with the supplied metadata and final stats.

Source

pub fn metadata(&self) -> &StreamMetadata

Returns the metadata of the recorded stream.

Source

pub fn envelopes(&self) -> &[StreamEnvelope]

Returns the recorded envelopes in sequence order.

Source

pub fn timing(&self) -> &StreamCassetteTiming

Returns the derived timing summary for the trace.

Source

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

Returns the deduplicated diagnostic symbols observed during recording.

Source

pub fn final_stats(&self) -> &StreamStats

Returns the final accumulated stats captured at end of trace.

Source

pub fn items(&self) -> Result<Vec<StreamItem>>

Reconstructs the stream items from the recorded envelopes.

Each item pairs an envelope’s packet with its captured ticks, ready to feed a replay stream.

Source

pub fn replay_stream_value(&self) -> Result<StreamValue>

Rebuilds a live, pull-based StreamValue from the recorded trace.

Source

pub fn to_expr(&self) -> Expr

Serializes the cassette to an Expr map keyed by field symbol.

The map carries the format symbol, metadata table, timing, envelope list, diagnostics, and final stats, suitable for persistence and round-tripping through from_expr.

Source

pub fn from_expr(expr: &Expr) -> Result<Self>

Deserializes a cassette from an Expr map produced by to_expr.

Validates the field set and format symbol, then reconstructs metadata, envelopes, timing, diagnostics, and final stats. Fails closed on an unknown format, missing or unexpected fields, or type mismatches.

Source

pub fn redacted(&self) -> Result<Self>

Returns a copy with host-device names and private payloads redacted.

Redacts the metadata, every envelope, and the diagnostic symbols so the result is safe to persist as a golden fixture.

Source

pub fn validate_golden_fixture( &self, path: &str, ) -> Result<StreamGoldenFixtureReport>

Validates the cassette as a golden fixture at path.

Checks the path lives under STREAM_CASSETTE_FIXTURE_ROOT with the cassette extension, that the trace is finite, that envelope sequences match their packet index, that each transport profile is replayable or previewable but never realtime, and that no unredacted payload or host-device name remains. Returns a StreamGoldenFixtureReport on success, or an error describing the first failed invariant.

Trait Implementations§

Source§

impl Clone for StreamCassette

Source§

fn clone(&self) -> StreamCassette

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 StreamCassette

Source§

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

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

impl Eq for StreamCassette

Source§

impl PartialEq for StreamCassette

Source§

fn eq(&self, other: &StreamCassette) -> 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 StreamCassette

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.