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::{DeserializeError, SerializeError};
use wasmer_cache::{Cache, FileSystemCache, Hash};

fn store_module(module: &Module, bytes: &[u8]) -> Result<(), SerializeError> {
    // Create a new file system cache.
    let mut fs_cache = FileSystemCache::new("some/directory/goes/here")?;

    // Compute a key for a given WebAssembly binary
    let key = Hash::generate(bytes);

    // Store a module into the cache given a key
    fs_cache.store(key, module)?;

    Ok(())
}

Implementations§

Construct a new FileSystemCache around the specified directory.

Set the extension for this cached file.

This is needed for loading native files from Windows, as otherwise loading the library will fail (it requires a .dll extension)

Trait Implementations§

The deserialization error for the implementation
The serialization error for the implementation
Loads a module using the provided Store and [Hash]. Read more
Store a Module into the cache with the given [Hash].

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
The archived version of the pointer metadata for this type.
Converts some archived metadata to the pointer metadata for itself.
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Deserializes using the given deserializer

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type for metadata in pointers and references to Self.
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
upcast ref
upcast mut ref
upcast boxed dyn