#[non_exhaustive]pub enum NumEncoding {
Fixed,
Leb128,
ProtobufWasteful,
ProtobufZigzag,
}Expand description
Controls the encoding of a numerical value. For instance, controls whether the numbers are compressed through a var-int format or if the entire length of their value is encoded.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Fixed
The value’s bits are encoded as-is according to the Endianness.
Leb128
The value’s bits are encoded according to the ULEB128
(Little Endian Base 128) standard if unsigned, or LEB128
standard if signed.
As the name suggests, the bytes are encoded in little endian order,
ignoring the Endianness.
ProtobufWasteful
The value’s bits are encoded according to
Protobuf’s varint encoding,
where unsigned values are encoded in the same way as Leb128,
and signed values are encoded as a reinterpret-cast of the bits to unsigned,
possibly wasting all the var-int length to encode the leading 1s.
This encoding method is not ideal to encode negative numbers and is provided merely for
compatibility concerns.
The bytes are encoded in little endian order, ignoring the Endianness.
ProtobufZigzag
The value’s bits are encoded according to
Protobuf’s varint encoding,
where unsigned values are encoded in the same way as Leb128,
and signed values are encoded as an unsigned value with its least significant bit
carrying the sign.
The bytes are encoded in little endian order, ignoring the Endianness.
Implementations§
Source§impl NumEncoding
impl NumEncoding
Sourcepub const fn borrowable(&self) -> bool
pub const fn borrowable(&self) -> bool
Determines whether a slice encoded with this encoding can be directly borrowed.
Currently only returns true with the Fixed variant
Trait Implementations§
Source§impl Clone for NumEncoding
impl Clone for NumEncoding
Source§fn clone(&self) -> NumEncoding
fn clone(&self) -> NumEncoding
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more