#[cfg(feature = "sync")]
pub(crate) mod notifier;
use std::{future::Future, pin::Pin, sync::Arc};
pub type ListenerFuture = Pin<Box<dyn Future<Output = ()> + Send>>;
#[cfg(feature = "sync")]
pub(crate) type EvictionListener<K, V> =
Arc<dyn Fn(Arc<K>, V, RemovalCause) + Send + Sync + 'static>;
#[cfg(feature = "future")]
pub(crate) type AsyncEvictionListener<K, V> =
Box<dyn Fn(Arc<K>, V, RemovalCause) -> ListenerFuture + Send + Sync + 'static>;
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum RemovalCause {
Expired,
Explicit,
Replaced,
Size,
}
impl RemovalCause {
pub fn was_evicted(&self) -> bool {
matches!(self, Self::Expired | Self::Size)
}
}