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
See variable-length integers of QUIC for more details.
Implementations§
Source§impl VarInt
impl VarInt
Sourcepub const fn from_u64(value: u64) -> Result<Self, Overflow>
pub const fn from_u64(value: u64) -> Result<Self, Overflow>
Construct a VarInt from a u64.
Succeeds if x < 2^62.
Sourcepub unsafe fn from_u64_unchecked(x: u64) -> Self
pub unsafe fn from_u64_unchecked(x: u64) -> Self
Sourcepub fn from_u128(value: u128) -> Result<Self, Overflow>
pub fn from_u128(value: u128) -> Result<Self, Overflow>
Construct a VarInt from a u128.
Succeeds if x < 2^62.
Sourcepub const fn into_inner(self) -> u64
pub const fn into_inner(self) -> u64
Extract the integer value
Sourcepub fn encoding_size(self) -> usize
pub fn encoding_size(self) -> usize
Compute the number of bytes needed to encode this value
Trait Implementations§
impl Copy for VarInt
impl Eq for VarInt
Source§impl Ord for VarInt
impl Ord for VarInt
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialOrd for VarInt
impl PartialOrd for VarInt
Source§impl PartialOrd<u64> for VarInt
impl PartialOrd<u64> 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 UnsafeUnpin for VarInt
impl UnwindSafe for VarInt
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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