Internals
Contributing
This page points a contributor at the rest. Issues go in the tracker.
- DEVELOPMENT.md covers the build, the tests, the commit rules, the threading and other conventions, and working against a local moq checkout.
- Where each crate is explained maps each crate to the page that explains how it works inside.
- Instrumentation and tests explains the test layers and the debug overlay.
- site/README.md builds the documentation site, with the API docs, and serves it locally.
Where each crate is explained
| Crate | Internals page |
|---|---|
iroh-live | The node and its transport, for the facade, its errors, and calls |
iroh-live-node | The node and its transport, Authorization and audiences, explained |
moq-transport-iroh | The node and its transport |
iroh-live-rooms | Authorization and audiences, explained |
moq-ext-access | Authorization and audiences, explained |
moq-ext-publisher, moq-ext-sources | Publishing |
moq-ext-player | Subscribing, Playout and A/V sync |
moq-ext-adaptive | Adaptive rendition switching |
moq-ext-json | Send data without media |
moq-ext-egui | Instrumentation and tests |
iroh-live-relay | Peer-to-peer and the media relay, iroh-live-relay reference |
iroh-live-cli | irl reference |
Crates and features says what each crate holds.
No moq-ext-* crate depends on iroh, so each could move upstream into moq,
the UI crate moq-ext-egui included. moq-ext-player and
moq-ext-publisher do not depend on each other. A transport publishes a
LocalBroadcast by reading it through moq_net::Consume. It builds a
RemoteBroadcast from a route table with from_resolved. iroh-live-rooms
has no media dependency. iroh-live depends on both sides and is the only
crate that joins them.
Upstream covers one publisher with one rendition, and one subscriber that
takes what it is given. The moq-ext-* crates add three things on top.
- Publishing encodes one source into a ladder of renditions.
- Subscribing starts a player that picks among those renditions as the downlink changes, and swaps decoders without a blank frame.
- Each player’s playout clock keeps audio and video aligned across two separate decode paths.
The docs
The docs are an mdBook under docs/,
with SUMMARY.md as the table of contents. Each page has one job:
getting-started/takes a new reader from nothing to a running program, in four short pages.guides/does one common task, CLI first, then a Rust program, in under 250 lines. A page starts with an “In short” block.concepts/explains the model in three pages: how it works, the two kinds of media relay server, and access.hosted/describes the hosted preview.reference/lists flags, defaults and limits, and answers problems.advanced/holds the specialized tasks and the deeper concept pages.internals/explains how the crates work inside, for contributors.
A new page goes into the first section whose reader needs it. Keep Get started, Guides and Concepts short, and push depth down into Advanced.
Rules that keep the pages consistent:
- A page describes what a reader can run today on
main. A plan, such as Hosted media relays, says so in a callout at its top. Move a fact out of a plan into a guide once a reader can run it. - A fact lives in one page, and other pages link to it. The latency modes
live in the
irlreference, the adaptation defaults in Adaptive rendition switching,IROH_SECRETin theirlreference, the feature list in Crates and features, and the cross-compile steps in Publish from a Raspberry Pi. - The pages use the terms of the glossary. Never
write a bare “relay”. An iroh relay is iroh’s, for hole punching and
connection fallback. A media relay is the MoQ server that forwards and
fans out media, such as
iroh-live-relay. A relay link is a node’s session with a media relay. Code names such as--relayandiroh-live-relaystay as they are, and the prose around them says which kind they mean. - A path’s id placeholder is
<endpoint id>in prose, and<peer>in reference pages that also show*and**patterns. - Link text matches the title of the page it links to.
- A page ends with “Where to go next”.
- Paragraphs have six sentences or fewer, and sentences stay under 25 words where they can. Define a term at its first use.
- In
internals/, explain the behavior first. Put file and constant names in lists, not in the middle of the explanation.
Code in the docs
Every rust block in every page of docs/ and in every crate README
compiles as a doctest of the iroh-live-doc-tests crate. Its build script
finds the pages by itself, so a new page needs no registration. The crate’s
dev-dependencies turn on the features that the pages use.
- A
rustblock compiles and runs. Mark a complete programrust,no_run, since most programs open devices or wait for peers. - Hide setup lines, such as imports and a wrapping function, with a leading
#. They compile, and the reader does not see them. A short excerpt with hidden setup is better than an uncompiled one. - Mark a fragment that cannot compile on its own
rust,ignore. Usetextfor output, diagrams, and anything that is not Rust.
Run these checks before you commit docs:
cargo make docs-check
cargo make site-no-api
docs-check runs the site tool’s check, the docs tests of irl, the doc
command test of iroh-live-relay and the doctests of iroh-live-doc-tests.
Together they check:
- every relative link and anchor in the repository’s Markdown,
- that every moq rev in the docs matches the root
Cargo.toml, and that every Cargo feature is in Crates and features, - that every Rust block compiles,
- that every command in a shell block of
docs/,site/and the READMEs parses, and names packages, targets, features andcargo maketasks that exist, - that the
irlreference names every flag.
site-no-api builds the site without the API docs and checks the links
between its pages. site/README.md describes the site
build.