pub struct ModuleCacheEntry<'config>(_);
Expand description

Module level cache entry.

Implementations§

source§

impl<'config> ModuleCacheEntry<'config>

source

pub fn new<'data>( compiler_name: &str, cache_config: &'config CacheConfig ) -> Self

Create the cache entry.

source

pub fn get_data<T, U, E>( &self, state: T, compute: fn(_: &T) -> Result<U, E> ) -> Result<U, E>where T: Hash, U: Serialize + for<'a> Deserialize<'a>,

Gets cached data if state matches, otherwise calls compute.

Data is automatically serialized/deserialized with bincode.

source

pub fn get_data_raw<T, U, E>( &self, state: &T, compute: fn(_: &T) -> Result<U, E>, serialize: fn(_: &T, _: &U) -> Option<Vec<u8>>, deserialize: fn(_: &T, _: Vec<u8>) -> Option<U> ) -> Result<U, E>where T: Hash,

Gets cached data if state matches, otherwise calls compute.

If the cache is disabled or no cached data is found then compute is called to calculate the data. If the data was found in cache it is passed to deserialize, which if successful will be the returned value. When computed the serialize function is used to generate the bytes from the returned value.

Auto Trait Implementations§

§

impl<'config> RefUnwindSafe for ModuleCacheEntry<'config>

§

impl<'config> Send for ModuleCacheEntry<'config>

§

impl<'config> Sync for ModuleCacheEntry<'config>

§

impl<'config> Unpin for ModuleCacheEntry<'config>

§

impl<'config> UnwindSafe for ModuleCacheEntry<'config>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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> Same<T> for T

§

type Output = T

Should always be Self
source§

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

§

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 Twhere U: TryFrom<T>,

§

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.