Skip to main content

dvb_si/descriptors/
mod.rs

1//! DVB + MPEG-2 descriptors. Each descriptor tag gets its own submodule file.
2//!
3//! The usual way to consume a descriptor is to walk a table's raw descriptor
4//! loop and call the specific descriptor module's `parse` for the tags you
5//! care about (e.g. [`satellite_delivery_system`], [`service`], [`linkage`]).
6//!
7//! The [`Descriptor`] enum covers only the small set of MPEG-2 descriptors
8//! that appear in contexts without surrounding table semantics (CA,
9//! data_stream_alignment, private_data_indicator, registration); every other
10//! tag lands as [`Descriptor::Unknown`] with its raw bytes preserved — it is
11//! NOT a dispatcher over the full typed-descriptor set.
12
13pub mod aac;
14pub mod ac3;
15pub mod adaptation_field_data;
16pub mod ancillary_data;
17pub mod announcement_support;
18pub mod application_signalling;
19pub mod bouquet_name;
20pub mod ca;
21pub mod ca_identifier;
22pub mod cable_delivery_system;
23pub mod cell_frequency_link;
24pub mod cell_list;
25pub mod component;
26pub mod content;
27pub mod content_identifier;
28pub mod country_availability;
29pub mod data_broadcast;
30pub mod data_broadcast_id;
31pub mod data_stream_alignment;
32pub mod default_authority;
33pub mod dsng;
34pub mod dts;
35pub mod ecm_repetition_rate;
36pub mod enhanced_ac3;
37pub mod extended_event;
38pub mod extension;
39pub mod frequency_list;
40pub mod fta_content_management;
41pub mod iso_639_language;
42pub mod linkage;
43pub mod local_time_offset;
44pub mod logical_channel;
45pub mod mosaic;
46pub mod multilingual_bouquet_name;
47pub mod multilingual_component;
48pub mod multilingual_network_name;
49pub mod multilingual_service_name;
50pub mod network_name;
51pub mod nvod_reference;
52pub mod parental_rating;
53pub mod partial_transport_stream;
54pub mod pdc;
55pub mod private_data_indicator;
56pub mod private_data_specifier;
57pub mod registration;
58pub mod related_content;
59pub mod s2_satellite_delivery_system;
60pub mod satellite_delivery_system;
61pub mod scrambling;
62pub mod service;
63pub mod service_availability;
64pub mod service_identifier;
65pub mod service_list;
66pub mod service_move;
67pub mod short_event;
68pub mod short_smoothing_buffer;
69pub mod stream_identifier;
70pub mod stuffing;
71pub mod subtitling;
72pub mod telephone;
73pub mod teletext;
74pub mod terrestrial_delivery_system;
75pub mod time_shifted_event;
76pub mod time_shifted_service;
77pub mod time_slice_fec_identifier;
78pub mod transport_stream;
79pub mod tva_id;
80pub mod vbi_data;
81pub mod vbi_teletext;
82pub mod xait_location;
83
84pub use ca::CaDescriptor;
85pub use data_stream_alignment::DataStreamAlignmentDescriptor;
86pub use private_data_indicator::PrivateDataIndicatorDescriptor;
87pub use registration::RegistrationDescriptor;
88
89/// Unified descriptor variant. Variants land as per-descriptor phases complete.
90#[derive(Debug, Clone, PartialEq, Eq)]
91#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
92#[non_exhaustive]
93pub enum Descriptor<'a> {
94    /// Conditional Access descriptor (tag 0x09).
95    Ca(CaDescriptor<'a>),
96    /// Data stream alignment descriptor (tag 0x06).
97    DataStreamAlignment(DataStreamAlignmentDescriptor),
98    /// Private Data Indicator descriptor (tag 0x0F).
99    PrivateDataIndicator(PrivateDataIndicatorDescriptor),
100    /// Registration descriptor (tag 0x05).
101    Registration(RegistrationDescriptor<'a>),
102    /// Forward-compatible fallthrough for tags we don't recognise.
103    Unknown {
104        /// The raw tag byte.
105        tag: u8,
106        /// The raw payload (descriptor_length bytes, not including the 2-byte header).
107        #[cfg_attr(feature = "serde", serde(borrow))]
108        bytes: &'a [u8],
109    },
110}
111
112impl<'a> Descriptor<'a> {
113    /// The underlying tag byte.
114    #[must_use]
115    pub const fn tag(&self) -> u8 {
116        match self {
117            Self::Ca(_) => ca::TAG,
118            Self::DataStreamAlignment(_) => data_stream_alignment::TAG,
119            Self::PrivateDataIndicator(_) => private_data_indicator::TAG,
120            Self::Registration(_) => registration::TAG,
121            Self::Unknown { tag, .. } => *tag,
122        }
123    }
124}