Skip to main content

CoList

Struct CoList 

Source
pub struct CoList<V>(/* private fields */)
where
    V: Clone + Send + Sync + 'static;
Expand description

CoList stored values in a sequence.

Implementations§

Source§

impl<V> CoList<V>
where V: Clone + Serialize + DeserializeOwned + Send + Sync + 'static,

Source

pub async fn from_iter<S>( storage: &S, iter: impl IntoIterator<Item = 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: &CoListIndex, ) -> Result<Option<V>, StorageError>
where S: AnyBlockStorage,

Source

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

Source

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

Source

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

Source

pub async fn vec<S>( &self, storage: &S, limit: Option<usize>, ) -> Result<Vec<V>, StorageError>
where S: AnyBlockStorage,

Convenience method to load all or limit entries into memory.

Source

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

Source

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

Source

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

Source

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

Pop last element.

See: CoListTransaction::pop

Source

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

Pop first element.

See: CoListTransaction::pop_front

Source

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

Source

pub async fn update_or_insert<S, F>( &mut self, storage: &S, key: CoListIndex, 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: CoListIndex, 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: CoListIndex, 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: CoListIndex, 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<S>( &self, storage: &S, ) -> Result<CoListTransaction<S, 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: CoListTransaction<S, V>, ) -> Result<(), StorageError>
where S: AnyBlockStorage,

Source

pub async fn with_transaction<S, F, Fut>( &mut self, storage: &S, update: F, ) -> Result<(), StorageError>
where S: AnyBlockStorage, F: FnOnce(CoListTransaction<S, V>) -> Fut + Send, Fut: Future<Output = Result<CoListTransaction<S, V>, StorageError>> + Send,

Open transaction, apply update and store it.

Trait Implementations§

Source§

impl<V> Clone for CoList<V>
where V: Clone + Send + Sync + 'static + Clone,

Source§

fn clone(&self) -> CoList<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<V> Debug for CoList<V>
where 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<V> Default for CoList<V>
where V: Clone + Send + Sync + 'static,

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de, V> Deserialize<'de> for CoList<V>
where 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<V> From<&CoList<V>> for Option<Cid>
where V: Clone + Send + Sync + 'static,

Source§

fn from(value: &CoList<V>) -> Self

Converts to this type from the input type.
Source§

impl<V> From<Option<Cid<64>>> for CoList<V>
where V: Clone + Send + Sync + 'static,

Source§

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

Converts to this type from the input type.
Source§

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

Source§

fn cmp(&self, other: &CoList<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<V> PartialEq for CoList<V>
where V: Clone + Send + Sync + 'static + PartialEq,

Source§

fn eq(&self, other: &CoList<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<V> PartialOrd for CoList<V>
where V: Clone + Send + Sync + 'static + PartialOrd,

Source§

fn partial_cmp(&self, other: &CoList<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<V> Serialize for CoList<V>
where 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, V> Streamable<S> for CoList<V>
where S: AnyBlockStorage, V: Clone + Serialize + DeserializeOwned + Send + Sync + 'static,

Source§

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

Source§

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

Source§

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

Source§

impl<S, V> Transactionable<S> for CoList<V>
where S: AnyBlockStorage, V: Clone + Serialize + DeserializeOwned + Send + Sync + 'static,

Source§

type Transaction = CoListTransaction<S, 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<V> Eq for CoList<V>
where V: Clone + Send + Sync + 'static + Eq,

Source§

impl<V> StructuralPartialEq for CoList<V>
where V: Clone + Send + Sync + 'static,

Auto Trait Implementations§

§

impl<V> Freeze for CoList<V>

§

impl<V> RefUnwindSafe for CoList<V>
where V: RefUnwindSafe,

§

impl<V> Send for CoList<V>

§

impl<V> Sync for CoList<V>

§

impl<V> Unpin for CoList<V>
where V: Unpin,

§

impl<V> UnsafeUnpin for CoList<V>

§

impl<V> UnwindSafe for CoList<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>,