caches/lru/
error.rs

1use core::fmt::{Display, Formatter};
2
3/// `CacheError` is the errors of this crate.
4#[derive(Copy, Clone, Debug, PartialEq, PartialOrd)]
5pub enum CacheError {
6    /// Invalid cache size
7    InvalidSize(usize),
8    /// Invalid recent ratio for [`TwoQueueCache`]
9    ///
10    /// [`TwoQueueCache`]: struct.TwoQueueCache.html
11    InvalidRecentRatio(f64),
12    /// Invalid ghost ratio for [`TwoQueueCache`]
13    ///
14    /// [`TwoQueueCache`]: struct.TwoQueueCache.html
15    InvalidGhostRatio(f64),
16}
17
18impl Display for CacheError {
19    fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
20        match self {
21            CacheError::InvalidSize(size) => write!(f, "invalid cache size {}", *size),
22            CacheError::InvalidRecentRatio(r) => write!(f, "invalid recent ratio {}", *r),
23            CacheError::InvalidGhostRatio(r) => write!(f, "invalid ghost ratio {}", *r),
24        }
25    }
26}