Struct s2n_quic_core::counter::Counter
source · [−]pub struct Counter<T, Behavior = ()>(_, _);
Expand description
A checked-overflow counter
Rather than silently wrapping, we want to ensure counting errors stay somewhat isolated so the counter will saturate rather than wrap. The counter operates in 3 modes:
- If
debug_assertions
are enabled, the counter will panic on overflow - If the
checked-counters
feature flag is defined, the counter will panic on overflow, even in release builds. - Otherwise, the counter will saturate
The counter can also be configured to always saturate by passing the Saturating
behavior:
use s2n_quic_core::counter::{Counter, Saturating};
let counter: Counter<u32, Saturating> = Default::default();
Implementations
sourceimpl<T, Behavior> Counter<T, Behavior>
impl<T, Behavior> Counter<T, Behavior>
Trait Implementations
sourceimpl<T, R> AddAssign<R> for Counter<T, ()> where
T: SaturatingAddAssign<R> + CheckedAddAssign<R> + AddAssign + UpcastFrom<R>,
impl<T, R> AddAssign<R> for Counter<T, ()> where
T: SaturatingAddAssign<R> + CheckedAddAssign<R> + AddAssign + UpcastFrom<R>,
sourcefn add_assign(&mut self, rhs: R)
fn add_assign(&mut self, rhs: R)
Performs the +=
operation. Read more
sourceimpl<T, R> AddAssign<R> for Counter<T, Saturating> where
T: SaturatingAddAssign<R>,
impl<T, R> AddAssign<R> for Counter<T, Saturating> where
T: SaturatingAddAssign<R>,
sourcefn add_assign(&mut self, rhs: R)
fn add_assign(&mut self, rhs: R)
Performs the +=
operation. Read more
sourceimpl<T, B> Ord for Counter<T, B> where
T: Ord,
impl<T, B> Ord for Counter<T, B> where
T: Ord,
sourceimpl<T, B, R> PartialEq<R> for Counter<T, B> where
Self: PartialOrd<R>,
impl<T, B, R> PartialEq<R> for Counter<T, B> where
Self: PartialOrd<R>,
sourceimpl<T, B> PartialOrd<Counter<T, B>> for Counter<T, B> where
T: PartialOrd<T>,
impl<T, B> PartialOrd<Counter<T, B>> for Counter<T, B> where
T: PartialOrd<T>,
sourcefn partial_cmp(&self, other: &Self) -> Option<Ordering>
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
sourceimpl<T, B> PartialOrd<T> for Counter<T, B> where
T: PartialOrd<T>,
impl<T, B> PartialOrd<T> for Counter<T, B> where
T: PartialOrd<T>,
sourcefn partial_cmp(&self, other: &T) -> Option<Ordering>
fn partial_cmp(&self, other: &T) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
sourceimpl<T, R> SubAssign<R> for Counter<T, ()> where
T: SaturatingSubAssign<R> + CheckedSubAssign<R> + SubAssign + UpcastFrom<R>,
impl<T, R> SubAssign<R> for Counter<T, ()> where
T: SaturatingSubAssign<R> + CheckedSubAssign<R> + SubAssign + UpcastFrom<R>,
sourcefn sub_assign(&mut self, rhs: R)
fn sub_assign(&mut self, rhs: R)
Performs the -=
operation. Read more
sourceimpl<T, R> SubAssign<R> for Counter<T, Saturating> where
T: SaturatingSubAssign<R>,
impl<T, R> SubAssign<R> for Counter<T, Saturating> where
T: SaturatingSubAssign<R>,
sourcefn sub_assign(&mut self, rhs: R)
fn sub_assign(&mut self, rhs: R)
Performs the -=
operation. Read more
sourceimpl<T, B> UpcastFrom<&'_ Counter<T, B>> for T where
T: for<'a> UpcastFrom<&'a T>,
impl<T, B> UpcastFrom<&'_ Counter<T, B>> for T where
T: for<'a> UpcastFrom<&'a T>,
fn upcast_from(value: &Counter<T, B>) -> Self
sourceimpl<T, B> UpcastFrom<Counter<T, B>> for T
impl<T, B> UpcastFrom<Counter<T, B>> for T
fn upcast_from(value: Counter<T, B>) -> Self
impl<T: Copy, Behavior: Copy> Copy for Counter<T, Behavior>
impl<T, B> Eq for Counter<T, B> where
Self: Ord,
Auto Trait Implementations
impl<T, Behavior> RefUnwindSafe for Counter<T, Behavior> where
Behavior: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, Behavior> Send for Counter<T, Behavior> where
Behavior: Send,
T: Send,
impl<T, Behavior> Sync for Counter<T, Behavior> where
Behavior: Sync,
T: Sync,
impl<T, Behavior> Unpin for Counter<T, Behavior> where
Behavior: Unpin,
T: Unpin,
impl<T, Behavior> UnwindSafe for Counter<T, Behavior> where
Behavior: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more