pub trait TakeBytes {
// Required method
fn take_bytes(&mut self, buf: &mut [u8]) -> Result<(), TakeBytesError>;
}
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(&mut self, buf: &mut [u8]) -> Result<(), TakeBytesError>
fn take_bytes(&mut self, buf: &mut [u8]) -> Result<(), TakeBytesError>
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
return a TakeBytesError::Eof
error.
Implementations on Foreign Types§
Source§impl TakeBytes for &[u8]
TakeBytes
is implemented for &[u8]
by taking the first part of the
slice.
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.