Skip to main content

CoMap

Struct CoMap 

Source
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>
where K: Hash + Ord + Clone + Serialize + DeserializeOwned + Send + Sync + 'static, V: Clone + Serialize + DeserializeOwned + Send + Sync + 'static,

Source

pub async fn from_iter<S>( storage: &S, iter: impl IntoIterator<Item = (K, V)>, ) -> Result<Self, StorageError>
where S: AnyBlockStorage,

Create collection from iterator.

Source

pub fn is_empty(&self) -> bool

Whether this collection is empty.

Source

pub async fn get<S>( &self, storage: &S, key: &K, ) -> Result<Option<V>, StorageError>
where S: AnyBlockStorage,

Source

pub async fn contains<S>( &self, storage: &S, key: &K, ) -> Result<bool, StorageError>
where S: AnyBlockStorage,

Source

pub fn stream<S>( &self, storage: &S, ) -> impl Stream<Item = Result<(K, V), StorageError>> + '_
where S: AnyBlockStorage,

Source

pub async fn insert<S>( &mut self, storage: &S, key: K, value: V, ) -> Result<(), StorageError>
where S: AnyBlockStorage,

Source

pub async fn remove<S>( &mut self, storage: &S, key: K, ) -> Result<Option<V>, StorageError>
where S: AnyBlockStorage,

Source

pub async fn update_or_insert<S, F>( &mut self, storage: &S, key: K, update: F, ) -> Result<(), StorageError>

Update (or insert default) value.

Source

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.

Source

pub async fn update<S, F>( &mut self, storage: &S, key: K, update: F, ) -> Result<(), StorageError>

Update value ignore if key not exists.

Source

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.

Source

pub async fn open_mut<'m, S>( &'m mut self, storage: &S, ) -> Result<CoMapMutTransaction<'m, S, K, V>, StorageError>
where S: AnyBlockStorage,

Source

pub async fn open<S>( &self, storage: &S, ) -> Result<CoMapTransaction<S, K, V>, StorageError>
where S: AnyBlockStorage,

Source

pub async fn open_lazy<S>( &self, storage: &S, ) -> Result<LazyTransaction<S, Self>, StorageError>
where S: AnyBlockStorage,

Source

pub async fn commit<S>( &mut self, transaction: CoMapTransaction<S, K, V>, ) -> Result<(), StorageError>
where S: AnyBlockStorage,

Commit transaction to this map.

Source

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<K, V> Clone for CoMap<K, V>
where K: Hash + Ord + Clone + Send + Sync + 'static + Clone, V: Clone + Send + Sync + 'static + Clone,

Source§

fn clone(&self) -> CoMap<K, V>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<K, V> Debug for CoMap<K, V>
where K: Hash + Ord + Clone + Send + Sync + 'static + Debug, V: Clone + Send + Sync + 'static + Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<K, V> Default for CoMap<K, V>
where K: Hash + Ord + Clone + Send + Sync + 'static, V: Clone + Send + Sync + 'static,

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
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>,

Source§

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> From<&CoMap<K, V>> for Option<Cid>
where K: Hash + Ord + Clone + Send + Sync + 'static, V: Clone + Send + Sync + 'static,

Source§

fn from(value: &CoMap<K, V>) -> Self

Converts to this type from the input type.
Source§

impl<K, V> From<Option<Cid<64>>> for CoMap<K, V>
where K: Hash + Ord + Clone + Send + Sync + 'static, V: Clone + Send + Sync + 'static,

Source§

fn from(cid: Option<Cid>) -> Self

Converts to this type from the input type.
Source§

impl<K, V> Hash for CoMap<K, V>
where K: Hash + Ord + Clone + Send + Sync + 'static + Hash, V: Clone + Send + Sync + 'static + Hash,

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<K, V> Ord for CoMap<K, V>
where K: Hash + Ord + Clone + Send + Sync + 'static + Ord, V: Clone + Send + Sync + 'static + Ord,

Source§

fn cmp(&self, other: &CoMap<K, V>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<K, V> PartialEq for CoMap<K, V>
where K: Hash + Ord + Clone + Send + Sync + 'static + PartialEq, V: Clone + Send + Sync + 'static + PartialEq,

Source§

fn eq(&self, other: &CoMap<K, V>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<K, V> PartialOrd for CoMap<K, V>
where K: Hash + Ord + Clone + Send + Sync + 'static + PartialOrd, V: Clone + Send + Sync + 'static + PartialOrd,

Source§

fn partial_cmp(&self, other: &CoMap<K, V>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<K, V> Serialize for CoMap<K, V>
where K: Hash + Ord + Clone + Send + Sync + 'static + Serialize, V: Clone + Send + Sync + 'static + Serialize,

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
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,

Source§

type Item = Result<(K, V), StorageError>

Source§

type Stream = Pin<Box<dyn Stream<Item = <CoMap<K, V> as Streamable<S>>::Item> + Send>>

Source§

fn stream(&self, storage: S) -> Self::Stream

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,

Source§

type Transaction = CoMapTransaction<S, K, V>

Source§

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,

Source§

impl<K, V> Eq for CoMap<K, V>
where K: Hash + Ord + Clone + Send + Sync + 'static + Eq, V: Clone + Send + Sync + 'static + Eq,

Source§

impl<K, V> StructuralPartialEq for CoMap<K, V>
where K: Hash + Ord + Clone + Send + Sync + 'static, V: Clone + Send + Sync + 'static,

Auto Trait Implementations§

§

impl<K, V> Freeze for CoMap<K, V>

§

impl<K, V> RefUnwindSafe for CoMap<K, V>

§

impl<K, V> Send for CoMap<K, V>

§

impl<K, V> Sync for CoMap<K, V>

§

impl<K, V> Unpin for CoMap<K, V>
where K: Unpin, V: Unpin,

§

impl<K, V> UnsafeUnpin for CoMap<K, V>

§

impl<K, V> UnwindSafe for CoMap<K, V>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> IsDefault for T
where T: Default + PartialEq,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,