use crate::store::StoreBase;
pub trait AsyncStoreRead: StoreBase {
fn get(&self, key: Self::Key) -> impl Future<Output = Option<Self::Value>>;
fn len(&self) -> impl Future<Output = usize>;
fn is_empty(&self) -> impl Future<Output = bool> {
async { self.len().await == 0 }
}
}
pub trait AsyncStoreWrite: AsyncStoreRead {
fn insert(&self, key: Self::Key, value: Self::Value) -> impl Future<Output = ()>;
}
pub trait AsyncStore: AsyncStoreRead + AsyncStoreWrite {}
impl<T> AsyncStore for T where T: AsyncStoreRead + AsyncStoreWrite {}