[][src]Struct solana_libra_vm_cache_map::CacheMap

pub struct CacheMap<'a, K, V, W> { /* fields omitted */ }

A map custom designed for the VM runtime caches. Allocations are done in an Arena instead of directly in a hash table, which allows for new entries to be added while existing entries are borrowed out.

TODO: Entry-like API? Current one is somewhat awkward to use. TODO: eviction -- how to do it safely? TODO: should the map own the arena?

Methods

impl<'a, K, V, W> CacheMap<'a, K, V, W> where
    K: Hash + PartialEq,
    W: Clone
[src]

pub fn new(alloc: &'a Arena<V>) -> Self[src]

pub fn get<Q: ?Sized>(&self, key: &Q) -> Option<W> where
    K: Borrow<Q>,
    Q: Hash + PartialEq
[src]

Get the value of the given key in the map.

pub fn or_insert_with_transform<F, G>(
    &self,
    key: K,
    insert: F,
    transform: G
) -> W where
    F: FnOnce() -> V,
    G: FnOnce(&'a V) -> W, 
[src]

Try inserting the value V if missing. The insert function is not called if the value is present.

The first value is picked to avoid multiple cached results floating around. This assumes that the cache is immutable (i.e. there's no invalidation).

Returns a reference to the inserted value.

pub fn or_insert_with_try_transform<F, G, E>(
    &self,
    key: K,
    insert: F,
    try_transform: G
) -> Result<W, E> where
    F: FnOnce() -> V,
    G: FnOnce(&'a V) -> Result<W, E>, 
[src]

A version of insert_with_transform where the transform can fail. If it does then the value is not inserted into the map and is left allocated as garbage in the arena.

Auto Trait Implementations

impl<'a, K, V, W> Sync for CacheMap<'a, K, V, W> where
    K: Send + Sync,
    V: Send,
    W: Send + Sync

impl<'a, K, V, W> Send for CacheMap<'a, K, V, W> where
    K: Send,
    V: Send,
    W: Send

impl<'a, K, V, W> Unpin for CacheMap<'a, K, V, W> where
    K: Unpin,
    W: Unpin

impl<'a, K, V, W> !RefUnwindSafe for CacheMap<'a, K, V, W>

impl<'a, K, V, W> UnwindSafe for CacheMap<'a, K, V, W> where
    K: UnwindSafe,
    W: UnwindSafe

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Erased for T