pub struct Engine { /* private fields */ }Expand description
A WebAssembly Universal Engine.
Implementations§
Source§impl Engine
impl Engine
Sourcepub fn new(
compiler_config: Box<dyn CompilerConfig>,
target: Target,
features: Features,
) -> Self
Available on (crate features std or core) and crate feature compiler only.
pub fn new( compiler_config: Box<dyn CompilerConfig>, target: Target, features: Features, ) -> Self
std or core) and crate feature compiler only.Create a new Engine with the given config
Sourcepub fn name(&self) -> &str
Available on crate features std or core only.
pub fn name(&self) -> &str
std or core only.Returns the name of this engine
Sourcepub fn deterministic_id(&self) -> String
Available on crate features std or core only.
pub fn deterministic_id(&self) -> String
std or core only.Returns the deterministic id of this engine
Sourcepub fn headless() -> Self
Available on crate features std or core only.
pub fn headless() -> Self
std or core only.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).
Sourcepub fn inner(&self) -> MutexGuard<'_, EngineInner>
Available on crate features std or core only.
pub fn inner(&self) -> MutexGuard<'_, EngineInner>
std or core only.Get reference to EngineInner.
Sourcepub fn inner_mut(&self) -> MutexGuard<'_, EngineInner>
Available on crate features std or core only.
pub fn inner_mut(&self) -> MutexGuard<'_, EngineInner>
std or core only.Get mutable reference to EngineInner.
Sourcepub fn register_signature(
&self,
func_type: &FunctionType,
) -> VMSharedSignatureIndex
Available on (crate features std or core) and non-WebAssembly only.
pub fn register_signature( &self, func_type: &FunctionType, ) -> VMSharedSignatureIndex
std or core) and non-WebAssembly only.Register a signature
Sourcepub fn lookup_signature(
&self,
sig: VMSharedSignatureIndex,
) -> Option<FunctionType>
Available on (crate features std or core) and non-WebAssembly only.
pub fn lookup_signature( &self, sig: VMSharedSignatureIndex, ) -> Option<FunctionType>
std or core) and non-WebAssembly only.Lookup a signature
Sourcepub fn validate(&self, binary: &[u8]) -> Result<(), CompileError>
Available on (crate features std or core) and crate feature compiler only.
pub fn validate(&self, binary: &[u8]) -> Result<(), CompileError>
std or core) and crate feature compiler only.Validates a WebAssembly module
Sourcepub fn compile(&self, binary: &[u8]) -> Result<Arc<Artifact>, CompileError>
Available on (crate features std or core) and crate feature compiler and non-WebAssembly only.
pub fn compile(&self, binary: &[u8]) -> Result<Arc<Artifact>, CompileError>
std or core) and crate feature compiler and non-WebAssembly only.Compile a WebAssembly binary
Sourcepub fn compile_with_progress(
&self,
binary: &[u8],
progress_callback: Option<CompilationProgressCallback>,
) -> Result<Arc<Artifact>, CompileError>
Available on (crate features std or core) and crate feature compiler only.
pub fn compile_with_progress( &self, binary: &[u8], progress_callback: Option<CompilationProgressCallback>, ) -> Result<Arc<Artifact>, CompileError>
std or core) and crate feature compiler only.Compile a WebAssembly binary with a progress callback.
Sourcepub unsafe fn deserialize_unchecked(
&self,
bytes: OwnedBuffer,
) -> Result<Arc<Artifact>, DeserializeError>
Available on (crate features std or core) and non-WebAssembly only.
pub unsafe fn deserialize_unchecked( &self, bytes: OwnedBuffer, ) -> Result<Arc<Artifact>, DeserializeError>
std or core) and non-WebAssembly only.Deserializes a WebAssembly module which was previously serialized with
[wasmer::Module::serialize].
§Safety
Sourcepub unsafe fn deserialize(
&self,
bytes: OwnedBuffer,
) -> Result<Arc<Artifact>, DeserializeError>
Available on (crate features std or core) and non-WebAssembly only.
pub unsafe fn deserialize( &self, bytes: OwnedBuffer, ) -> Result<Arc<Artifact>, DeserializeError>
std or core) and non-WebAssembly only.Deserializes a WebAssembly module which was previously serialized with
[wasmer::Module::serialize].
§Safety
Sourcepub unsafe fn deserialize_from_file(
&self,
file_ref: &Path,
) -> Result<Arc<Artifact>, DeserializeError>
Available on (crate features std or core) and non-WebAssembly only.
pub unsafe fn deserialize_from_file( &self, file_ref: &Path, ) -> Result<Arc<Artifact>, DeserializeError>
std or core) and non-WebAssembly only.Sourcepub unsafe fn deserialize_from_file_unchecked(
&self,
file_ref: &Path,
) -> Result<Arc<Artifact>, DeserializeError>
Available on (crate features std or core) and non-WebAssembly only.
pub unsafe fn deserialize_from_file_unchecked( &self, file_ref: &Path, ) -> Result<Arc<Artifact>, DeserializeError>
std or core) and non-WebAssembly only.Sourcepub fn id(&self) -> &EngineId
Available on crate features std or core only.
pub fn id(&self) -> &EngineId
std or core only.A unique identifier for this object.
This exists to allow us to compare two Engines for equality. Otherwise, comparing two trait objects unsafely relies on implementation details of trait representation.
Sourcepub fn set_tunables(&mut self, tunables: impl Tunables + Send + Sync + 'static)
Available on (crate features std or core) and non-WebAssembly only.
pub fn set_tunables(&mut self, tunables: impl Tunables + Send + Sync + 'static)
std or core) and non-WebAssembly only.Attach a Tunable to this engine
Sourcepub fn tunables(&self) -> &dyn Tunables
Available on (crate features std or core) and non-WebAssembly only.
pub fn tunables(&self) -> &dyn Tunables
std or core) and non-WebAssembly only.Get a reference to attached Tunable of this engine
Sourcepub fn with_opts(
&mut self,
_suggested_opts: &UserCompilerOptimizations,
) -> Result<(), CompileError>
Available on crate features std or core only.
pub fn with_opts( &mut self, _suggested_opts: &UserCompilerOptimizations, ) -> Result<(), CompileError>
std or core only.Add suggested optimizations to this engine.
§Note
Not every backend supports every optimization. This function may fail (i.e. not set the suggested optimizations) silently if the underlying engine backend does not support one or more optimizations.
Trait Implementations§
Source§impl From<Box<dyn CompilerConfig>> for Engine
Available on (crate features std or core) and crate feature compiler only.
impl From<Box<dyn CompilerConfig>> for Engine
std or core) and crate feature compiler only.Source§fn from(config: Box<dyn CompilerConfig>) -> Self
fn from(config: Box<dyn CompilerConfig>) -> Self
Source§impl From<EngineBuilder> for Engine
Available on crate features std or core only.
impl From<EngineBuilder> for Engine
std or core only.Source§fn from(engine_builder: EngineBuilder) -> Self
fn from(engine_builder: EngineBuilder) -> Self
Auto Trait Implementations§
impl Freeze for Engine
impl !RefUnwindSafe for Engine
impl Send for Engine
impl Sync for Engine
impl Unpin for Engine
impl !UnwindSafe for Engine
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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>
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 moreSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.Source§impl<T> Upcastable for T
impl<T> Upcastable for T
Source§fn upcast_any_ref(&self) -> &(dyn Any + 'static)
fn upcast_any_ref(&self) -> &(dyn Any + 'static)
std or core only.Source§fn upcast_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn upcast_any_mut(&mut self) -> &mut (dyn Any + 'static)
std or core only.