pub trait Cache {
type SerializeError: Error + Send + Sync;
type DeserializeError: Error + Send + Sync;
// Required methods
unsafe fn load(
&self,
engine: &impl AsEngineRef,
key: Hash,
) -> Result<Module, Self::DeserializeError>;
fn store(
&mut self,
key: Hash,
module: &Module,
) -> Result<(), Self::SerializeError>;
}
Expand description
A generic cache for storing and loading compiled wasm modules.
Required Associated Types§
Sourcetype SerializeError: Error + Send + Sync
type SerializeError: Error + Send + Sync
The serialization error for the implementation
Sourcetype DeserializeError: Error + Send + Sync
type DeserializeError: Error + Send + Sync
The deserialization error for the implementation
Required Methods§
Sourceunsafe fn load(
&self,
engine: &impl AsEngineRef,
key: Hash,
) -> Result<Module, Self::DeserializeError>
unsafe fn load( &self, engine: &impl AsEngineRef, key: Hash, ) -> Result<Module, Self::DeserializeError>
Loads a module using the provided [wasmer::Store
] and crate::Hash
.
§Safety
This function is unsafe as the cache store could be tampered with.
Sourcefn store(
&mut self,
key: Hash,
module: &Module,
) -> Result<(), Self::SerializeError>
fn store( &mut self, key: Hash, module: &Module, ) -> Result<(), Self::SerializeError>
Store a [Module
] into the cache with the given crate::Hash
.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.