ResourceCounterContext

Trait ResourceCounterContext 

Source
pub trait ResourceCounterContext<R, T>: CounterContext<T> {
    // Required method
    fn per_resource_counters<'a>(&'a self, resource: &'a R) -> &'a T;

    // Provided methods
    fn increment_both<F: Fn(&T) -> &Counter>(&self, resource: &R, cb: F) { ... }
    fn add_both<F: Fn(&T) -> &Counter>(&self, resource: &R, value: u64, cb: F) { ... }
    fn add_both_usize<F: Fn(&T) -> &Counter>(
        &self,
        resource: &R,
        value: usize,
        cb: F,
    ) { ... }
}
Expand description

A context that provides access to per-resource counters for observation and debugging.

Required Methods§

Source

fn per_resource_counters<'a>(&'a self, resource: &'a R) -> &'a T

Returns a reference to the set of counters on resource.

Provided Methods§

Source

fn increment_both<F: Fn(&T) -> &Counter>(&self, resource: &R, cb: F)

Increments both the per-resource and stackwide versions of the counter returned by the callback.

Source

fn add_both<F: Fn(&T) -> &Counter>(&self, resource: &R, value: u64, cb: F)

Adds value to both the per-resource and stackwide versions of the counter returned by the callback.

Source

fn add_both_usize<F: Fn(&T) -> &Counter>( &self, resource: &R, value: usize, cb: F, )

Like add_both but takes a usize value, saturating to u64::max if conversion fails.

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§

Source§

impl<C, S, R, Meta, DeviceId> ResourceCounterContext<R, C> for FakeCoreCtx<S, Meta, DeviceId>
where S: ResourceCounterContext<R, C>,

Source§

impl<P, R, C> ResourceCounterContext<R, C> for UninstantiableWrapper<P>