Struct SharedMemoryContents

Source
pub struct SharedMemoryContents<K, V> { /* private fields */ }

Implementations§

Source§

impl<K: Debug + PartialEq + Serialize + Deserialize<'static>, V: Debug + Serialize + Deserialize<'static>> SharedMemoryContents<K, V>

Source

pub fn try_insert(&mut self, key: K, value: V) -> Result<Option<V>, Error>

Tries to insert a key-value pair into the shared hashmap. If the key already exists, it is removed before inserting the new value. If the size of the hashmap exceeds the maximum size, it will evict items until there is enough space to insert the new key-value pair. Returns a Result containing an Option of the removed value if the hashmap was full and an item had to be evicted, or an error if the hashmap is too large to insert the new key-value pair.

§Arguments
  • key - A key of type K to insert into the hashmap.
  • value - A value of type V to insert into the hashmap.
Source

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

Returns the value associated with the given key in the hashmap, or None if the key is not present. If the key is present, the last accessed time for the corresponding bucket is updated.

§Arguments
  • key - A reference to the key to search for in the hashmap.
§Returns
  • Some(V) - The value associated with the given key, if it exists in the hashmap.
  • None - If the key is not present in the hashmap.
Source

pub fn peak(&self, key: &K) -> Option<V>

Returns the value associated with the given key, if it exists in the hashmap.

§Arguments
  • key - A reference to the key to search for in the hashmap.
§Returns
  • Some(V) - The value associated with the given key, if it exists in the hashmap.
  • None - If the key does not exist in the hashmap.
Source

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

Removes the entry with the specified key from the hashmap and returns the value of the removed entry. If the key is not present in the hashmap, returns None.

§Arguments
  • self - A mutable reference to the hashmap.
  • key - The key of the entry to be removed.
§Returns
  • Some(V) - The value of the removed entry, if it existed in the hashmap.
  • None - If the key was not present in the hashmap.
Source

pub fn len(&self) -> usize

Returns the number of elements in the shared hashmap.

Source

pub fn is_empty(&self) -> bool

Returns true if the shared hashmap contains no elements.

Source

pub fn used(&self) -> usize

Returns the total size of the shared memory contents used by the hashmap.

Source

pub fn free(&self) -> usize

Returns the number of free slots in the hashmap.

Source

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

Returns true if the shared hashmap contains the specified key.

§Arguments
  • key - A reference to the key to search for in the shared hashmap.
Source

pub fn clear(&mut self)

Clears the hashmap, removing all key-value pairs.

Source

pub fn get_lru(&self) -> Option<&Bucket<K, V>>

Get the least recently used bucket.

Source

pub fn evict(&mut self) -> Option<V>

Evict the least recently used bucket.

Trait Implementations§

Source§

impl<K: Debug + PartialEq + Serialize + Deserialize<'static>, V: Debug + Serialize + Deserialize<'static>> Debug for SharedMemoryContents<K, V>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

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

§

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

§

impl<K, V> Send for SharedMemoryContents<K, V>
where K: Send, V: Send,

§

impl<K, V> Sync for SharedMemoryContents<K, V>
where K: Sync, V: Sync,

§

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

§

impl<K, V> UnwindSafe for SharedMemoryContents<K, V>
where K: UnwindSafe, V: 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> 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, 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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V