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/vec2.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/vec2.rs')
-rw-r--r-- | evc/src/vec2.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/evc/src/vec2.rs b/evc/src/vec2.rs index b1dd1b4..8b01fdb 100644 --- a/evc/src/vec2.rs +++ b/evc/src/vec2.rs @@ -26,6 +26,21 @@ impl Ser for Vec2 { } } +pub struct Small<T>(pub T); +impl Ser for Small<Vec2> { + fn write(&self, sink: &mut impl std::io::Write) -> anyhow::Result<()> { + sink.put((self.0.x as i8, self.0.y as i8)) + } + + fn read(source: &mut impl std::io::Read) -> anyhow::Result<Self> { + let (x, y): (i8, i8) = source.get()?; + Ok(Small(Vec2 { + x: x as isize, + y: y as isize, + })) + } +} + impl std::ops::Add for Vec2 { type Output = Vec2; #[inline] |