pub struct FileSystemCache { /* private fields */ }Expand description
Representation of a directory that contains compiled wasm artifacts.
The FileSystemCache type implements the Cache trait, which allows it to be used
generically when some sort of cache is required.
§Usage:
use wasmer_runtime::cache::{Cache, FileSystemCache, WasmHash};
fn store_module(module: Module) -> Result<Module, CacheError> {
// Create a new file system cache.
// This is unsafe because we can't ensure that the artifact wasn't
// corrupted or tampered with.
let mut fs_cache = unsafe { FileSystemCache::new("some/directory/goes/here")? };
// Compute a key for a given WebAssembly binary
let key = WasmHash::generate(&[]);
// Store a module into the cache given a key
fs_cache.store(key, module.clone())?;
Ok(module)
}Implementations§
Source§impl FileSystemCache
impl FileSystemCache
Sourcepub unsafe fn new<P: Into<PathBuf>>(path: P) -> Result<Self>
pub unsafe fn new<P: Into<PathBuf>>(path: P) -> Result<Self>
Construct a new FileSystemCache around the specified directory.
The contents of the cache are stored in sub-versioned directories.
§Note:
This method is unsafe because there’s no way to ensure the artifacts stored in this cache haven’t been corrupted or tampered with.
Trait Implementations§
Source§impl Cache for FileSystemCache
impl Cache for FileSystemCache
Source§type StoreError = Error
type StoreError = Error
Error type to return when store error occurs
Source§fn load(&self, key: WasmHash) -> Result<Module, CacheError>
fn load(&self, key: WasmHash) -> Result<Module, CacheError>
loads a module using the default
BackendSource§fn load_with_backend(
&self,
key: WasmHash,
backend: Backend,
) -> Result<Module, CacheError>
fn load_with_backend( &self, key: WasmHash, backend: Backend, ) -> Result<Module, CacheError>
loads a cached module using a specific
BackendAuto Trait Implementations§
impl Freeze for FileSystemCache
impl RefUnwindSafe for FileSystemCache
impl Send for FileSystemCache
impl Sync for FileSystemCache
impl Unpin for FileSystemCache
impl UnwindSafe for FileSystemCache
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