Struct bincode::enc::EncoderImpl
source · pub struct EncoderImpl<W: Writer, C: Config> { /* private fields */ }
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§
source§impl<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> Freeze for EncoderImpl<W, C>
impl<W, C> RefUnwindSafe for EncoderImpl<W, C>where
W: RefUnwindSafe,
C: RefUnwindSafe,
impl<W, C> Send for EncoderImpl<W, C>
impl<W, C> Sync for EncoderImpl<W, C>
impl<W, C> Unpin for EncoderImpl<W, C>
impl<W, C> UnwindSafe for EncoderImpl<W, C>where
W: UnwindSafe,
C: UnwindSafe,
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