Skip to main content

SharedValuesCache

Struct SharedValuesCache 

Source
pub struct SharedValuesCache { /* private fields */ }
Expand description

Cache layer that stores references or owned and referenced shared containers

Implementations§

Source§

impl SharedValuesCache

Source

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.

Source

pub fn store_shared_container(&mut self, container: SharedContainer)

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.

Source

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?

Source

pub fn store_vec<T: 'static>(&mut self, vec: Vec<T>) -> usize

Source

pub fn remove_stored_vec(&mut self, handle: usize)

Removes a stored vector from the cache based on its handle.

Source

pub fn get_callable(&self, hash: u64) -> Option<Callable>

Retrieves a callable from the cache based on its hash value.

Source

pub fn remove_callable_with_hash(&mut self, hash: u64)

Removes a callable from the cache based on its hash value.

Source

pub fn remove_shared_container(&mut self, pointer_address: &PointerAddress)

Removes the shared container for the given pointer address from the cache, if it exists.

Source

pub fn try_take_owned_shared_container( &mut self, pointer_address: &PointerAddress, ) -> Result<OwnedSharedContainer, CacheValueRetrievalError>

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

Source

pub fn try_get_shared_container( &self, pointer_address: &PointerAddress, ) -> Result<&SharedContainer, ValueNotFoundInCacheError>

Source

pub fn try_get_shared_container_reference( &self, pointer_address: &PointerAddress, mutability: ReferenceMutability, ) -> Result<ReferencedSharedContainer, CacheValueRetrievalError>

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.

Source

pub fn try_get_shared_container_mutable_reference( &self, pointer_address: &PointerAddress, ) -> Result<ReferencedSharedContainer, CacheValueRetrievalError>

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.

Source

pub fn try_get_shared_container_immutable_reference( &self, pointer_address: &PointerAddress, ) -> Result<ReferencedSharedContainer, ValueNotFoundInCacheError>

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.

Source

pub fn try_get_shared_container_with_ownership( &mut self, pointer_address: &PointerAddress, ownership: SharedContainerOwnership, ) -> Result<SharedContainer, CacheValueRetrievalError>

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.

Source

pub fn has_address_with_ownership( &self, pointer_address: &PointerAddress, ownership: SharedContainerOwnership, ) -> bool

Trait Implementations§

Source§

impl Debug for SharedValuesCache

Source§

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

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

impl Default for SharedValuesCache

Source§

fn default() -> Self

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

Auto Trait Implementations§

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> DynEq for T
where T: Any,

Source§

default fn dyn_eq(&self, _other: &(dyn Any + 'static)) -> bool

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> TryClone for T

Source§

default fn try_clone(&self) -> Result<Value, ()>

Attempts to clone Self into a new Value.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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<T, U> TypeSubset<U> for T
where U: TypeSuperset<T>,

Source§

fn is_subset_of(&self, other: &U) -> bool

Returns whether self is a subset of type