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

Create a new Encoder

Return the underlying writer

Trait Implementations

The concrete Writer type

The concrete Config type

Returns a mutable reference to the writer

Returns a reference to the config

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.