wasmtime_cache

Struct ModuleCacheEntry

Source
pub struct ModuleCacheEntry<'config>(/* private fields */);
Expand description

Module level cache entry.

Implementations§

Source§

impl<'config> ModuleCacheEntry<'config>

Source

pub fn new(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> 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> 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> 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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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 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.