1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
//! Opaque binary payloads over [`moq-net`](moq_net) tracks, in two modes:
//!
//! - [`snapshot`]: **lossy**. One value updated over time; a consumer only gets the most recent
//! one. Older values are superseded and dropped.
//! - [`stream`]: **lossless**. An ordered append-log of self-contained payloads, delivered in order
//! with nothing superseded. Bounded by the group cache: see [`stream`] for what that costs a
//! consumer that falls behind.
//!
//! Pick [`snapshot`] when consumers care about "what is the value now" (a poster image, a
//! serialized state blob) and [`stream`] when they care about every payload (an event log, a
//! sequence of samples).
//!
//! The bytes are opaque: this crate frames them onto a track and optionally compresses them, and
//! never looks inside. For JSON documents reach for [`moq-json`](https://docs.rs/moq-json) instead,
//! which adds RFC 7396 merge-patch deltas on top of the same two modes.
//!
//! Compression is [`moq-flate`](moq_flate), the same group-scoped DEFLATE moq-json uses, so the two
//! agree on the wire: each group is one raw DEFLATE stream, sync-flushed at every frame boundary. A
//! [`stream`] therefore compresses each payload against the earlier ones in its group, while a
//! [`snapshot`] group holds a single self-contained value.
// The browser transport is `!Send`, so on wasm the shared state behind these `Arc`s is
// too and clippy suggests `Rc`. The same code is genuinely cross-thread on native, so
// `Arc` stays and the lint is unactionable here.
/// How a binary track compresses its frames.
/// Errors produced while publishing or consuming binary payloads.
/// A [`Result`](std::result::Result) using this crate's [`Error`].
pub type Result<T> = Result;