pub struct Engine {
pub(crate) be: BackendEngine,
pub(crate) id: u64,
}Expand description
The Engine is the entrypoint type for the runtime. It defines the kind of steps the runtime must take to execute
the WebAssembly module (compile, interpret..) and the place of execution (in-browser, host,
..).
Fields§
§be: BackendEngine§id: u64Implementations§
Source§impl Engine
impl Engine
Sourcepub fn into_sys(self) -> Engine
pub fn into_sys(self) -> Engine
Consume self into a crate::backend::sys::engine::Engine.
Sourcepub fn as_sys(&self) -> &Engine
pub fn as_sys(&self) -> &Engine
Convert a reference to self into a reference crate::backend::sys::engine::Engine.
Sourcepub fn as_sys_mut(&mut self) -> &mut Engine
pub fn as_sys_mut(&mut self) -> &mut Engine
Convert a mutable reference to self into a mutable reference crate::backend::sys::engine::Engine.
Source§impl Engine
impl Engine
pub(crate) fn atomic_next_engine_id() -> u64
Sourcepub fn deterministic_id(&self) -> String
pub fn deterministic_id(&self) -> String
Returns the deterministic id of this engine.
Sourcepub fn default_features_for_backend(
backend: &BackendKind,
target: &Target,
) -> Features
pub fn default_features_for_backend( backend: &BackendKind, target: &Target, ) -> Features
Returns the default WebAssembly features supported by this backend for a given target.
These are the features that will be enabled by default without any user configuration.
Sourcepub fn supported_features_for_backend(
backend: &BackendKind,
target: &Target,
) -> Features
pub fn supported_features_for_backend( backend: &BackendKind, target: &Target, ) -> Features
Returns all WebAssembly features supported by the specified backend for a given target.
This static method allows checking features for any backend, not just the current one.
Sourceunsafe fn deserialize_unchecked(
&self,
bytes: impl IntoBytes,
) -> Result<Arc<Artifact>, DeserializeError>
unsafe fn deserialize_unchecked( &self, bytes: impl IntoBytes, ) -> Result<Arc<Artifact>, DeserializeError>
Deserializes a WebAssembly module which was previously serialized with
Module::serialize,
§Note
You should almost always prefer Self::deserialize.
§Errors
Not every implementer supports serializing and deserializing modules.
Currently, only the sys engines support it, and only when the target
architecture is not wasm32.
§Safety
Sourceunsafe fn deserialize(
&self,
bytes: impl IntoBytes,
) -> Result<Arc<Artifact>, DeserializeError>
unsafe fn deserialize( &self, bytes: impl IntoBytes, ) -> Result<Arc<Artifact>, DeserializeError>
Deserializes a WebAssembly module which was previously serialized with
Module::serialize,
§Errors
Not every implementer supports serializing and deserializing modules.
Currently, only the sys engines support it, and only when the target
architecture is not wasm32.
Sourceunsafe fn deserialize_from_file_unchecked(
&self,
file_ref: &Path,
) -> Result<Arc<Artifact>, DeserializeError>
unsafe fn deserialize_from_file_unchecked( &self, file_ref: &Path, ) -> Result<Arc<Artifact>, DeserializeError>
Load a serialized WebAssembly module from a file and deserialize it.
§Note
You should almost always prefer Self::deserialize_from_file.
§Errors
Not every implementer supports serializing and deserializing modules.
Currently, only the sys engines support it, and only when the target
architecture is not wasm32.
§Safety
Sourceunsafe fn deserialize_from_file(
&self,
file_ref: &Path,
) -> Result<Arc<Artifact>, DeserializeError>
unsafe fn deserialize_from_file( &self, file_ref: &Path, ) -> Result<Arc<Artifact>, DeserializeError>
Sourcepub fn with_opts(
&mut self,
suggested_opts: &UserCompilerOptimizations,
) -> Result<(), CompileError>
pub fn with_opts( &mut self, suggested_opts: &UserCompilerOptimizations, ) -> Result<(), CompileError>
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.
Sourcepub fn supports_async(&self) -> bool
pub fn supports_async(&self) -> bool
Returns true if the engine supports async operations.
Trait Implementations§
Source§impl AsEngineRef for Engine
impl AsEngineRef for Engine
Source§impl From<EngineBuilder> for Engine
impl From<EngineBuilder> for Engine
Source§fn from(value: EngineBuilder) -> Self
fn from(value: EngineBuilder) -> Self
Source§impl From<Singlepass> for Engine
impl From<Singlepass> for Engine
Source§fn from(value: Singlepass) -> Self
fn from(value: Singlepass) -> Self
Source§impl NativeEngineExt for Engine
impl NativeEngineExt for Engine
Source§fn new(
compiler_config: Box<dyn CompilerConfig>,
target: Target,
features: Features,
) -> Self
fn new( compiler_config: Box<dyn CompilerConfig>, target: Target, features: Features, ) -> Self
Engine with the given configSource§fn set_tunables(&mut self, tunables: impl Tunables + Send + Sync + 'static)
fn set_tunables(&mut self, tunables: impl Tunables + Send + Sync + 'static)
Source§fn 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>
Source§unsafe 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>
Source§unsafe 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>
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§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
§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,
§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>
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 more