Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions doc/lib/rs/crate/moq-tokio.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ Tokio-based connection helpers for native Rust applications. Provides TLS config
moq-tokio = "0.19"
```

The default features cover a working build. If you set `default-features = false`, pick a QUIC backend (`quinn`, `quiche`, or `noq`); a build without one fails with a message naming them. `noq` also needs a crypto provider (`aws-lc-rs` or `ring`) to compile. `quinn` takes one from either feature or from a provider you install yourself with `CryptoProvider::install_default()`, and `quiche` brings its own.

## API Reference

Full API documentation: [docs.rs/moq-tokio](https://docs.rs/moq-tokio)
Expand Down
28 changes: 28 additions & 0 deletions rs/justfile
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,34 @@ features:
cargo clippy --locked --workspace --all-targets --all-features -- -D warnings
RUSTDOCFLAGS="-D warnings" cargo doc --locked --workspace --all-features --no-deps
cargo nextest run --locked --workspace --all-targets --all-features
just rs _unsupported-features

# The workspace compiles above can't reach a backend-less moq-tokio: cargo unifies
# features per crate, so a member depending on it with a backend enables one for
# everyone. Only a per-crate invocation selects the shapes an external consumer with
# `default-features = false` can land on, so assert those still fail on their own
# `compile_error!` rather than on whatever breaks first inside the modules.
#
# `--features quinn` is deliberately absent: it compiles without a provider feature and
# takes one from `CryptoProvider::install_default()` at runtime, which is supported.
_unsupported-features:
#!/usr/bin/env bash
set -euo pipefail

expect() {
local want="$1"; shift
local got
got=$(cargo check --locked -p moq-tokio --no-default-features "$@" 2>&1 || true)
if ! grep -qF "$want" <<< "$got"; then
echo "rs: moq-tokio ${*:-(no features)} should fail on: $want" >&2
echo "$got" | grep -E '^error' >&2 || true
exit 1
fi
}

expect "requires a QUIC backend"
expect "requires a QUIC backend" --features tcp
expect "requires a crypto provider" --features noq

# nextest, not `cargo test`, so a wedged test is killed instead of pinning a core
# until someone notices (`.config/nextest.toml` sets the timeout). The trade is
Expand Down
39 changes: 38 additions & 1 deletion rs/moq-tokio/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,47 @@
//! - Iroh P2P (requires `iroh` feature)
//!
//! See [`Client`] for connecting to relays and [`Server`] for accepting
//! connections. [`mdns`] finds peers to connect to on the local network.
//! connections. The `mdns` module, behind the feature of the same name, finds
//! peers to connect to on the local network.
//!
//! # Required features
//!
//! A build needs a QUIC backend (`quinn`, `quiche`, or `noq`). `noq` additionally
//! needs a crypto provider (`aws-lc-rs` or `ring`) to compile at all. `quinn` takes
//! one from either feature or from a provider the application installed with
//! `CryptoProvider::install_default()`, and `quiche` brings its own. The `default`
Comment on lines +17 to +20

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Require a Rustls provider for quiche servers

When a consumer follows this guidance and enables only quiche, server startup still calls crypto::provider() from QuicheServer::new while computing certificate fingerprints; with neither provider feature nor an application-installed Rustls provider, that function panics. Quiche's BoringSSL provider does not populate Rustls's process-wide provider, so document/install a Rustls provider for this configuration or avoid using Rustls for the fingerprint.

AGENTS.md reference: AGENTS.md:L107-L109

Useful? React with 👍 / 👎.

//! set covers all of this; `default-features = false` means picking them yourself.

#![warn(missing_docs)]

// A backend-less build is not a supported configuration, and without these it fails deep in
// the modules that assume one: `QuicBackend` becomes an empty enum, `RequestKind` an empty
// match, and `worker`/`server` reference items their own gates removed. Say so once here
// instead of letting the caller read eight errors that never name the cause.
//
// Workspace builds never reach these: cargo unifies features per crate, so a member that
// depends on moq-tokio with a backend enables it for everyone. Only `-p moq-tokio` or an
// external consumer with `default-features = false` can select the broken shapes.
#[cfg(not(any(feature = "quinn", feature = "quiche", feature = "noq")))]
compile_error!(
"moq-tokio requires a QUIC backend: enable one of the `quinn`, `quiche`, or `noq` features. \
A tcp/uds-only build is not supported (see moq-dev/moq#2834)."
);

// Without a provider feature, `web-transport-noq` is built without its own, and the endpoint
// constructors this crate calls stop existing: the build fails with three unrelated E0599s
// about `EndpointConfig::default` and `ServerConfig::with_crypto`. Say which feature is
// missing instead.
//
// Only `noq` gets this. `quinn` compiles either way and resolves its provider at runtime
// through `crypto::provider()`, which accepts one the application installed with
// `CryptoProvider::install_default()`; refusing that build would remove a supported path.
// `quiche` needs neither, since boringssl brings its own.
#[cfg(all(feature = "noq", not(any(feature = "aws-lc-rs", feature = "ring"))))]
compile_error!(
"the `noq` backend requires a crypto provider: enable `aws-lc-rs` or `ring`."
);

pub mod accept;
pub use moq_sock::bind;
pub mod cli;
Expand Down