Module compact_size

Module compact_size 

Source
Expand description

Variable length integer encoding A.K.A CompactSize.

An integer can be encoded depending on the represented value to save space. Variable length integers always precede an array/vector of a type of data that may vary in length.

Constants§

MAX_ENCODABLE_VALUE
The maximum size of a serialized object in bytes or number of elements (for eg vectors) when the size is encoded as CompactSize.
MAX_ENCODING_SIZE
The maximum length of an encoding.

Functions§

decode_unchecked
Gets the compact size encoded value from slice and moves slice past the encoding.
encode
Encodes CompactSize without allocating.
encoded_size
Returns the number of bytes used to encode this CompactSize value.
encoded_size_const
Returns the number of bytes used to encode this CompactSize value (in const context).