Meter

Trait Meter 

Source
pub trait Meter<K, V> {
    type Measure: Default + Copy;

    // Required method
    fn measure<Q: ?Sized>(&self, key: &Q, value: &V) -> Self::Measure
       where K: Borrow<Q>;
}
Expand description

A trait for measuring the size of a cache entry.

If you implement this trait, you should use usize as the Measure type, otherwise you will also have to implement CountableMeter.

Required Associated Types§

Source

type Measure: Default + Copy

The type used to store measurements.

Required Methods§

Source

fn measure<Q: ?Sized>(&self, key: &Q, value: &V) -> Self::Measure
where K: Borrow<Q>,

Calculate the size of key and value.

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<K> Meter<K, u64> for FileSize

Given a tuple of (path, filesize), use the filesize for measurement.

Source§

impl<K, V> Meter<K, V> for Count