Skip to main content

CounterWidth

Enum CounterWidth 

Source
pub enum CounterWidth {
    Unknown,
    Bits32,
    Bits64,
}
Expand description

The bit width of a cumulative OS counter (§8.2).

The width is what separates a wraparound from a reset. A 32-bit interface counter read on a 64-bit host jumps back to a small value roughly every 34 seconds on a saturated gigabit link; reporting each of those as a reset would blank the interface row almost continuously. When the width is genuinely unknown there is no evidence to tell wrap from reset apart, so the conservative answer applies: report a reset and re-baseline.

Variants§

§

Unknown

The width is not known, so every backwards move is treated as a reset.

The default, because guessing a width and guessing wrong fabricates traffic that never happened.

§

Bits32

A 32-bit counter, such as a legacy ifTable-style interface counter or a 32-bit device register widened to u64 by the caller.

§

Bits64

A 64-bit counter, such as Linux /proc/net/dev on a 64-bit kernel.

Included for completeness: at 100 Gbit/s a 64-bit byte counter takes over forty years to wrap, so in practice this behaves like CounterWidth::Unknown apart from rejecting absurd backwards jumps.

Implementations§

Source§

impl CounterWidth

Source

pub const fn bits(self) -> Option<u32>

The number of significant bits, or None when the width is unknown.

Source

pub const fn max_value(self) -> Option<u64>

The largest value the counter can hold, or None when unknown.

Trait Implementations§

Source§

impl Clone for CounterWidth

Source§

fn clone(&self) -> CounterWidth

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for CounterWidth

Source§

impl Debug for CounterWidth

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for CounterWidth

Source§

fn default() -> CounterWidth

Returns the “default value” for a type. Read more
Source§

impl Eq for CounterWidth

Source§

impl Hash for CounterWidth

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for CounterWidth

Source§

fn eq(&self, other: &CounterWidth) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for CounterWidth

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.