Struct mbpr::Encoder [] [src]

pub struct Encoder { /* fields omitted */ }

Data type used to encode data efficient

This structure has been built from the ground up to avoid branching while encoding.

Methods

impl Encoder
[src]

Pass an already constructed packet in. This will allocate a buffer the size of that packet

To avoid allocations this method allows for a pre-allocated vector be passed in. The Vector's size will be checked, and it MAY be resized if too small. If it's capacity is sufficient no allocations will be done.

Consumes this type (destroying it) but returns the underlying vector as to not dellocator it's memory (be used again).

Used internally for testing, maybe useful to the developer reading this this allows for the input value to set the len/capacity of the internal memory

Unsafe

This method is unsafe. If you encode a packet LARGER then the method your program may seg fault as there is no bounds checking when encoding.

While the underlying vec is fully populated this returns only the data written to it. So if with::capacity is used to create a buffer larger then a packet this can be used to read only the packet data.

Get length of data written to the encoder

Encode a u8 used internally.

Encode a u16 used internally.

Encode a u32 used internally.

Encode a u64 used internally.

Encode a [u8] used internally.