pub struct SliceWriter<'storage> { /* private fields */ }
Expand description

A helper struct that implements Writer for a &[u8] slice.

use bincode::enc::write::{Writer, SliceWriter};

let destination = &mut [0u8; 100];
let mut writer = SliceWriter::new(destination);
writer.write(&[1, 2, 3, 4, 5]).unwrap();

assert_eq!(writer.bytes_written(), 5);
assert_eq!(destination[0..6], [1, 2, 3, 4, 5, 0]);

Implementations

Create a new instance of SliceWriter with the given byte array.

Return the amount of bytes written so far.

Trait Implementations

Write bytes to the underlying writer. Exactly bytes.len() bytes must be written, or else an error should be returned.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.