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.
Implementations§
Source§impl VarInt
impl VarInt
Sourcepub fn from_u64(x: u64) -> Result<Self, VarIntBoundsExceeded>
pub fn from_u64(x: u64) -> Result<Self, VarIntBoundsExceeded>
Succeeds if x < 2^62.
Sourcepub const unsafe fn from_u64_unchecked(x: u64) -> Self
pub const unsafe fn from_u64_unchecked(x: u64) -> Self
Sourcepub const fn into_inner(self) -> u64
pub const fn into_inner(self) -> u64
Extract the integer value.
Source§impl VarInt
impl VarInt
Sourcepub fn decode<B: Buf>(r: &mut B) -> Result<Self, VarIntUnexpectedEnd>
pub fn decode<B: Buf>(r: &mut B) -> Result<Self, VarIntUnexpectedEnd>
Decode a QUIC varint from an in-memory buffer.
Sourcepub async fn read<S: AsyncRead + Unpin>(
stream: &mut S,
) -> Result<Self, VarIntUnexpectedEnd>
pub async fn read<S: AsyncRead + Unpin>( stream: &mut S, ) -> Result<Self, VarIntUnexpectedEnd>
Read a QUIC varint from an async stream.
Sourcepub fn encode<B: BufMut>(&self, w: &mut B)
pub fn encode<B: BufMut>(&self, w: &mut B)
Encode this value as a QUIC varint into the given buffer.
Sourcepub async fn write<S: AsyncWrite + Unpin>(
&self,
stream: &mut S,
) -> Result<(), VarIntUnexpectedEnd>
pub async fn write<S: AsyncWrite + Unpin>( &self, stream: &mut S, ) -> Result<(), VarIntUnexpectedEnd>
Encode and write this value as a QUIC varint to an async stream.
Trait Implementations§
Source§impl Ord for VarInt
impl Ord for VarInt
Source§impl PartialOrd for VarInt
impl PartialOrd for VarInt
Source§impl TryFrom<u128> for VarInt
impl TryFrom<u128> for VarInt
Source§type Error = VarIntBoundsExceeded
type Error = VarIntBoundsExceeded
The type returned in the event of a conversion error.
Source§impl TryFrom<u64> for VarInt
impl TryFrom<u64> for VarInt
Source§type Error = VarIntBoundsExceeded
type Error = VarIntBoundsExceeded
The type returned in the event of a conversion error.
Source§impl TryFrom<usize> for VarInt
impl TryFrom<usize> for VarInt
Source§type Error = VarIntBoundsExceeded
type Error = VarIntBoundsExceeded
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 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