INNER CODE UNIT · Rust
put
Barre/ZeroFS · zerofs/nbd-proto/src/lib.rs:232
fn put(&mut self, bytes: &[u8]) -> Result<(), CodecError> {
let end = self
.offset
.checked_add(bytes.len())
.ok_or(CodecError::BufferTooSmall)?;
self.output
.get_mut(self.offset..end)
.ok_or(CodecError::BufferTooSmall)?
.copy_from_slice(bytes);
self.offset = end;
Ok(())
}
}
trait Scalar: Sized {
const SIZE: usize;
fn read(r: &mut Reader<'_>) -> Result<Self, CodecError>;
fn write(&self, w: &mut Writer<'_>) -> Result<(), CodecError>;