Skip to content

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

crates.iodocs.rs

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

Learn more

hang

crates.iodocs.rs

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

Learn more

moq-mux

crates.iodocs.rs

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

Learn more

Authentication

moq-token

crates.iodocs.rs

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

Learn more

Networking

web-transport

QUIC and WebTransport implementation for Rust.

Features:

  • Quinn-based QUIC
  • WebTransport protocol support
  • TLS certificate management
  • Server and client modes

Learn more

moq-native

docs.rs

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:

bash
cargo install moq-cli

Usage:

bash
# Publish a video file
moq-cli publish video.mp4

# Publish from FFmpeg
ffmpeg -i input.mp4 -f mpegts - | moq-cli publish -

Learn more

moq-token-cli

Command-line tool for JWT token management (binary name: moq-token-cli).

Installation:

bash
cargo install moq-token-cli

Usage:

bash
# 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 1735689600

See Authentication guide for details.

Utilities

libmoq

docs.rs

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:

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:

bash
# 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-cli

See Linux packages for apt/dnf repository setup and the Applications docs for usage.

From source

bash
git clone https://github.com/moq-dev/moq
cd moq/rs
cargo build --release

Quick 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:

rust
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:

rust
// 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

Licensed under MIT or Apache-2.0