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 fn from_u64(x: u64) -> Result<VarInt, Overflow>
pub fn from_u64(x: u64) -> Result<VarInt, Overflow>
Construct a VarInt
from a u64
.
Succeeds if x
< 2^62.
Sourcepub unsafe fn from_u64_unchecked(x: u64) -> VarInt
pub unsafe fn from_u64_unchecked(x: u64) -> VarInt
Sourcepub fn from_u128(x: u128) -> Result<VarInt, Overflow>
pub fn from_u128(x: u128) -> Result<VarInt, Overflow>
Construct a VarInt
from a u128
.
Succeeds if x
< 2^62.
Sourcepub fn into_inner(self) -> u64
pub 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§
Source§impl From<ErrorFrameType> for VarInt
impl From<ErrorFrameType> for VarInt
Source§fn from(val: ErrorFrameType) -> VarInt
fn from(val: ErrorFrameType) -> VarInt
Converts to this type from the input type.
Source§impl From<ParameterId> for VarInt
impl From<ParameterId> for VarInt
Source§fn from(id: ParameterId) -> VarInt
fn from(id: ParameterId) -> VarInt
Converts to this type from the input type.
Source§impl Ord for VarInt
impl Ord for VarInt
Source§impl PartialOrd<u64> for VarInt
impl PartialOrd<u64> for VarInt
Source§impl PartialOrd for VarInt
impl PartialOrd for VarInt
Source§impl TryFrom<ParameterValue> for VarInt
impl TryFrom<ParameterValue> for VarInt
Source§type Error = TryIntoError<ParameterValue>
type Error = TryIntoError<ParameterValue>
The type returned in the event of a conversion error.
Source§fn try_from(
value: ParameterValue,
) -> Result<VarInt, TryIntoError<ParameterValue>>
fn try_from( value: ParameterValue, ) -> Result<VarInt, TryIntoError<ParameterValue>>
Performs the conversion.
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