Hamt

Struct Hamt 

Source
pub struct Hamt<K, V, A>(/* private fields */)
where
    A: Annotation<KvPair<K, V>>;

Implementations§

Source§

impl<K, V, A> Hamt<K, V, A>
where K: Eq + Canon, V: Canon, A: Annotation<KvPair<K, V>> + Canon,

Source

pub fn new() -> Self

Creates a new empty Hamt

Source

pub fn insert(&mut self, key: K, val: V) -> Result<Option<V>, CanonError>

Source

pub fn remove(&mut self, key: &K) -> Result<Option<V>, CanonError>

Source

pub fn get<'a>( &'a self, key: &K, ) -> Result<Option<impl Deref<Target = V> + 'a>, CanonError>

Source

pub fn get_mut<'a>( &'a mut self, key: &K, ) -> Result<Option<impl DerefMut<Target = V> + 'a>, CanonError>

Trait Implementations§

Source§

impl<K: Canon, V: Canon, A> Canon for Hamt<K, V, A>
where A: Annotation<KvPair<K, V>> + Canon,

Source§

fn encode(&self, sink: &mut Sink<'_>)

Write the encoded value as bytes to a Sink
Source§

fn decode(source: &mut Source<'_>) -> Result<Self, CanonError>

Return the decoded value from bytes in a Source
Source§

fn encoded_len(&self) -> usize

Returns the number of bytes needed to encode this value
Source§

impl<K: Clone, V: Clone, A> Clone for Hamt<K, V, A>
where A: Annotation<KvPair<K, V>> + Clone,

Source§

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

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, A> Compound<A> for Hamt<K, V, A>
where A: Annotation<KvPair<K, V>> + Canon, K: Canon, V: Canon,

Source§

type Leaf = KvPair<K, V>

The leaf type of the Compound collection
Source§

fn child(&self, ofs: usize) -> Child<'_, Self, A>

Returns a reference to a possible child at specified offset
Source§

fn child_mut(&mut self, ofs: usize) -> ChildMut<'_, Self, A>

Returns a mutable reference to a possible child at specified offset
Source§

fn from_generic(generic: &GenericTree) -> Result<Self, CanonError>

Construct a specific compound tree from a generic tree
Source§

fn annotations(&self) -> AnnoIter<'_, Self, A>
where A: Annotation<Self::Leaf>,

Provides an iterator over all sub-annotations of the compound node
Source§

fn generic(&self) -> GenericTree
where Self::Leaf: Canon, A: Annotation<Self::Leaf>,

Returns a generic version of this compound tree, erasing the specific annotation and leaf types, to provide a universal tree encoding.
Source§

impl<K: Debug, V: Debug, A> Debug for Hamt<K, V, A>
where A: Annotation<KvPair<K, V>> + Debug,

Source§

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

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

impl<K, V, A> Default for Hamt<K, V, A>
where A: Annotation<KvPair<K, V>>,

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl<K, V, A> !Freeze for Hamt<K, V, A>

§

impl<K, V, A> !RefUnwindSafe for Hamt<K, V, A>

§

impl<K, V, A> Send for Hamt<K, V, A>
where K: Send + Sync, V: Send + Sync, A: Send + Sync,

§

impl<K, V, A> Sync for Hamt<K, V, A>
where K: Sync + Send, V: Sync + Send, A: Send + Sync,

§

impl<K, V, A> Unpin for Hamt<K, V, A>
where K: Unpin, V: Unpin, A: Unpin,

§

impl<K, V, A> !UnwindSafe for Hamt<K, V, A>

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> EncodeToVec for T
where T: Canon,

Source§

fn encode_to_vec(&self) -> Vec<u8>

Encode Self into a buffer
Source§

impl<'a, C, A> First<'a, A> for C
where C: Compound<A>, A: Canon,

Source§

fn first(&'a self) -> Result<Option<Branch<'a, C, A>>, CanonError>

Construct a Branch pointing to the first element, if not empty
Source§

fn first_mut(&'a mut self) -> Result<Option<BranchMut<'a, C, A>>, CanonError>
where C: MutableLeaves + Clone,

Construct a BranchMut pointing to the first element, if not empty
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<'a, C, A, K> GetMaxKey<'a, A, K> for C
where C: Compound<A> + Clone, <C as Compound<A>>::Leaf: Keyed<K>, A: Annotation<<C as Compound<A>>::Leaf> + Borrow<MaxKey<K>>, K: Ord + Clone + Debug,

Source§

fn max_key(&'a self) -> Result<Option<Branch<'a, C, A>>, CanonError>

Construct a Branch pointing to the element with the largest key
Source§

fn max_key_mut(&'a mut self) -> Result<Option<BranchMut<'a, C, A>>, CanonError>
where C: MutableLeaves,

Construct a BranchMut pointing to the element with the largest key
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> Keyed<T> for T

Source§

fn key(&self) -> &T

Return a reference to the key of the leaf type
Source§

impl<'a, C, A> Nth<'a, A> for C
where C: Compound<A> + Clone, A: Annotation<<C as Compound<A>>::Leaf> + Borrow<Cardinality>,

Source§

fn nth(&'a self, ofs: u64) -> Result<Option<Branch<'a, C, A>>, CanonError>

Construct a Branch pointing to the nth element, if any
Source§

fn nth_mut( &'a mut self, ofs: u64, ) -> Result<Option<BranchMut<'a, C, A>>, CanonError>
where C: MutableLeaves,

Construct a BranchMut pointing to the nth element, if any
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.