Struct wasmtime_cache::ModuleCacheEntry
source · 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<'data>(
compiler_name: &str,
cache_config: &'config CacheConfig,
) -> Self
pub fn new<'data>( 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