pub struct VarInt(/* private fields */);Expand description
An integer less than 2^62
Values of this type are suitable for encoding as QUIC variable-length integer. It would be neat if we could express to Rust that the top two bits are available for use as enum discriminants
Implementations§
Source§impl VarInt
impl VarInt
Sourcepub const fn from_u32(x: u32) -> Self
pub const fn from_u32(x: u32) -> Self
Construct a VarInt infallibly using the largest available type.
Larger values need to use try_from instead.
pub const fn from_u64(x: u64) -> Option<Self>
pub const fn from_u128(x: u128) -> Option<Self>
Sourcepub const fn into_inner(self) -> u64
pub const fn into_inner(self) -> u64
Extract the integer value
Trait Implementations§
Source§impl Ord for VarInt
impl Ord for VarInt
Source§impl PartialOrd for VarInt
impl PartialOrd for VarInt
Source§impl TryFrom<VarInt> for u16
impl TryFrom<VarInt> for u16
Source§type Error = BoundsExceeded
type Error = BoundsExceeded
The type returned in the event of a conversion error.
Source§impl TryFrom<VarInt> for u32
impl TryFrom<VarInt> for u32
Source§type Error = BoundsExceeded
type Error = BoundsExceeded
The type returned in the event of a conversion error.
Source§impl TryFrom<VarInt> for u8
impl TryFrom<VarInt> for u8
Source§type Error = BoundsExceeded
type Error = BoundsExceeded
The type returned in the event of a conversion error.
Source§impl TryFrom<u128> for VarInt
impl TryFrom<u128> for VarInt
Source§type Error = BoundsExceeded
type Error = BoundsExceeded
The type returned in the event of a conversion error.
Source§impl TryFrom<u64> for VarInt
impl TryFrom<u64> for VarInt
Source§type Error = BoundsExceeded
type Error = BoundsExceeded
The type returned in the event of a conversion error.
Source§impl TryFrom<usize> for VarInt
impl TryFrom<usize> for VarInt
Source§type Error = BoundsExceeded
type Error = BoundsExceeded
The type returned in the event of a conversion error.
impl Copy for VarInt
impl Eq for VarInt
impl StructuralPartialEq for VarInt
Auto Trait Implementations§
impl Freeze for VarInt
impl RefUnwindSafe for VarInt
impl Send for VarInt
impl Sync for VarInt
impl Unpin for VarInt
impl UnwindSafe for VarInt
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more