1#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
2pub enum PID {
3 PAT,
4 CAT,
5 TSDT,
6
7 NIT,
9 SDT,
11 EIT,
13 RST,
15 TDT,
17 NetworkSynchronization,
19 RNT,
21
22 InbandSignalling,
23 Measurement,
24 DIT,
25 SIT,
26
27 NULL,
28
29 Reserved(u16),
32
33 Other(u16),
34}
35
36impl PID {
37 #[inline(always)]
38 pub fn is_section(self) -> bool {
39 match self {
40 PID::Other(..) | PID::NULL | PID::Reserved(..) => false,
41 _ => true,
42 }
43 }
44
45 #[inline(always)]
46 pub fn is_null(self) -> bool {
47 match self {
48 PID::NULL => true,
49 _ => false,
50 }
51 }
52
53 #[inline(always)]
54 pub fn is_other(self) -> bool {
55 match self {
56 PID::Other(..) => true,
57 _ => false,
58 }
59 }
60}
61
62impl From<u16> for PID {
63 fn from(d: u16) -> Self {
64 match d {
65 0x0000 => PID::PAT,
66 0x0001 => PID::CAT,
67 0x0002 => PID::TSDT,
68 0x0003..=0x000F => PID::Reserved(d),
69 0x0010 => PID::NIT,
70 0x0011 => PID::SDT,
71 0x0012 => PID::EIT,
72 0x0013 => PID::RST,
73 0x0014 => PID::TDT,
74 0x0015 => PID::NetworkSynchronization,
75 0x0016 => PID::RNT,
76 0x0017..=0x001B => PID::Reserved(d),
77 0x001C => PID::InbandSignalling,
78 0x001D => PID::Measurement,
79 0x001E => PID::DIT,
80 0x001F => PID::SIT,
81
82 0x1FFF => PID::NULL,
83
84 _ => PID::Other(d),
85 }
86 }
87}
88
89impl From<PID> for u16 {
90 fn from(pid: PID) -> u16 {
91 match pid {
92 PID::PAT => 0x0000,
93 PID::CAT => 0x0001,
94 PID::TSDT => 0x0002,
95 PID::NIT => 0x0010,
96 PID::SDT => 0x0011,
97 PID::EIT => 0x0012,
98 PID::RST => 0x0013,
99 PID::TDT => 0x0014,
100 PID::NetworkSynchronization => 0x0015,
101 PID::RNT => 0x0016,
102 PID::InbandSignalling => 0x001C,
103 PID::Measurement => 0x001D,
104 PID::DIT => 0x001E,
105 PID::SIT => 0x001F,
106
107 PID::NULL => 0x1FFF,
108
109 PID::Reserved(d) => d,
110
111 PID::Other(d) => d,
112 }
113 }
114}