Trait nuts_bytes::PutBytes

source ·
pub trait PutBytes {
    // Required method
    fn put_bytes(&mut self, buf: &[u8]) -> Result<()>;
}
Expand description

Trait that describes a writer of binary data.

The Writer utility accepts all types that implements this trait.

Required Methods§

source

fn put_bytes(&mut self, buf: &[u8]) -> Result<()>

Appends all the given data in buf at the end of this writer.

Errors

If not all data could be written, an Error::NoSpace error should be returned.

Implementations on Foreign Types§

source§

impl PutBytes for Vec<u8>

PutBytes is implemented for Vec<u8> by appending bytes to the Vec.

source§

fn put_bytes(&mut self, buf: &[u8]) -> Result<()>

source§

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 an Error::NoSpace error.

source§

fn put_bytes(&mut self, buf: &[u8]) -> Result<()>

Implementors§