From 8e4ec0943973b96addbe01f4c02f91cf04d081a7 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Mon, 5 Dec 2022 21:22:00 +0100 Subject: more code --- evc/src/pixel.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 evc/src/pixel.rs (limited to 'evc/src/pixel.rs') diff --git a/evc/src/pixel.rs b/evc/src/pixel.rs new file mode 100644 index 0000000..adeaf84 --- /dev/null +++ b/evc/src/pixel.rs @@ -0,0 +1,19 @@ +use crate::ser::{Ser, Sink, Source}; + +#[derive(Copy, Clone, Debug, Default)] +pub struct Pixel { + pub r: u8, + pub g: u8, + pub b: u8, +} + +impl Ser for Pixel { + fn write(&self, sink: &mut impl std::io::Write) -> std::io::Result<()> { + sink.put((self.r, self.g, self.b)) + } + + fn read(source: &mut impl std::io::Read) -> std::io::Result { + let (r, g, b) = source.get()?; + Ok(Self { r, g, b }) + } +} -- cgit v1.2.3-70-g09d2