INNER CODE UNIT · Rust

WIRE_SIZE

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

            const WIRE_SIZE: usize = 0 $(+ <$kind as Scalar>::SIZE)*;

            fn decode(input: &[u8]) -> Result<Self, CodecError> {
                let mut r = Reader(input);
                let value = Self { $($field: <$kind as Scalar>::read(&mut r)?),* };
                $($(if value.$field != $expected {
                    return Err(CodecError::InvalidMagic);
                })?)*
                Ok(value)
            }

            fn encode(&self, output: &mut [u8]) -> Result<usize, CodecError> {
                $($(if self.$field != $expected {
                    return Err(CodecError::InvalidMagic);
                })?)*
                let mut w = Writer { output, offset: 0 };
                $(self.$field.write(&mut w)?;)*
                Ok(w.offset)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…