use std::future::Future;
use crate::{CacheEntry, Error, SizeError};
#[dynosaur::dynosaur(pub(crate) DynCacheTier = dyn(box) CacheTier, bridge(none))]
#[allow(
clippy::allow_attributes,
unreachable_pub,
reason = "re-exported at the crate root via `pub use tier::CacheTier`; the dynosaur attribute macro misfires unreachable_pub on the definition and item-level #[expect] is unfulfilled across the expansion"
)]
pub trait CacheTier<K, V>: Send + Sync {
fn get(&self, key: &K) -> impl Future<Output = Result<Option<CacheEntry<V>>, Error>> + Send;
fn insert(&self, key: K, entry: CacheEntry<V>) -> impl Future<Output = Result<(), Error>> + Send;
fn invalidate(&self, key: &K) -> impl Future<Output = Result<(), Error>> + Send;
fn clear(&self) -> impl Future<Output = Result<(), Error>> + Send;
fn len(&self) -> impl Future<Output = Result<u64, SizeError>> + Send {
async { Err(SizeError::unsupported()) }
}
fn is_empty(&self) -> impl Future<Output = Result<bool, SizeError>> + Send {
async { self.len().await.map(|n| n == 0) }
}
}