Struct HashTable

Source
pub struct HashTable<C: Config, D: Borrow<[u8]>> { /* private fields */ }
Expand description

The HashTable type provides a cheap way to construct a non-resizable view of a persisted hash table. If the underlying data storage D implements BorrowMut<[u8]> then the table can be modified in place.

Implementations§

Source§

impl<C: Config, D: Borrow<[u8]>> HashTable<C, D>

Source

pub fn from_raw_bytes(data: D) -> Result<HashTable<C, D>, Box<dyn Error>>

Constructs a HashTable from its raw byte representation. The provided data must have the exact right number of bytes.

This method has constant time complexity and will only verify the header data of the hash table. It will not copy any data.

Source

pub unsafe fn from_raw_bytes_unchecked(data: D) -> HashTable<C, D>

Constructs a HashTable from its raw byte representation without doing any verification of the underlying data. It is the user’s responsibility to make sure that the underlying data is actually a valid hash table.

The HashTable::from_raw_bytes method provides a safe alternative to this method.

Source

pub fn get(&self, key: &C::Key) -> Option<C::Value>

Source

pub fn contains_key(&self, key: &C::Key) -> bool

Source

pub fn iter(&self) -> Iter<'_, C>

Source

pub fn len(&self) -> usize

Returns the number of items stored in the hash table.

Source

pub fn raw_bytes(&self) -> &[u8]

Source§

impl<C: Config, D: Borrow<[u8]> + BorrowMut<[u8]>> HashTable<C, D>

Source

pub fn init_in_place( data: D, max_item_count: usize, max_load_factor_percent: u8, ) -> Result<HashTable<C, D>, Box<dyn Error>>

Source

pub fn insert(&mut self, key: &C::Key, value: &C::Value) -> Option<C::Value>

Inserts the given key-value pair into the table. Unlike HashTableOwned::insert this method cannot grow the underlying table if there is not enough space for the new item. Instead the call will panic.

Trait Implementations§

Source§

impl<C: Clone + Config, D: Clone + Borrow<[u8]>> Clone for HashTable<C, D>

Source§

fn clone(&self) -> HashTable<C, D>

Returns a copy 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<C: Copy + Config, D: Copy + Borrow<[u8]>> Copy for HashTable<C, D>

Auto Trait Implementations§

§

impl<C, D> Freeze for HashTable<C, D>
where D: Freeze,

§

impl<C, D> RefUnwindSafe for HashTable<C, D>

§

impl<C, D> Send for HashTable<C, D>
where D: Send, C: Send,

§

impl<C, D> Sync for HashTable<C, D>
where D: Sync, C: Sync,

§

impl<C, D> Unpin for HashTable<C, D>
where D: Unpin, C: Unpin,

§

impl<C, D> UnwindSafe for HashTable<C, D>
where D: UnwindSafe, C: UnwindSafe,

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> 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> 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.