pub trait Diffable {
type Val;
// Required methods
fn start(&mut self);
fn stop(&mut self);
fn current_value(&mut self) -> Self::Val;
fn diff(current: &Self::Val, earlier: &Self::Val) -> u64;
fn print_diff(val: u64);
}
Expand description
An abstraction over some changing values that we want to measure.
A Diffable object could be stateless (e.g. a timer that reads the wall clock), or stateful (e.g. holds reference to a perf event fd)
Required Associated Types§
Required Methods§
sourcefn current_value(&mut self) -> Self::Val
fn current_value(&mut self) -> Self::Val
Read the current value
sourcefn diff(current: &Self::Val, earlier: &Self::Val) -> u64
fn diff(current: &Self::Val, earlier: &Self::Val) -> u64
Compute the difference between two readings
sourcefn print_diff(val: u64)
fn print_diff(val: u64)
Print the difference in a specific format
Object Safety§
This trait is not object safe.