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 ac3;
14pub mod bouquet_name;
15pub mod ca;
16pub mod cable_delivery_system;
17pub mod component;
18pub mod content;
19pub mod content_identifier;
20pub mod data_stream_alignment;
21pub mod default_authority;
22pub mod enhanced_ac3;
23pub mod extended_event;
24pub mod frequency_list;
25pub mod iso_639_language;
26pub mod linkage;
27pub mod local_time_offset;
28pub mod logical_channel;
29pub mod network_name;
30pub mod parental_rating;
31pub mod private_data_indicator;
32pub mod registration;
33pub mod s2_satellite_delivery_system;
34pub mod satellite_delivery_system;
35pub mod service;
36pub mod service_list;
37pub mod short_event;
38pub mod stream_identifier;
39pub mod subtitling;
40pub mod teletext;
41pub mod terrestrial_delivery_system;
42
43pub use ca::CaDescriptor;
44pub use data_stream_alignment::DataStreamAlignmentDescriptor;
45pub use private_data_indicator::PrivateDataIndicatorDescriptor;
46pub use registration::RegistrationDescriptor;
47
48/// Unified descriptor variant. Variants land as per-descriptor phases complete.
49#[derive(Debug, Clone, PartialEq, Eq)]
50#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
51#[non_exhaustive]
52pub enum Descriptor<'a> {
53    /// Conditional Access descriptor (tag 0x09).
54    Ca(CaDescriptor<'a>),
55    /// Data stream alignment descriptor (tag 0x06).
56    DataStreamAlignment(DataStreamAlignmentDescriptor),
57    /// Private Data Indicator descriptor (tag 0x0F).
58    PrivateDataIndicator(PrivateDataIndicatorDescriptor),
59    /// Registration descriptor (tag 0x05).
60    Registration(RegistrationDescriptor<'a>),
61    /// Forward-compatible fallthrough for tags we don't recognise.
62    Unknown {
63        /// The raw tag byte.
64        tag: u8,
65        /// The raw payload (descriptor_length bytes, not including the 2-byte header).
66        #[cfg_attr(feature = "serde", serde(borrow))]
67        bytes: &'a [u8],
68    },
69}
70
71impl<'a> Descriptor<'a> {
72    /// The underlying tag byte.
73    #[must_use]
74    pub const fn tag(&self) -> u8 {
75        match self {
76            Self::Ca(_) => ca::TAG,
77            Self::DataStreamAlignment(_) => data_stream_alignment::TAG,
78            Self::PrivateDataIndicator(_) => private_data_indicator::TAG,
79            Self::Registration(_) => registration::TAG,
80            Self::Unknown { tag, .. } => *tag,
81        }
82    }
83}