pub struct SharedValuesCache { /* private fields */ }Expand description
Cache layer that stores references or owned and referenced shared containers
Implementations§
Sourcepub fn new(values: Vec<SharedContainer>) -> Self
pub fn new(values: Vec<SharedContainer>) -> Self
Creates a new SharedValuesCache and populates it with the provided shared containers. Assumes that all provided containers have unique pointer addresses.
Stores a shared container in the cache, indexed by its pointer address. If a container already exists at the address, the container with the maximum ownership is kept.
Sourcepub fn store_callable(&mut self, callable: Callable) -> u64
pub fn store_callable(&mut self, callable: Callable) -> u64
Stores a callable in the cache and returns its hash value. TODO: use different hash and HashMap<hash, callable> to reduce collisions?
pub fn store_vec<T: 'static>(&mut self, vec: Vec<T>) -> usize
Sourcepub fn remove_stored_vec(&mut self, handle: usize)
pub fn remove_stored_vec(&mut self, handle: usize)
Removes a stored vector from the cache based on its handle.
Sourcepub fn get_callable(&self, hash: u64) -> Option<Callable>
pub fn get_callable(&self, hash: u64) -> Option<Callable>
Retrieves a callable from the cache based on its hash value.
Sourcepub fn remove_callable_with_hash(&mut self, hash: u64)
pub fn remove_callable_with_hash(&mut self, hash: u64)
Removes a callable from the cache based on its hash value.
Removes the shared container for the given pointer address from the cache, if it exists.
Tries to take an owned shared container from the cache for the given pointer address. If the container for the address is not an owned shared container, or if there is no container for the address, None is returned and the cache is not modified. If an owned shared container is found for the address, it is replaced with a reference in the cache and the owned container is returned
Tries to get a mutable reference to a shared container from the cache at the given pointer address. If the container for the address is not in the cache, a ValueNotFoundInCacheError is returned.
Tries to get a mutable reference to a shared container from the cache at the given pointer address. If the container for the address is not in the cache, a ValueNotFoundInCacheError is returned. If the container cannot be accessed as a mutable reference, an UnexpectedImmutableReferenceError error is returned.
Tries to get an immutable reference to a shared container from the cache at the given pointer address. If the container for the address is not in the cache, a ValueNotFoundInCacheError is returned.
Tries to get a shared container from the cache at the given pointer address with the specified ownership. If the container for the address is not in the cache, or if the container cannot be accessed with the specified ownership, a CacheValueRetrievalError is returned.
pub fn has_address_with_ownership( &self, pointer_address: &PointerAddress, ownership: SharedContainerOwnership, ) -> bool
Trait Implementations§
Auto Trait Implementations§
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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