pub trait NativeEngineExt {
// Required methods
fn new(
compiler_config: Box<dyn CompilerConfig>,
target: Target,
features: Features,
) -> Self;
fn headless() -> Self;
fn target(&self) -> &Target;
fn set_tunables(&mut self, tunables: impl Tunables + Send + Sync + 'static);
fn tunables(&self) -> &dyn Tunables;
fn new_module_with_progress(
&self,
bytes: &[u8],
on_progress: CompilationProgressCallback,
) -> Result<Module, CompileError>;
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 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
Sourcefn new_module_with_progress(
&self,
bytes: &[u8],
on_progress: CompilationProgressCallback,
) -> Result<Module, CompileError>
fn new_module_with_progress( &self, bytes: &[u8], on_progress: CompilationProgressCallback, ) -> Result<Module, CompileError>
Compile a module from bytes with a progress callback.
The callback is invoked with progress updates during the compilation process. The callback also may return an error to abort the compilation.
Signature of the callback function: Fn(CompilationProgress) -> Result<(), UserAbort> + Send + Sync + 'static
§Aborting compilation
The callback has to return a Result<(), UserAbort>.
If the callback returns an error, the compilation will fail with a CompileError::Aborted.
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.