Struct bincode::enc::EncoderImpl
source · [−]Expand description
An Encoder that writes bytes into a given writer W
.
This struct should rarely be used.
In most cases, prefer any of the encode
functions.
The ByteOrder that is chosen will impact the endianness that is used to write integers to the writer.
let slice: &mut [u8] = &mut [0, 0, 0, 0];
let config = bincode::config::legacy().with_big_endian();
let mut encoder = EncoderImpl::new(SliceWriter::new(slice), config);
// this u32 can be any Encodable
5u32.encode(&mut encoder).unwrap();
assert_eq!(encoder.into_writer().bytes_written(), 4);
assert_eq!(slice, [0, 0, 0, 5]);
Implementations
sourceimpl<W: Writer, C: Config> EncoderImpl<W, C>
impl<W: Writer, C: Config> EncoderImpl<W, C>
sourcepub fn new(writer: W, config: C) -> EncoderImpl<W, C>
pub fn new(writer: W, config: C) -> EncoderImpl<W, C>
Create a new Encoder
sourcepub fn into_writer(self) -> W
pub fn into_writer(self) -> W
Return the underlying writer
Trait Implementations
Auto Trait Implementations
impl<W, C> RefUnwindSafe for EncoderImpl<W, C>where
C: RefUnwindSafe,
W: RefUnwindSafe,
impl<W, C> Send for EncoderImpl<W, C>where
C: Send,
W: Send,
impl<W, C> Sync for EncoderImpl<W, C>where
C: Sync,
W: Sync,
impl<W, C> Unpin for EncoderImpl<W, C>where
C: Unpin,
W: Unpin,
impl<W, C> UnwindSafe for EncoderImpl<W, C>where
C: UnwindSafe,
W: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more