StatsLedger

Struct StatsLedger 

Source
pub struct StatsLedger { /* private fields */ }
Expand description

The shared traffic ledger.

Lock-free and const-constructible, so a board declares one static and hands out &'static references to every producer and reader. Ordering is Relaxed throughout: each counter is independent, no reader is deciding anything from the ordering between two of them, and the alternative buys a fence on the radio’s hot path to make diagnostics agree about an instant nobody is looking at.

Implementations§

Source§

impl StatsLedger

Source

pub const fn new() -> Self

Source

pub fn bump(&self, counter: Counter)

Record one event.

Source

pub fn add(&self, counter: Counter, n: u32)

Record n events. Adding zero is free and is the ordinary case for a mirroring producer whose source has not moved.

Source

pub fn get(&self, counter: Counter) -> u32

What a host reads: events since boot, or since it last cleared this counter.

Source

pub fn raw(&self, counter: Counter) -> u32

The underlying tally, ignoring any clear. Nothing on the wire reports this; it is here so a device that wants a since-boot view of its own has one.

Source

pub fn reset(&self, counter: Counter)

Start this counter over from here.

Clearing several counters is several of these, so a frame landing mid-sweep is counted before one and after another. Nothing reads them closely enough for that to matter, and the alternative is a lock on the radio’s hot path.

Trait Implementations§

Source§

impl Debug for StatsLedger

Source§

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

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

impl Default for StatsLedger

Source§

fn default() -> Self

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

Auto Trait Implementations§

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.