aboutsummaryrefslogtreecommitdiff
path: root/evc/src/header.rs
blob: e5f008d971aae1462c406953e2c009e6aa4d4ff1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
use crate::ser::{Ser, Sink, Source};

#[derive(Debug, Clone)]
pub struct Header {
    pub resolution: (usize, usize),
    pub frame_count: usize,
}

impl Ser for Header {
    fn write(&self, sink: &mut impl std::io::Write) -> std::io::Result<()> {
        sink.put([0x5eu8, 0xb1u8, 0xc3u8, 0x08u8])?;
        sink.put((self.resolution, self.frame_count))?;
        Ok(())
    }

    fn read(source: &mut impl std::io::Read) -> std::io::Result<Self> {
        source.get::<[u8; 4]>()?;
        Ok(Self {
            resolution: source.get()?,
            frame_count: source.get()?,
        })
    }
}