Expand description
§moq-net: Media over QUIC networking layer
moq-net is the networking layer for Media over QUIC: real-time pub/sub with built-in
caching, fan-out, and prioritization, on top of QUIC. Sub-second latency at massive scale.
At session setup it negotiates one of two wire protocols: the simplified moq-lite
protocol (the default) or the full IETF moq-transport protocol.
§API
The API is built around Producer/Consumer pairs, with the hierarchy:
- Origin: A collection of Broadcasts, produced by one or more Sessions.
- Broadcast: A collection of Tracks, produced by a single publisher.
- Track: A collection of Groups, delivered out-of-order until expired.
- Group: A collection of Frames, delivered in order until cancelled.
- Frame: Chunks of data with an upfront size.
§Compatibility
The API exposes the intersection of features supported by both protocols, intentionally keeping it small rather than polluting it with half-baked features.
The library is forwards-compatible with the full IETF specification and supports moq-transport drafts 14+ via version negotiation. Everything will work perfectly, so long as your application uses the API as defined above.
For example, there’s no concept of “sub-group”. When connecting to a moq-transport
implementation, we use sub-group=0 for all frames and silently drop any received
frames not in sub-group=0. If your application genuinely needs multiple sub-groups,
tell me why and we can figure something out.
§Producers and Consumers
Each level of the hierarchy is split into a Producer / Consumer pair:
- The Producer is the writer: it appends new state (publishes a broadcast, starts a group, writes frames, closes a track).
- The Consumer is a reader: each consumer holds its own independent view of the producer’s state, with its own cursor through the stream.
Both halves are cheaply clonable so you can hand out multiple handles. Cloning a consumer creates another reader (each at its own cursor); cloning a producer gives another writer that contributes to the same shared state. Closing the last producer signals consumers that no more updates are coming.
§Async
This library is async-first, using tokio for async I/O and task management.
Any plain async method should be awaited from inside an active tokio runtime.
Otherwise you risk a panic.
This requirement is being phased out as more methods grow poll_xxx counterparts
built on kio, so you can drive them from custom executors without a tokio
runtime. You can also call them synchronously, since kio is built on the
standard std::task::Waker API and any std::task::Waker is a valid driver.
Re-exports§
Structs§
- Bandwidth
Consumer - Consumes bandwidth estimates, allowing reads and async change notifications.
- Bandwidth
Producer - Produces bandwidth estimates, notifying consumers when the value changes.
- Bounds
Exceeded - The number is too large to fit in a VarInt (62 bits).
- Broadcast
- A collection of media tracks that can be published and subscribed to.
- Broadcast
Consumer - Subscribe to arbitrary broadcast/tracks.
- Broadcast
Dynamic - Handles on-demand track creation for a broadcast.
- Broadcast
Producer - Manages tracks within a broadcast.
- Broadcast
Stats - A per-broadcast, tier-scoped handle. Cheap to clone.
- Broadcast
Subscription - RAII guard for one of a session’s per-broadcast subscriptions.
See
SessionBroadcasts::subscribe. - Client
- A MoQ client session builder.
- Counters
- Cumulative atomic counters for a single
(tier, role)on a broadcast. - Frame
- A chunk of data with an upfront size.
- Frame
Consumer - Used to consume a frame’s worth of data, streaming as bytes arrive.
- Frame
Producer - Writes a frame’s payload in one or more chunks.
- Group
- A group contains a sequence number because they can arrive out of order.
- Group
Consumer - Consume a group, frame-by-frame.
- Group
Producer - Writes frames to a group in order.
- Origin
- A relay origin, identified by a 62-bit varint on the wire.
- Origin
Consumer - Consumes announced broadcasts matching against an optional prefix.
- Origin
List - Bounded list of
Originentries, typically the hop chain of a broadcast. - Origin
Producer - Announces broadcasts to consumers over the network.
- Path
- A broadcast path that provides safe prefix matching operations.
- Path
Prefixes - A deduplicated list of path prefixes.
- Publisher
Stats - RAII broadcast guard for the publisher role. See
BroadcastStats::publisher. - Publisher
Track - RAII subscription guard for the publisher role.
- Server
- A MoQ server session builder.
- Session
- A MoQ transport session, wrapping a WebTransport connection.
- Session
Broadcasts - Per-session tracker that turns a peer session’s per-broadcast subscription
lifecycle into
broadcasts/broadcasts_closedbumps. - Session
Stats - RAII guard for a connected session, keyed by auth root and tier. Bumps
sessionson construction andsessions_closedon drop. SeeStatsHandle::session. - Stats
- Top-level stats aggregator. Cheap to clone (
Arcinside for the shared runtime state). One instance per relay; sessions get tier-scoped handles viaStats::tier. Build it from aStatsConfigviaStats::new. - Stats
Config - Settings for a
Statsaggregator. Construct withStatsConfig::newand chain thewith_*setters (e.g.StatsConfig::new().with_origin(origin).with_prefix(".foo")), then hand it toStats::new. - Stats
Handle - Tier-scoped wrapper around
Stats. Whatcrate::Client::with_statsandcrate::Server::with_statsaccept. Cheap to clone. - Subscriber
Stats - RAII broadcast guard for the subscriber role. See
BroadcastStats::subscriber. - Subscriber
Track - RAII subscription guard for the subscriber role.
- Time
Overflow - Returned when a
Timescaleoperation would exceed the QUIC VarInt range (2^62 - 1) or overflow during scale conversion or arithmetic. - Timescale
- A timestamp representing the presentation time in a given scale. ex. 1000 for milliseconds.
- TooMany
Origins - Returned when an operation would grow an
OriginListpast its hop-count cap. - Track
- A track is a collection of groups, delivered out-of-order until expired.
- Track
Consumer - A consumer for a track, used to read groups.
- Track
Producer - A producer for a track, used to create new groups.
- Versions
- A set of supported MoQ versions.
Enums§
- Decode
Error - A decode error.
- Encode
Error - An error that occurs during encoding.
- Error
- A list of possible errors that can occur during the session.
- Tier
- Distinguishes traffic classes so a single
Statscan record customer-facing and cluster-peer traffic separately. Each tracked broadcast keeps per-tierCounterson both its publisher and subscriber sides. - Version
- A MoQ protocol version.
Constants§
- ALPNS
- ALPN strings for supported versions.
Traits§
- AsPath
- A trait for types that can be converted to a
Path.
Type Aliases§
- Origin
Announce - A broadcast path and its associated consumer, or None if closed.
- Path
Owned - An owned version of
Pathwith a'staticlifetime. - Result
- Time
- A timestamp representing the presentation time in milliseconds.