Struct s2n_quic_core::packet::number::PacketNumber
source · pub struct PacketNumber(/* private fields */);
Expand description
Contains a fully-decoded packet number in a given space
Internally the packet number is represented as a NonZeroU64
to ensure optimal memory layout.
The lower 62 bits are used to store the actual packet number value.
The upper 2 bits are used to store the packet number space. Because
there are only 3 spaces, the zero state is never used, which is why
NonZeroU64
can be used instead of u64
.
Implementations§
source§impl PacketNumber
impl PacketNumber
sourcepub fn space(self) -> PacketNumberSpace
pub fn space(self) -> PacketNumberSpace
Returns the PacketNumberSpace
for the given PacketNumber
sourcepub const fn as_varint(packet_number: Self) -> VarInt
pub const fn as_varint(packet_number: Self) -> VarInt
Converts the PacketNumber
into a VarInt
value.
Note: Even though some scenarios require this function, it should be
avoided in most cases, as it removes the corresponding PacketNumberSpace
and allows math operations to be performed, which can easily result in
protocol errors.
sourcepub fn truncate(
self,
largest_acknowledged_packet_number: Self,
) -> Option<TruncatedPacketNumber>
pub fn truncate( self, largest_acknowledged_packet_number: Self, ) -> Option<TruncatedPacketNumber>
Truncates the PacketNumber
into a TruncatedPacketNumber
based on
the largest acknowledged packet number
sourcepub fn next(self) -> Option<Self>
pub fn next(self) -> Option<Self>
Compute the next packet number in the space. If the packet number has
exceeded the maximum value allowed None
will be returned.
sourcepub fn prev(self) -> Option<Self>
pub fn prev(self) -> Option<Self>
Compute the prev packet number in the space. If the packet number has
underflowed None
will be returned.
sourcepub const fn as_crypto_nonce(self) -> u64
pub const fn as_crypto_nonce(self) -> u64
Create a nonce for crypto from the packet number value
Note: This should not be used by anything other than crypto-related functionality.
sourcepub fn checked_distance(self, rhs: PacketNumber) -> Option<u64>
pub fn checked_distance(self, rhs: PacketNumber) -> Option<u64>
Computes the distance between this packet number and the given packet number, returning None if overflow occurred.
Trait Implementations§
source§impl Clone for PacketNumber
impl Clone for PacketNumber
source§fn clone(&self) -> PacketNumber
fn clone(&self) -> PacketNumber
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for PacketNumber
impl Debug for PacketNumber
source§impl Default for PacketNumber
impl Default for PacketNumber
source§impl Display for PacketNumber
impl Display for PacketNumber
source§impl Hash for PacketNumber
impl Hash for PacketNumber
source§impl IntervalBound for PacketNumber
impl IntervalBound for PacketNumber
source§impl IntoEvent<u64> for PacketNumber
impl IntoEvent<u64> for PacketNumber
fn into_event(self) -> u64
source§impl Ord for PacketNumber
impl Ord for PacketNumber
source§impl PartialEq for PacketNumber
impl PartialEq for PacketNumber
source§impl PartialOrd for PacketNumber
impl PartialOrd for PacketNumber
source§impl Set for PacketNumber
impl Set for PacketNumber
source§fn contains(&self, packet_number: PacketNumber) -> bool
fn contains(&self, packet_number: PacketNumber) -> bool
Set
contains a given packet numbersource§fn smallest(&self) -> PacketNumber
fn smallest(&self) -> PacketNumber
source§fn largest(&self) -> PacketNumber
fn largest(&self) -> PacketNumber
source§fn as_range(&self) -> PacketNumberRange ⓘ
fn as_range(&self) -> PacketNumberRange ⓘ
impl Copy for PacketNumber
impl Eq for PacketNumber
Auto Trait Implementations§
impl Freeze for PacketNumber
impl RefUnwindSafe for PacketNumber
impl Send for PacketNumber
impl Sync for PacketNumber
impl Unpin for PacketNumber
impl UnwindSafe for PacketNumber
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)