pub struct CoMap<K, V>(/* private fields */)
where
K: Hash + Ord + Clone + Send + Sync + 'static,
V: Clone + Send + Sync + 'static;Implementations§
Source§impl<K, V> CoMap<K, V>
impl<K, V> CoMap<K, V>
Sourcepub async fn from_iter<S>(
storage: &S,
iter: impl IntoIterator<Item = (K, V)>,
) -> Result<Self, StorageError>where
S: AnyBlockStorage,
pub async fn from_iter<S>(
storage: &S,
iter: impl IntoIterator<Item = (K, V)>,
) -> Result<Self, StorageError>where
S: AnyBlockStorage,
Create collection from iterator.
pub async fn get<S>(
&self,
storage: &S,
key: &K,
) -> Result<Option<V>, StorageError>where
S: AnyBlockStorage,
pub async fn contains<S>(
&self,
storage: &S,
key: &K,
) -> Result<bool, StorageError>where
S: AnyBlockStorage,
pub fn stream<S>(
&self,
storage: &S,
) -> impl Stream<Item = Result<(K, V), StorageError>> + '_where
S: AnyBlockStorage,
pub async fn insert<S>(
&mut self,
storage: &S,
key: K,
value: V,
) -> Result<(), StorageError>where
S: AnyBlockStorage,
pub async fn remove<S>(
&mut self,
storage: &S,
key: K,
) -> Result<Option<V>, StorageError>where
S: AnyBlockStorage,
Sourcepub async fn update_or_insert<S, F>(
&mut self,
storage: &S,
key: K,
update: F,
) -> Result<(), StorageError>
pub async fn update_or_insert<S, F>( &mut self, storage: &S, key: K, update: F, ) -> Result<(), StorageError>
Update (or insert default) value.
Sourcepub async fn try_update_or_insert_async<S, F, Fut>(
&mut self,
storage: &S,
key: K,
update: F,
) -> Result<(), StorageError>where
V: Default,
F: FnOnce(V) -> Fut + Send,
Fut: Future<Output = Result<V, StorageError>> + Send,
S: AnyBlockStorage,
pub async fn try_update_or_insert_async<S, F, Fut>(
&mut self,
storage: &S,
key: K,
update: F,
) -> Result<(), StorageError>where
V: Default,
F: FnOnce(V) -> Fut + Send,
Fut: Future<Output = Result<V, StorageError>> + Send,
S: AnyBlockStorage,
Update (or insert default) value.
Sourcepub async fn update<S, F>(
&mut self,
storage: &S,
key: K,
update: F,
) -> Result<(), StorageError>
pub async fn update<S, F>( &mut self, storage: &S, key: K, update: F, ) -> Result<(), StorageError>
Update value ignore if key not exists.
Sourcepub async fn try_update_async<S, F, Fut>(
&mut self,
storage: &S,
key: K,
update: F,
) -> Result<(), StorageError>where
F: FnOnce(V) -> Fut + Send,
Fut: Future<Output = Result<V, StorageError>> + Send,
S: AnyBlockStorage,
pub async fn try_update_async<S, F, Fut>(
&mut self,
storage: &S,
key: K,
update: F,
) -> Result<(), StorageError>where
F: FnOnce(V) -> Fut + Send,
Fut: Future<Output = Result<V, StorageError>> + Send,
S: AnyBlockStorage,
Update (or insert default) value.
pub async fn open_mut<'m, S>(
&'m mut self,
storage: &S,
) -> Result<CoMapMutTransaction<'m, S, K, V>, StorageError>where
S: AnyBlockStorage,
pub async fn open<S>(
&self,
storage: &S,
) -> Result<CoMapTransaction<S, K, V>, StorageError>where
S: AnyBlockStorage,
pub async fn open_lazy<S>(
&self,
storage: &S,
) -> Result<LazyTransaction<S, Self>, StorageError>where
S: AnyBlockStorage,
Sourcepub async fn commit<S>(
&mut self,
transaction: CoMapTransaction<S, K, V>,
) -> Result<(), StorageError>where
S: AnyBlockStorage,
pub async fn commit<S>(
&mut self,
transaction: CoMapTransaction<S, K, V>,
) -> Result<(), StorageError>where
S: AnyBlockStorage,
Commit transaction to this map.
Sourcepub async fn with_transaction<S, F, Fut>(
&mut self,
storage: &S,
update: F,
) -> Result<(), StorageError>where
S: AnyBlockStorage,
F: FnOnce(CoMapTransaction<S, K, V>) -> Fut + Send,
Fut: Future<Output = Result<CoMapTransaction<S, K, V>, StorageError>> + Send,
pub async fn with_transaction<S, F, Fut>(
&mut self,
storage: &S,
update: F,
) -> Result<(), StorageError>where
S: AnyBlockStorage,
F: FnOnce(CoMapTransaction<S, K, V>) -> Fut + Send,
Fut: Future<Output = Result<CoMapTransaction<S, K, V>, StorageError>> + Send,
Open transaction, apply update and store it.
Trait Implementations§
Source§impl<'de, K, V> Deserialize<'de> for CoMap<K, V>where
K: Hash + Ord + Clone + Send + Sync + 'static + Deserialize<'de>,
V: Clone + Send + Sync + 'static + Deserialize<'de>,
impl<'de, K, V> Deserialize<'de> for CoMap<K, V>where
K: Hash + Ord + Clone + Send + Sync + 'static + Deserialize<'de>,
V: Clone + Send + Sync + 'static + Deserialize<'de>,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<K, V> Ord for CoMap<K, V>
impl<K, V> Ord for CoMap<K, V>
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl<K, V> PartialOrd for CoMap<K, V>where
K: Hash + Ord + Clone + Send + Sync + 'static + PartialOrd,
V: Clone + Send + Sync + 'static + PartialOrd,
impl<K, V> PartialOrd for CoMap<K, V>where
K: Hash + Ord + Clone + Send + Sync + 'static + PartialOrd,
V: Clone + Send + Sync + 'static + PartialOrd,
Source§impl<S, K, V> Streamable<S> for CoMap<K, V>where
S: AnyBlockStorage,
K: Hash + Ord + Clone + Serialize + DeserializeOwned + Send + Sync + 'static,
V: Clone + Serialize + DeserializeOwned + Send + Sync + 'static,
impl<S, K, V> Streamable<S> for CoMap<K, V>where
S: AnyBlockStorage,
K: Hash + Ord + Clone + Serialize + DeserializeOwned + Send + Sync + 'static,
V: Clone + Serialize + DeserializeOwned + Send + Sync + 'static,
Source§impl<S, K, V> Transactionable<S> for CoMap<K, V>where
S: AnyBlockStorage,
K: Hash + Ord + Clone + Serialize + DeserializeOwned + Send + Sync + 'static,
V: Clone + Serialize + DeserializeOwned + Send + Sync + 'static,
impl<S, K, V> Transactionable<S> for CoMap<K, V>where
S: AnyBlockStorage,
K: Hash + Ord + Clone + Serialize + DeserializeOwned + Send + Sync + 'static,
V: Clone + Serialize + DeserializeOwned + Send + Sync + 'static,
type Transaction = CoMapTransaction<S, K, V>
fn open<'life0, 'life1, 'async_trait>(
&'life0 self,
storage: &'life1 S,
) -> Pin<Box<dyn Future<Output = Result<Self::Transaction, StorageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
impl<K, V> Eq for CoMap<K, V>
impl<K, V> StructuralPartialEq for CoMap<K, V>
Auto Trait Implementations§
impl<K, V> Freeze for CoMap<K, V>
impl<K, V> RefUnwindSafe for CoMap<K, V>where
K: RefUnwindSafe,
V: RefUnwindSafe,
impl<K, V> Send for CoMap<K, V>
impl<K, V> Sync for CoMap<K, V>
impl<K, V> Unpin for CoMap<K, V>
impl<K, V> UnsafeUnpin for CoMap<K, V>
impl<K, V> UnwindSafe for CoMap<K, V>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more