Module fixed_size

Module fixed_size 

Source
Expand description

Sized data encoding algorithms that power this crate.

The main idea is to make sized data encoding as fast as possible, taking as little space as possible. Each type implementing AsFixedSizeBytes trait is aware of its encoded size and of data type of the byte buffer that is used to encode it. Constant generics enable us to encode such fixed size types in [u8; N], which is very good, since arrays are stack-based data structures and don’t involve expensive heap allocations, so most types encode themselves into such generic arrays.

Generic types (such as Option) are not yet compatible with constant generics and therefore they are encoded to Vec of u8.

AsFixedSizeBytes trait encapusaltes these differences providing a simple API.

Traits§

AsFixedSizeBytes
Allows fast and space-efficient fixed size data encoding.
Buffer
Either [u8; N] or Vec of u8