srt_runtime/lib.rs
1//! `srt-runtime` — SRT (Secure Reliable Transport) packet codecs.
2//!
3//! Spec grounding: [`draft-sharabayko-srt-01`](https://datatracker.ietf.org/doc/html/draft-sharabayko-srt-01)
4//! (free, redistributable IETF Internet-Draft), vendored at
5//! `specs/ietf_draft_sharabayko_srt_01.txt`; the curated field tables this
6//! crate implements against live in `specs/rules/srt-rules.md`.
7//!
8//! # Scope of this release
9//!
10//! This is the **packet codec** deliverable only: typed, byte-exact
11//! `parse`/`serialize` for every packet type in §3 (Packet Structure) — the
12//! 16-byte SRT header, the data packet (§3.1), and every control packet type
13//! (§3.2): Handshake (with its extension messages: Handshake Extension,
14//! §3.2.1.1; Key Material, §3.2.1.2/§3.2.2; Stream ID, §3.2.1.3; Group
15//! Membership, §3.2.1.4), Keep-Alive, ACK, NAK, Congestion Warning, Shutdown,
16//! ACKACK, Message Drop Request, and Peer Error.
17//!
18//! **Explicit follow-ups, not attempted here:**
19//! - The handshake **state machine** (caller/listener/rendezvous exchange,
20//! §4.3) — this crate parses/builds handshake *packets*, not a connection.
21//! - ARQ / loss handling, TSBPD, congestion control (§4-§5).
22//! - Actual AES key-wrap/unwrap **crypto** (§6) — [`packet::KeyMaterial`]
23//! carries the wrapped-key bytes opaquely.
24//! - A `tokio` socket adapter (mirroring `rtsp-runtime`'s `io` module).
25//!
26//! # The sans-IO contract
27//!
28//! No sockets, no state machine: [`packet::SrtPacket::parse`] takes the bytes
29//! of one UDP datagram and returns a typed packet; the packet's
30//! `serialize_into` writes it back out. Everything here is a pure, allocating
31//! (but not I/O-performing) parse/serialize pair.
32//!
33//! # Reserved-bit policy
34//!
35//! Fields the spec documents as fixed-value or reserved-for-future-use
36//! (`Subtype` on every Control Type except User-Defined; the header
37//! `Type-specific Information` word where a packet type does not use it; the
38//! Key Material message's `S`/`V`/`PT`/`Sign`/`Resv1`/`Resv2`/`Resv3` fields)
39//! are validated against their spec-mandated value on parse and are not
40//! stored in the typed structs — they are reconstructed on serialize. A
41//! non-compliant value is a structured [`error::Error`], never a panic.
42//!
43//! # Module map
44//! - [`packet`] — [`packet::SrtPacket`], the data/control packet types, and
45//! their sub-structures (handshake extensions, Key Material, ACK variants,
46//! NAK loss-list coding).
47//! - [`error`] — the [`Error`] enum and [`Result`] alias.
48
49#![cfg_attr(not(feature = "std"), no_std)]
50#![forbid(unsafe_code)]
51#![warn(missing_docs)]
52#![cfg_attr(docsrs, feature(doc_cfg))]
53
54extern crate alloc;
55
56pub mod error;
57pub mod packet;
58
59pub use error::{Error, Result};
60pub use packet::SrtPacket;
61
62/// The Internet-Draft this crate implements packet structure from.
63pub const SPEC: &str = "draft-sharabayko-srt-01";