pub trait Unpacker: Sized {
type Error;
// Required method
fn unpack_bytes<B: AsMut<[u8]>>(
&mut self,
bytes: B
) -> Result<(), Self::Error>;
// Provided methods
fn ensure_bytes(&self, _len: usize) -> Result<(), Self::Error> { ... }
fn read_bytes(&self) -> Option<usize> { ... }
}
Expand description
A type that can unpack any value that implements Packable
.
Required Associated Types§
Required Methods§
Provided Methods§
sourcefn ensure_bytes(&self, _len: usize) -> Result<(), Self::Error>
fn ensure_bytes(&self, _len: usize) -> Result<(), Self::Error>
Tries to guarantee that the Unpacker
has at least len
bytes.
This method must fail if and only if it is certain that there are not enough bytes and
it is allowed to return Ok(())
in any other case.
sourcefn read_bytes(&self) -> Option<usize>
fn read_bytes(&self) -> Option<usize>
Returns the exact number of read bytes if possible.