1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 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<Self> { let (r, g, b) = source.get()?; Ok(Self { r, g, b }) } }