ritecache 0.1.0

RiteCache. A smart cache that knows your data.
Documentation
pub mod count_meter;
pub mod file_meter;
#[cfg(feature = "heapsize")]
pub mod heap_meter;

use std::borrow::Borrow;

/// 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`][countablemeter].
///
/// [countablemeter]: trait.Meter.html
pub trait Meter<K, V> {
    /// The type used to store measurements.
    type Measure: Default + Copy;
    /// Calculate the size of `key` and `value`.
    fn measure<Q: ?Sized>(&self, key: &Q, value: &V) -> Self::Measure
    where
        K: Borrow<Q>;
}