pub trait VarIntTarget:
Debug
+ Eq
+ PartialEq
+ PartialOrd
+ Sized
+ Copy {
type Signed: SignedVarIntTarget;
const MAX_VARINT_BYTES: u8;
const MAX_LAST_VARINT_BYTE: u8;
// Required methods
fn vector_to_num(res: [u8; 16]) -> Self;
fn scalar_to_num(x: u64) -> Self;
fn cast_u32(num: u32) -> Self;
fn cast_u64(num: u64) -> Self;
fn num_to_scalar_stage1(self) -> u64;
fn num_to_vector_stage1(self) -> [u8; 16];
fn zigzag(from: Self::Signed) -> Self;
fn unzigzag(self) -> Self::Signed;
}Expand description
Represents an unsigned scalar value that can be encoded to and decoded from a varint.
Required Associated Constants§
Sourceconst MAX_VARINT_BYTES: u8
const MAX_VARINT_BYTES: u8
The maximum length of varint that is necessary to represent this number
Sourceconst MAX_LAST_VARINT_BYTE: u8
const MAX_LAST_VARINT_BYTE: u8
The maximum value of the last byte if the varint is MAX_VARINT_BYTES long such that the varint would not overflow the target
Required Associated Types§
Sourcetype Signed: SignedVarIntTarget
type Signed: SignedVarIntTarget
The signed version of this type
Required Methods§
Sourcefn vector_to_num(res: [u8; 16]) -> Self
fn vector_to_num(res: [u8; 16]) -> Self
Converts a 128-bit vector to this number
Note: Despite operating on 128-bit SIMD vectors, these functions accept and return static arrays due to a lack of optimization capability by the compiler when passing or returning intrinsic vectors.
fn scalar_to_num(x: u64) -> Self
Sourcefn num_to_scalar_stage1(self) -> u64
fn num_to_scalar_stage1(self) -> u64
Splits this number into 7-bit segments for encoding
Sourcefn num_to_vector_stage1(self) -> [u8; 16]
fn num_to_vector_stage1(self) -> [u8; 16]
Splits this number into 7-bit segments for encoding
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.