pub struct VarInt(u64);Expand description
A QUIC variable-length integer (RFC 9000 Section 16).
Uses 2-bit prefix encoding:
- 00: 1 byte, values 0-63
- 01: 2 bytes, values 0-16383
- 10: 4 bytes, values 0-1073741823
- 11: 8 bytes, values 0-4611686018427387903
Tuple Fields§
§0: u64Implementations§
Source§impl VarInt
impl VarInt
Sourcepub fn from_u64(v: u64) -> Result<Self, VarIntError>
pub fn from_u64(v: u64) -> Result<Self, VarIntError>
Create a VarInt from a u64, returning an error if it exceeds the maximum.
Sourcepub fn into_inner(self) -> u64
pub fn into_inner(self) -> u64
Get the inner u64 value.
Sourcepub fn encoded_len(&self) -> usize
pub fn encoded_len(&self) -> usize
Return the number of bytes needed to encode this varint.
Sourcepub fn decode(buf: &mut impl Buf) -> Result<Self, VarIntError>
pub fn decode(buf: &mut impl Buf) -> Result<Self, VarIntError>
Decode a varint from the given buffer.
Trait Implementations§
Source§impl Ord for VarInt
impl Ord for VarInt
Source§impl PartialOrd for VarInt
impl PartialOrd for VarInt
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 UnsafeUnpin 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