Skip to main content

MetricsState

Trait MetricsState 

Source
pub trait MetricsState: 'static + Sealed {
    type Handle;
}
Expand description

Typestate marker for whether a Context tracks runtime metrics.

This trait is sealed and is implemented for exactly two types:

  • DfirMetrics: metrics are tracked. The context holds a shared Rc<DfirMetrics> handle which is updated by the generated code and exposed via Dfir::metrics.
  • (): metrics are not tracked. The handle is the zero-sized (), so the context statically contains no metrics state at all, and the metrics() accessors do not exist.

Which one is used is determined at codegen time by AsCodeOptions::include_metrics_tracking, so there is no runtime check or default-allocated metrics when tracking is disabled.

Required Associated Types§

Source

type Handle

The metrics handle stored inside the context: Rc<DfirMetrics> or ().

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl MetricsState for ()

Metrics are not tracked. Zero-sized, no runtime cost.

Implementors§

Source§

impl MetricsState for DfirMetrics

Metrics are tracked.