pub trait NativeEngineExt {
// Required methods
fn new(
compiler_config: Box<dyn CompilerConfig>,
target: Target,
features: Features,
) -> Self;
fn set_hash_algorithm(&mut self, hash_algorithm: Option<HashAlgorithm>);
fn headless() -> Self;
fn target(&self) -> &Target;
fn set_tunables(&mut self, tunables: impl Tunables + Send + Sync + 'static);
fn tunables(&self) -> &dyn Tunables;
unsafe fn deserialize_from_mmapped_file_unchecked(
&self,
file_ref: &Path,
) -> Result<Module, DeserializeError>;
unsafe fn deserialize_from_mmapped_file(
&self,
file_ref: &Path,
) -> Result<Module, DeserializeError>;
}
Expand description
The custom trait to access to all the sys
function in the common
engine.
Required Methods§
Sourcefn new(
compiler_config: Box<dyn CompilerConfig>,
target: Target,
features: Features,
) -> Self
fn new( compiler_config: Box<dyn CompilerConfig>, target: Target, features: Features, ) -> Self
Create a new Engine
with the given config
Sourcefn set_hash_algorithm(&mut self, hash_algorithm: Option<HashAlgorithm>)
fn set_hash_algorithm(&mut self, hash_algorithm: Option<HashAlgorithm>)
Sets the hash algorithm
Sourcefn headless() -> Self
fn headless() -> Self
Create a headless Engine
A headless engine is an engine without any compiler attached. This is useful for assuring a minimal runtime for running WebAssembly modules.
For example, for running in IoT devices where compilers are very expensive, or also to optimize startup speed.
§Important
Headless engines can’t compile or validate any modules,
they just take already processed Modules (via Module::serialize
).
Sourcefn set_tunables(&mut self, tunables: impl Tunables + Send + Sync + 'static)
fn set_tunables(&mut self, tunables: impl Tunables + Send + Sync + 'static)
Attach a Tunable to this engine
Sourceunsafe fn deserialize_from_mmapped_file_unchecked(
&self,
file_ref: &Path,
) -> Result<Module, DeserializeError>
unsafe fn deserialize_from_mmapped_file_unchecked( &self, file_ref: &Path, ) -> Result<Module, DeserializeError>
Load a serialized WebAssembly module from a memory mapped file and deserialize it.
NOTE: you should almost always prefer Self::deserialize_from_mmapped_file
.
§Safety
Sourceunsafe fn deserialize_from_mmapped_file(
&self,
file_ref: &Path,
) -> Result<Module, DeserializeError>
unsafe fn deserialize_from_mmapped_file( &self, file_ref: &Path, ) -> Result<Module, DeserializeError>
Load a serialized WebAssembly module from a memory mapped file and deserialize it.
§Safety
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.