pub struct ModuleCacheEntry<'config>(/* private fields */);
Expand description
Module level cache entry.
Implementations§
Source§impl<'config> ModuleCacheEntry<'config>
impl<'config> ModuleCacheEntry<'config>
Sourcepub fn new(compiler_name: &str, cache_config: &'config CacheConfig) -> Self
pub fn new(compiler_name: &str, cache_config: &'config CacheConfig) -> Self
Create the cache entry.
Sourcepub fn get_data<T, U, E>(
&self,
state: T,
compute: fn(_: &T) -> Result<U, E>,
) -> Result<U, E>
pub fn get_data<T, U, E>( &self, state: T, compute: fn(_: &T) -> Result<U, E>, ) -> Result<U, E>
Gets cached data if state matches, otherwise calls compute
.
Data is automatically serialized/deserialized with bincode
.
Sourcepub 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,
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> Freeze for ModuleCacheEntry<'config>
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> 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
Mutably borrows from an owned value. Read more