use crate::utils::BigEndianReader;
#[derive(Debug, Clone, Copy, Default)]
pub struct WindowDefinition {
pub id: u8,
pub x: u16,
pub y: u16,
pub width: u16,
pub height: u16,
}
#[derive(Debug, Clone)]
pub struct WindowDefinitionSegment {
pub windows: Vec<WindowDefinition>,
}
impl WindowDefinitionSegment {
pub fn parse(reader: &mut BigEndianReader, _length: usize) -> Option<Self> {
let count = reader.read_u8()? as usize;
let mut windows = Vec::with_capacity(count);
for _ in 0..count {
let id = reader.read_u8()?;
let x = reader.read_u16()?;
let y = reader.read_u16()?;
let width = reader.read_u16()?;
let height = reader.read_u16()?;
windows.push(WindowDefinition {
id,
x,
y,
width,
height,
});
}
Some(Self { windows })
}
}