diff options
author | metamuffin <metamuffin@disroot.org> | 2022-12-06 19:30:03 +0100 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2022-12-06 19:30:03 +0100 |
commit | 70514416c2ade2abe628efbd0a629a66febdeb13 (patch) | |
tree | 03b54f677046afe5a2e1b04768c1cb9104771462 /evc/src/ser.rs | |
parent | c4e995d29209e0e0a1aafd9652971b8980fafb15 (diff) | |
download | video-codec-experiments-70514416c2ade2abe628efbd0a629a66febdeb13.tar video-codec-experiments-70514416c2ade2abe628efbd0a629a66febdeb13.tar.bz2 video-codec-experiments-70514416c2ade2abe628efbd0a629a66febdeb13.tar.zst |
minor stuff, store translation as i8
Diffstat (limited to 'evc/src/ser.rs')
-rw-r--r-- | evc/src/ser.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/evc/src/ser.rs b/evc/src/ser.rs index 61ca684..98d6706 100644 --- a/evc/src/ser.rs +++ b/evc/src/ser.rs @@ -93,6 +93,18 @@ impl Ser for u8 { Ok(buf[0]) } } +impl Ser for i8 { + fn write(&self, sink: &mut impl Write) -> anyhow::Result<()> { + Ok(sink + .write_all(&unsafe { std::mem::transmute_copy::<_, [u8; 1]>(self) }) + .context("write i8")?) + } + fn read(source: &mut impl Read) -> anyhow::Result<Self> { + let mut buf = [0u8; 1]; + source.read_exact(&mut buf)?; + Ok(unsafe { std::mem::transmute_copy(&buf) }) + } +} impl Ser for u16 { fn write(&self, sink: &mut impl Write) -> anyhow::Result<()> { Ok(sink |