Struct wasmer_cache::filesystem::FileSystemCache
source · pub struct FileSystemCache {
path: PathBuf,
ext: Option<String>,
}
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(())
}
Fields§
§path: PathBuf
§ext: Option<String>
Implementations§
source§impl FileSystemCache
impl FileSystemCache
sourcepub fn new<P: Into<PathBuf>>(path: P) -> Result<Self>
pub fn new<P: Into<PathBuf>>(path: P) -> Result<Self>
Construct a new FileSystemCache
around the specified directory.
sourcepub fn set_cache_extension(&mut self, ext: Option<impl ToString>)
pub fn set_cache_extension(&mut self, ext: Option<impl ToString>)
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§
source§impl Cache for FileSystemCache
impl Cache for FileSystemCache
§type DeserializeError = DeserializeError
type DeserializeError = DeserializeError
The deserialization error for the implementation
§type SerializeError = SerializeError
type SerializeError = SerializeError
The serialization error for the implementation
source§unsafe 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>
source§fn 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
.source§impl Clone for FileSystemCache
impl Clone for FileSystemCache
source§fn clone(&self) -> FileSystemCache
fn clone(&self) -> FileSystemCache
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto 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§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Returns the layout of the type.
§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2where
T: SharedNiching<N1, N2>,
N1: Niching<T>,
N2: Niching<T>,
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2where
T: SharedNiching<N1, N2>,
N1: Niching<T>,
N2: Niching<T>,
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> Pointee for T
impl<T> Pointee for T
§impl<T> Upcastable for T
impl<T> Upcastable for T
§fn upcast_any_ref(&self) -> &(dyn Any + 'static)
fn upcast_any_ref(&self) -> &(dyn Any + 'static)
upcast ref
§fn upcast_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn upcast_any_mut(&mut self) -> &mut (dyn Any + 'static)
upcast mut ref
§fn upcast_any_box(self: Box<T>) -> Box<dyn Any>
fn upcast_any_box(self: Box<T>) -> Box<dyn Any>
upcast boxed dyn