Rust Libraries
The Rust implementation provides the reference implementation of the MoQ protocol, along with server-side tools and native applications.
Core Libraries
moq-net
The networking layer for MoQ. At session setup it negotiates one of two wire protocols: the simplified moq-lite protocol or the full IETF moq-transport protocol.
Features:
- Broadcasts, tracks, groups, and frames
- Built-in concurrency and deduplication
- QUIC stream management
- Prioritization and backpressure
hang
Media-specific encoding/streaming library built on top of moq-net.
Features:
- Catalog for track discovery
- Container format (timestamp + codec bitstream)
- Support for H.264/265, VP8/9, AV1, AAC, Opus
moq-mux
Media muxers and demuxers for importing existing formats into MoQ.
Features:
- fMP4/CMAF import
- HLS playlist import
- H.264/H.265 Annex B parsing
- AAC and Opus codec support
Authentication
moq-token
JWT authentication library and CLI tool for generating tokens.
Features:
- HMAC and RSA/ECDSA signing
- Path-based authorization
- Token generation and verification
- Available as library and CLI
Networking
web-transport
QUIC and WebTransport implementation for Rust.
Features:
- Quinn-based QUIC
- WebTransport protocol support
- TLS certificate management
- Server and client modes
moq-native
Opinionated helpers to configure a Quinn QUIC endpoint.
Features:
- TLS certificate management
- QUIC transport configuration
- Connection setup helpers
CLI Tools
moq-cli
Command-line tool for media operations (binary name: moq-cli).
Features:
- Publish video from files or FFmpeg
- Test and development
- Media server deployments
Installation:
cargo install moq-cliUsage:
# Publish a video file
moq-cli publish video.mp4
# Publish from FFmpeg
ffmpeg -i input.mp4 -f mpegts - | moq-cli publish -moq-token-cli
Command-line tool for JWT token management (binary name: moq-token-cli).
Installation:
cargo install moq-token-cliUsage:
# Generate a key
moq-token-cli --key root.jwk generate
# Sign a token
moq-token-cli --key root.jwk sign \
--root "rooms/123" \
--publish "alice" \
--expires 1735689600See Authentication guide for details.
Utilities
libmoq
C bindings for moq-net via FFI.
Use cases:
- Integrate with C/C++ applications
- Bindings for other languages
- Legacy system integration
Installation
Libraries (crates.io)
Add the crates you need to your Cargo.toml:
[dependencies]
moq-net = "0.1"
hang = "0.1"All crates are published to crates.io with API docs on docs.rs.
Binaries
The relay and CLI ship through several channels. Pick whichever fits:
# crates.io (any platform with a Rust toolchain)
cargo install moq-relay moq-cli moq-token-cli
# Homebrew (macOS / Linux)
brew install moq-dev/tap/moq-relay moq-dev/tap/moq-cli
# Debian / Ubuntu (see the Linux packages guide for repo setup)
sudo apt install moq-relay moq-cli
# Fedora / RHEL (see the Linux packages guide for repo setup)
sudo dnf install moq-relay moq-cli
# Nix
nix build github:moq-dev/moq#moq-relay
nix build github:moq-dev/moq#moq-cli
# Docker
docker run moqdev/moq-relay
docker run moqdev/moq-cliSee Linux packages for apt/dnf repository setup and the Applications docs for usage.
From source
git clone https://github.com/moq-dev/moq
cd moq/rs
cargo build --releaseQuick Start
moq-native configures the QUIC endpoint and TLS for you, then moq-net handles the MoQ handshake. Connect to a relay with a few lines:
let client = moq_native::ClientConfig::default().init()?;
let url = url::Url::parse("https://relay.moq.dev/anon")?;
let session = client.connect(url).await?;To publish or consume, wire an Origin into the session before connecting:
// Subscribe: wait for broadcasts to be announced.
let origin = moq_net::Origin::new().produce();
let mut consumer = origin.consume();
let session = client.with_consume(origin).connect(url).await?;
while let Some((path, broadcast)) = consumer.announced().await {
// ... subscribe to tracks on each broadcast ...
}The Native guide walks through publishing, subscribing, reading the catalog, and decoding frames end to end. For runnable code see the hang/examples directory: video.rs (publish) and subscribe.rs.
API Documentation
Full API documentation is available on docs.rs:
Next Steps
- Explore moq-net - Networking layer
- Explore hang - Media library
- Explore moq-mux - Media import
- Deploy moq-relay - Relay server
- View code examples