#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub enum RemovalCause {
Expired,
Size,
Explicit,
Replaced,
}
pub(crate) fn from_moka(cause: moka::notification::RemovalCause) -> RemovalCause {
match cause {
moka::notification::RemovalCause::Expired => RemovalCause::Expired,
moka::notification::RemovalCause::Size => RemovalCause::Size,
moka::notification::RemovalCause::Explicit => RemovalCause::Explicit,
moka::notification::RemovalCause::Replaced => RemovalCause::Replaced,
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn from_moka_maps_all_variants() {
assert_eq!(from_moka(moka::notification::RemovalCause::Expired), RemovalCause::Expired);
assert_eq!(from_moka(moka::notification::RemovalCause::Size), RemovalCause::Size);
assert_eq!(from_moka(moka::notification::RemovalCause::Explicit), RemovalCause::Explicit);
assert_eq!(from_moka(moka::notification::RemovalCause::Replaced), RemovalCause::Replaced);
}
}