netstack3_base

Trait CounterContext

Source
pub trait CounterContext<T> {
    // Required method
    fn with_counters<O, F: FnOnce(&T) -> O>(&self, cb: F) -> O;

    // Provided methods
    fn increment<F: FnOnce(&T) -> &Counter>(&self, cb: F) { ... }
    fn add<F: FnOnce(&T) -> &Counter>(&self, n: u64, cb: F) { ... }
}
Expand description

A context that stores counters.

CounterContext exposes access to counters for observation and debugging.

Required Methods§

Source

fn with_counters<O, F: FnOnce(&T) -> O>(&self, cb: F) -> O

Call the function with an immutable reference to counter type T.

Provided Methods§

Source

fn increment<F: FnOnce(&T) -> &Counter>(&self, cb: F)

Increments the counter returned by the callback.

Source

fn add<F: FnOnce(&T) -> &Counter>(&self, n: u64, cb: F)

Adds the provided value to the counter returned by the callback.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§