iroh_metrics::core

Trait Metric

Source
pub trait Metric:
    Default
    + Iterable
    + Sized
    + Debug
    + 'static
    + Send
    + Sync {
    // Required method
    fn name() -> &'static str;

    // Provided methods
    fn new(registry: &mut Registry) -> Self { ... }
    fn with_metric<T, F: FnOnce(&Self) -> T>(f: F) { ... }
    fn try_get() -> Option<&'static Self> { ... }
}
Expand description

Description of a group of metrics.

Required Methods§

Source

fn name() -> &'static str

The name of this metric group.

Provided Methods§

Source

fn new(registry: &mut Registry) -> Self

Initializes this metric group.

Source

fn with_metric<T, F: FnOnce(&Self) -> T>(f: F)

Access to this metrics group to record a metric. Only records if this metric is registered in the global registry.

Source

fn try_get() -> Option<&'static Self>

Attempts to get the current metric from the global registry.

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§