pub trait PutBytes {
// Required method
fn put_bytes(&mut self, buf: &[u8]) -> Result<(), PutBytesError>;
}
Expand description
Trait that describes a writer of binary data.
The Writer
utility accepts all types that implements
this trait.
Required Methods§
Sourcefn put_bytes(&mut self, buf: &[u8]) -> Result<(), PutBytesError>
fn put_bytes(&mut self, buf: &[u8]) -> Result<(), PutBytesError>
Appends all the given data in buf
at the end of this writer.
§Errors
If not all data could be written, the implementator should
return a PutBytesError::NoSpace
error.
Implementations on Foreign Types§
Source§impl PutBytes for &mut Vec<u8>
PutBytes
is implemented for [&mut Vec<u8>
] by appending bytes to the Vec
.
impl PutBytes for &mut Vec<u8>
PutBytes
is implemented for [&mut Vec<u8>
] by appending bytes to the Vec
.
Source§impl PutBytes for &mut [u8]
PutBytes
is implemented for &mut [u8]
by copying into the slice,
overwriting its data.
impl PutBytes for &mut [u8]
PutBytes
is implemented for &mut [u8]
by copying into the slice,
overwriting its data.
Note that putting bytes updates the slice to point to the yet unwritten part. The slice will be empty when it has been completely overwritten.
If the number of bytes to be written exceeds the size of the slice, the
operation will return a PutBytesError::NoSpace
error.