Skip to main content

Module stream

Module stream 

Source
Expand description

Append-log JSON publishing over moq-net tracks.

The counterpart to snapshot mode: instead of one JSON value updated over time, a stream is an ordered log of self-contained records. Every Producer::append writes one JSON object as one frame, and a Consumer yields every record in order.

The whole log rides a single group that is never rolled: on a compressed track, that one group is one DEFLATE window, so every record compresses against all the earlier ones. There is deliberately no group rolling (and so no catch-up machinery): a moq-net group has no size cap. A caller that wants to bound the record rate throttles at the source (e.g. the timeline’s segment cadence); a consumer that finds a gap can fetch or extrapolate.

A record that cannot be encoded or written therefore ends the track rather than continuing in a second group: a log missing a record is not lossless, and a gap dressed up as a complete log is worse than a visible failure. A publisher with more to say opens a new track.

§Budget

A log accepts appends for its track’s life; only a record larger than one frame may be (32 MiB) is refused, with [moq_net::Error::FrameTooLarge], before it is written. moq-net holds only the group’s newest 32 MiB and sheds older records from its front, so a consumer that falls further behind, or joins after the front is shed, gets [moq_net::Error::Evicted].

§Choosing a layer

Producer and Consumer own a track. Encoder and Decoder are the same logic without it, for when something else is already in charge of the track. A log has no group boundaries to report, so they carry no state.

Re-exports§

pub use consumer::Consumer;
pub use producer::Finished;
pub use producer::Producer;

Modules§

consumer
Consuming an ordered log from a track: a Decoder plus the track it reads from.
producer
Publishing an ordered log over a track: an Encoder plus the track it writes to.

Structs§

Config
Codec options for an Encoder, and so for the Producer wrapping one.
Decoder
Decodes JSON records from frame payloads.
Encoder
Encodes JSON records into frame payloads.
Pending
An encoded record the caller has not yet acknowledged writing.