INNER CODE UNIT · Rust

write

Barre/ZeroFS · zerofs/nbd-proto/src/lib.rs:249

    fn write(&self, w: &mut Writer<'_>) -> Result<(), CodecError>;
}

macro_rules! scalar {
    ($ty:ty) => {
        impl Scalar for $ty {
            const SIZE: usize = std::mem::size_of::<Self>();
            fn read(r: &mut Reader<'_>) -> Result<Self, CodecError> {
                Ok(Self::from_be_bytes(r.take()?))
            }
            fn write(&self, w: &mut Writer<'_>) -> Result<(), CodecError> {
                w.put(&self.to_be_bytes())
            }
        }
    };
}
scalar!(u16);
scalar!(u32);

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…