Struct bincode::enc::write::SliceWriter
source · 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§
source§impl<'storage> SliceWriter<'storage>
impl<'storage> SliceWriter<'storage>
sourcepub fn new(bytes: &'storage mut [u8]) -> SliceWriter<'storage>
pub fn new(bytes: &'storage mut [u8]) -> SliceWriter<'storage>
Create a new instance of SliceWriter
with the given byte array.
sourcepub fn bytes_written(&self) -> usize
pub fn bytes_written(&self) -> usize
Return the amount of bytes written so far.
Trait Implementations§
Auto Trait Implementations§
impl<'storage> Freeze for SliceWriter<'storage>
impl<'storage> RefUnwindSafe for SliceWriter<'storage>
impl<'storage> Send for SliceWriter<'storage>
impl<'storage> Sync for SliceWriter<'storage>
impl<'storage> Unpin for SliceWriter<'storage>
impl<'storage> !UnwindSafe for SliceWriter<'storage>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more