Expand description
Lossy latest-value JSON publishing over moq-net tracks.
One value updated over time. Consumer::next yields each state with its frame timestamp,
in order, skipping every group a newer one supersedes; Consumer::latest skips to the
newest state. Superseded groups are lost, so use stream when every
record must survive, or window for a bounded recent history.
On the wire the value is published as a series of groups, where each group is self-contained: its first frame is a full snapshot and any following frames are RFC 7396 JSON Merge Patch deltas applied in order. Every group starts independently, so a reader can resynchronize after skipping superseded groups without needing earlier deltas.
Config::deltas turns deltas off, so every change is a fresh snapshot group, matching a plain
“one JSON blob per group” track.
§Refresh
A group of deltas grows until a joiner wants a fresh one. A track created with a
refresh ratio asks for one when a subscriber joins while the
open group’s deltas outweigh that ratio times its snapshot. The joiner still reads the cached
group meanwhile: the ratio limits how often groups roll, not what a joiner downloads.
Producer::poll_refresh answers by restating the value as a snapshot in
a new group; Encoder::snapshot does the same for a caller that owns the track. Without a ratio,
or behind a relay that cannot forward the ask, a group runs to the encoder’s frame and byte caps.
A caller can also roll a group for its own reasons with Producer::cut: it closes the open
group and leaves the next update to open the replacement with a full snapshot, so the deltas
already written stop being provisional without publishing an empty group.
§Choosing a layer
Producer and Consumer own a track: hand one a
track::Producer and it manages the groups for you.
Encoder and Decoder are the same logic without the track. The encoder turns values into
Encoded frame payloads and says where the group boundaries fall; the decoder reconstructs a
value from those payloads. Reach for them when something else is already in charge of the track,
for example a moq_mux::container::Producer also managing a timeline and a catalog estimate.
Encoded::keyframe maps straight onto moq_mux::container::Frame::keyframe.
Encoding advances state that the frame’s consumers depend on, so Encoder::update hands back a
Pending the caller commits once the write succeeds. Dropping it uncommitted resynchronizes
the encoder, which keeps a frame that never reached the wire from desyncing the stream.
Re-exports§
pub use consumer::Consumer;pub use producer::Finished;pub use producer::Guard;pub use producer::Producer;
Modules§
- consumer
- Consuming a JSON value from a track: a
Decoderplus the track it reads from. - producer
- Publishing a JSON value over a track: an
Encoderplus the track it writes to.
Structs§
- Config
- Codec options for an
Encoder, and so for theProducerwrapping one. - Decoder
- Reconstructs a JSON value from the snapshot and delta frames of a group.
- Encoded
- One encoded frame, and the group boundary it implies.
- Encoder
- Encodes a JSON value into frame payloads, choosing snapshots and deltas automatically.
- Pending
- An encoded frame the caller has not yet acknowledged writing.