Skip to main content

scte35_splice/
traits.rs

1//! SCTE-35-specific dispatch traits. `Parse` / `Serialize` come from
2//! `broadcast_common` and are imported directly at call sites.
3//!
4//! These mirror dvb-si's `DescriptorDef` / `TableDef`: each typed wire entity
5//! declares its discriminant byte and a SCREAMING_SNAKE diagnostic `NAME`, and
6//! the `declare_*!` dispatch macros pin the byte literal in the dispatch list
7//! to the trait const via a drift test, so the list can never silently drift
8//! from the implemented set.
9
10use broadcast_common::Parse;
11
12/// Implemented by every typed splice command; drives
13/// [`crate::commands::AnyCommand`] dispatch. `COMMAND_TYPE` is the
14/// `splice_command_type` byte (§9.6.1, Table 7) this type parses.
15pub trait CommandDef<'a>: Parse<'a, Error = crate::error::Error> {
16    /// Wire `splice_command_type` (§9.6.1, Table 7).
17    const COMMAND_TYPE: u8;
18    /// Diagnostic name, SCREAMING_SNAKE, suffix-free: `SPLICE_INSERT`,
19    /// `TIME_SIGNAL`, `BANDWIDTH_RESERVATION`.
20    const NAME: &'static str;
21}
22
23/// Implemented by every typed splice descriptor; drives
24/// [`crate::descriptors::AnySpliceDescriptor`] dispatch. `TAG` is the
25/// `splice_descriptor_tag` byte (§10.1, Table 16) this type parses.
26pub trait SpliceDescriptorDef<'a>: Parse<'a, Error = crate::error::Error> {
27    /// Wire `splice_descriptor_tag` (§10.1, Table 16).
28    const TAG: u8;
29    /// Diagnostic name, SCREAMING_SNAKE, suffix-free: `AVAIL`, `DTMF`,
30    /// `SEGMENTATION`, `TIME`, `AUDIO`.
31    const NAME: &'static str;
32}