pgs_parse/
pgs_segment_type.rs1use std::fmt::Display;
2
3#[derive(Debug, PartialEq, Clone, Copy)]
5pub enum PgsSegmentType {
6 PDS = 0x14,
8 ODS = 0x15,
10 PCS = 0x16,
12 WDS = 0x17,
14 END = 0x80,
16 ERR = 0x00
18}
19
20impl Display for PgsSegmentType {
21 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
22 match self {
23 PgsSegmentType::PDS => write!(f, "Palette Definition Segment"),
24 PgsSegmentType::ODS => write!(f, "Object Definition Segment"),
25 PgsSegmentType::PCS => write!(f, "Presentation Composition Segment"),
26 PgsSegmentType::WDS => write!(f, "Window Definition Segment"),
27 PgsSegmentType::END => write!(f, "End of Display Set Segment"),
28 PgsSegmentType::ERR => write!(f, "Error in Segment"),
29 }
30 }
31}
32
33impl From<u8> for PgsSegmentType {
34 fn from(value: u8) -> Self {
42 match value {
43 0x14 => PgsSegmentType::PDS,
44 0x15 => PgsSegmentType::ODS,
45 0x16 => PgsSegmentType::PCS,
46 0x17 => PgsSegmentType::WDS,
47 0x80 => PgsSegmentType::END,
48 _ => PgsSegmentType::ERR
49 }
50 }
51}