broadcast-core
The wire-format contract of the rust-broadcast workspace: the
symmetric Parse/ParsePrefix/ParseWith/Serialize traits, checked field-width helpers, MSB-first
bit I/O, typed reserved-bit fields, the big-endian wire field readers, media
timescales, the shared error kinds and the container-independent CENC scheme
identity.
What it does / what it does not
This is the low-level floor that the DVB/MPEG format crates build on: every
wire type in the workspace implements its Parse/Serialize pair, and the
streaming Stage contract every muxer and demuxer stage follows lives here
too. It is published as 0.1: the API is the contract the wire crates build
on and is not yet frozen; it is meant to freeze at 1.0. It holds
only settled pieces that do not change as new formats are added, so they can
grow without a breaking change here rippling up through every consumer. The
crate is #![no_std] + alloc on every target and depends on nothing but an
optional serde derive.
It carries no CRC, media-clock wrap arithmetic, XML reader or HTTP-date
codec — those stay in broadcast-common and its siblings. It has no shared
format error enum either: it owns only the cross-cutting failure kinds
(short buffer, field overflow, CRC mismatch, invalid sync, …) that each crate
wraps in its own Error.
Contents
| Path | What it is |
|---|---|
traits (Parse, ParsePrefix, ParseWith, Serialize) |
The symmetric parse/serialize contract every wire type implements, re-exported at the crate root (the root re-exports these four traits and nothing else). ParseWith bounds work or nesting through the caller's limits; ParsePrefix returns the bytes a length-delimited structure took. |
len |
Range-checked narrowing for wire length/count fields (fit_u8, fit_u16, fit_bits, fit_mask, …) and check_limit, the read-side twin that reports a caller-supplied limit exceeded. |
bits |
Backing MSB-first BitReader, BitWriter and growable BitBuf; BitError carries the shared kinds. |
error |
The shared failure kinds (BufferTooShort, FieldOverflow, CrcMismatch, LimitExceeded, …), each #[non_exhaustive] with a const fn new, and WireError, all of them as one enum. |
ids (TrackId) |
The one track identity the box layer, the muxing hub and damage reports share. |
range (ByteRange) |
An absolute byte range of the input, with a checked end. |
stage (Stage, Demand, Instant) |
The streaming-stage contract and the nanosecond monotonic clock it is driven on. |
damage |
The report of content a reader skipped, and the caller's policy for it. |
units |
Decimal time-unit and byte ratios. |
reserved |
Typed runs of reserved bits that round-trip what was parsed, including FieldValue<BITS> for a catch-all arm's wire bits. |
timescale (timescale!) |
A non-zero media timescale and wrap-safe rescaling. |
cenc (cenc::CencScheme) |
The container-independent CENC scheme identity: cenc, cens, cbc1, cbcs. |
wire |
The checked Reader cursor and Writer, with big-endian, little-endian, signed and 24/48-bit forms, and field::<N>() for an offset the caller already holds. |
impl_spec_display! |
The Display-from-name() macro every public spec enum uses. |
Feature flags
| Feature | Default | What it enables |
|---|---|---|
std |
yes | Forwards to serde/std; the crate itself is no_std + alloc on every target. |
serde |
no | serde::Serialize on the shared spec types. |
[]
= "0.1"
# embedded (no_std + alloc):
# broadcast-core = { version = "0.1", default-features = false }
Stability
This is 0.1: the API is not yet frozen. It is meant to freeze at
1.0, as the stable floor the wire-format crates build on. What 1.0 will
promise:
- every item's name, signature, trait items, derives and
implset, and the expansion of the two exported macros,timescale!andimpl_spec_display!(thecore_api_pinworkspace guard pins all of them and fails on any un-reviewed change); - the shared error kinds stay
Copy, carry only&'static strlabels and plain numbers, and grow only by new fields reached through theirconst fn new(they are#[non_exhaustive]); - the
Stagedriver contract written on the trait, withDemand::Atbinding and every other demand advisory; - the serialised form of a damage report (
snake_casetokens, a tagged structured cause).
Display text is diagnostic and outside the promise. Before 1.0,
additions are still possible as reviewed edits of the pin.
Related crates and licence
Part of the rust-broadcast workspace. Licensed under either of Apache-2.0 or MIT at your option.