libbitsub_core/pgs/
window.rs1use crate::utils::BigEndianReader;
4
5#[derive(Debug, Clone, Copy, Default)]
7pub struct WindowDefinition {
8 pub id: u8,
10 pub x: u16,
12 pub y: u16,
14 pub width: u16,
16 pub height: u16,
18}
19
20#[derive(Debug, Clone)]
22pub struct WindowDefinitionSegment {
23 pub windows: Vec<WindowDefinition>,
25}
26
27impl WindowDefinitionSegment {
28 pub fn parse(reader: &mut BigEndianReader, _length: usize) -> Option<Self> {
30 let count = reader.read_u8()? as usize;
31 let mut windows = Vec::with_capacity(count);
32
33 for _ in 0..count {
34 let id = reader.read_u8()?;
35 let x = reader.read_u16()?;
36 let y = reader.read_u16()?;
37 let width = reader.read_u16()?;
38 let height = reader.read_u16()?;
39
40 windows.push(WindowDefinition {
41 id,
42 x,
43 y,
44 width,
45 height,
46 });
47 }
48
49 Some(Self { windows })
50 }
51}