Multimap

Struct Multimap 

Source
pub struct Multimap<'a, BS>(/* private fields */);
Expand description

Multimap stores multiple values per key in a Hamt of Amts. The order of insertion of values for each key is retained.

Implementations§

Source§

impl<'a, BS> Multimap<'a, BS>
where BS: Blockstore,

Source

pub fn new(bs: &'a BS, outer_bitwidth: u32, inner_bitwidth: u32) -> Self

Initializes a new empty multimap. The outer_bitwidth is the width of the HAMT and the inner_bitwidth is the width of the AMTs inside of it.

Source

pub fn from_root( bs: &'a BS, cid: &Cid, outer_bitwidth: u32, inner_bitwidth: u32, ) -> Result<Self, Error>

Initializes a multimap from a root Cid

Source

pub fn root(&mut self) -> Result<Cid, Error>

Retrieve root from the multimap.

Source

pub fn add<V>(&mut self, key: BytesKey, value: V) -> Result<(), Error>

Adds a value for a key.

Source

pub fn get<V>(&self, key: &[u8]) -> Result<Option<Array<'a, V, BS>>, Error>

Gets the Array of value type V using the multimap store.

Source

pub fn remove_all(&mut self, key: &[u8]) -> Result<(), Error>

Removes all values for a key.

Source

pub fn for_each<F, V>(&self, key: &[u8], f: F) -> Result<(), Error>

Iterates through all values in the array at a given key.

Source

pub fn for_all<F, V>(&self, f: F) -> Result<(), Error>
where V: Serialize + DeserializeOwned, F: FnMut(&BytesKey, &Array<'_, V, BS>) -> Result<()>,

Iterates through all arrays in the multimap

Auto Trait Implementations§

§

impl<'a, BS> Freeze for Multimap<'a, BS>

§

impl<'a, BS> RefUnwindSafe for Multimap<'a, BS>
where BS: RefUnwindSafe,

§

impl<'a, BS> Send for Multimap<'a, BS>
where BS: Sync,

§

impl<'a, BS> !Sync for Multimap<'a, BS>

§

impl<'a, BS> Unpin for Multimap<'a, BS>

§

impl<'a, BS> UnwindSafe for Multimap<'a, BS>
where BS: RefUnwindSafe,

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> 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> Same for T

Source§

type Output = T

Should always be Self
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.