dvb_si/traits.rs
1//! SI-specific traits. `Parse` is provided by `dvb_common`
2//! and imported directly at call sites.
3
4use dvb_common::Parse;
5
6/// Implemented by every typed descriptor; drives [`crate::descriptors::AnyDescriptor`]
7/// dispatch. `TAG` is the wire descriptor_tag this type parses.
8pub trait DescriptorDef<'a>: Parse<'a, Error = crate::error::Error> {
9 /// Wire descriptor_tag.
10 const TAG: u8;
11 /// Diagnostic name. Convention (workspace-wide): SCREAMING_SNAKE,
12 /// suffix-free — `SHORT_EVENT`, `EXTENSION`, `NETWORK_NAME`
13 /// (no `_descriptor` suffix).
14 const NAME: &'static str;
15}
16
17/// Implemented by every typed table-section parser; drives
18/// [`crate::tables::AnyTableSection`] dispatch. `TABLE_ID_RANGES` lists the
19/// inclusive `(lo, hi)` table_id ranges this type accepts.
20///
21/// Third-party types may implement this trait to register private table_ids
22/// via [`TableRegistry`][crate::tables::TableRegistry].
23pub trait TableDef<'a>: dvb_common::Parse<'a, Error = crate::error::Error> {
24 /// Inclusive `(lo, hi)` table_id ranges this type parses.
25 ///
26 /// Single-id types use a single-element slice `&[(id, id)]`.
27 /// Multi-range types (e.g. SDT `[(0x42,0x42),(0x46,0x46)]`) list each
28 /// contiguous run separately.
29 const TABLE_ID_RANGES: &'static [(u8, u8)];
30 /// Spec name for diagnostics. SCREAMING_SNAKE, suffix-free:
31 /// `PROGRAM_ASSOCIATION`, `EVENT_INFORMATION`, `SERVICE_DESCRIPTION`.
32 ///
33 /// Deliberate exceptions: `DSM_CC_SECTION` and `MPE_DATAGRAM_SECTION` keep
34 /// `_SECTION` because it is part of the spec entity name, not a type suffix.
35 const NAME: &'static str;
36}