Trait nuts_bytes::TakeBytes
source · pub trait TakeBytes {
// Required method
fn take_bytes<E: TakeBytesError>(&mut self, buf: &mut [u8]) -> Result<(), E>;
}
Expand description
Trait that describes a reader of binary data.
The Reader
utility accepts all types that implements
this trait.
Required Methods§
sourcefn take_bytes<E: TakeBytesError>(&mut self, buf: &mut [u8]) -> Result<(), E>
fn take_bytes<E: TakeBytesError>(&mut self, buf: &mut [u8]) -> Result<(), E>
Reads some bytes from the source and puts them into the given buffer
buf
.
Errors
If not enough data are available to fill buf
the implementator should
create an EOF error with TakeBytesError::eof()
.
Object Safety§
This trait is not object safe.
Implementations on Foreign Types§
source§impl TakeBytes for &[u8]
impl TakeBytes for &[u8]
TakeBytes
is implemented for &[u8]
by taking the first part of the
slice.
Note that taking bytes updates the slice to point to the yet unread part. The slice will be empty when EOF is reached.