aboutsummaryrefslogtreecommitdiff
path: root/evc/src/header.rs
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2022-12-06 08:16:09 +0100
committermetamuffin <metamuffin@disroot.org>2022-12-06 08:16:09 +0100
commit5002d0df81f74418665e4e99179ba56d8e78cbe1 (patch)
tree2ece906f886934dd0fc335a4aa31bc5363fa92e8 /evc/src/header.rs
parentbafb1df8b7764a0a62f1c656eb52fbe7bfd8b8ac (diff)
downloadvideo-codec-experiments-5002d0df81f74418665e4e99179ba56d8e78cbe1.tar
video-codec-experiments-5002d0df81f74418665e4e99179ba56d8e78cbe1.tar.bz2
video-codec-experiments-5002d0df81f74418665e4e99179ba56d8e78cbe1.tar.zst
more codde
Diffstat (limited to 'evc/src/header.rs')
-rw-r--r--evc/src/header.rs12
1 files changed, 7 insertions, 5 deletions
diff --git a/evc/src/header.rs b/evc/src/header.rs
index 923e8ff..5244ce5 100644
--- a/evc/src/header.rs
+++ b/evc/src/header.rs
@@ -1,20 +1,22 @@
use crate::ser::{Ser, Sink, Source};
-#[derive(Debug, Clone)]
+#[derive(Debug, Clone, PartialEq, Copy)]
pub struct Header {
pub resolution: (usize, usize),
pub frame_count: usize,
}
+pub const MAGIC: [u8; 4] = [0x5eu8, 0xb1u8, 0xc3u8, 0x08u8];
+
impl Ser for Header {
- fn write(&self, sink: &mut impl std::io::Write) -> std::io::Result<()> {
- sink.put([0x5eu8, 0xb1u8, 0xc3u8, 0x08u8])?;
+ fn write(&self, sink: &mut impl std::io::Write) -> anyhow::Result<()> {
+ sink.put(MAGIC)?;
sink.put((self.resolution, self.frame_count))?;
Ok(())
}
- fn read(source: &mut impl std::io::Read) -> std::io::Result<Self> {
- source.get::<[u8; 4]>()?;
+ fn read(source: &mut impl std::io::Read) -> anyhow::Result<Self> {
+ assert_eq!(source.get::<[u8; 4]>()?, MAGIC);
let (resolution, frame_count) = source.get()?;
Ok(Self {
resolution,