pub trait VarInt:
TryFrom<u64>
+ Copy
+ Sealed {
const LOWER_BOUND: usize;
const UPPER_BOUND: usize;
// Provided methods
fn varint_len(self) -> usize { ... }
fn read<R>(r: &mut R) -> Result<Self, Error>
where R: Read { ... }
fn write<W>(varint: &Self, w: &mut W) -> Result<(), Error>
where W: Write { ... }
}
Expand description
A trait for a number readable/writable as a VarInt.
This is sealed to prevent unintended implementations. It MUST only be implemented for primitive
types (or sufficiently approximate types like NonZero<_>
).
Required Associated Constants§
Sourceconst LOWER_BOUND: usize
const LOWER_BOUND: usize
The lower bound on the amount of bytes this will take up when encoded.
Sourceconst UPPER_BOUND: usize
const UPPER_BOUND: usize
The upper bound on the amount of bytes this will take up when encoded.
Provided Methods§
Sourcefn varint_len(self) -> usize
fn varint_len(self) -> usize
The amount of bytes this number will take when serialized as a VarInt.
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.