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 + 'static, Global>,
target: Target,
features: Features
) -> Engine
pub fn new(
compiler_config: Box<dyn CompilerConfig + 'static, Global>,
target: Target,
features: Features
) -> Engine
Create a new Engine
with the given config
sourcepub fn headless() -> Engine
pub fn headless() -> Engine
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>
pub fn inner(&self) -> MutexGuard<'_, EngineInner>
Get reference to EngineInner
.
sourcepub fn inner_mut(&self) -> MutexGuard<'_, EngineInner>
pub fn inner_mut(&self) -> MutexGuard<'_, EngineInner>
Get mutable reference to EngineInner
.
sourcepub fn register_signature(
&self,
func_type: &FunctionType
) -> VMSharedSignatureIndex
pub fn register_signature(
&self,
func_type: &FunctionType
) -> VMSharedSignatureIndex
Register a signature
sourcepub fn lookup_signature(
&self,
sig: VMSharedSignatureIndex
) -> Option<FunctionType>
pub fn lookup_signature(
&self,
sig: VMSharedSignatureIndex
) -> Option<FunctionType>
Lookup a signature
sourcepub fn validate(&self, binary: &[u8]) -> Result<(), CompileError>
pub fn validate(&self, binary: &[u8]) -> Result<(), CompileError>
Validates a WebAssembly module
sourcepub fn compile(&self, binary: &[u8]) -> Result<Arc<Artifact>, CompileError>
pub fn compile(&self, binary: &[u8]) -> Result<Arc<Artifact>, CompileError>
Compile a WebAssembly binary
sourcepub unsafe fn deserialize(
&self,
bytes: &[u8]
) -> Result<Arc<Artifact>, DeserializeError>
pub unsafe fn deserialize(
&self,
bytes: &[u8]
) -> Result<Arc<Artifact>, DeserializeError>
Deserializes a WebAssembly module
Safety
The serialized content must represent a serialized WebAssembly module.
sourcepub unsafe fn deserialize_from_file(
&self,
file_ref: &Path
) -> Result<Arc<Artifact>, DeserializeError>
pub unsafe fn deserialize_from_file(
&self,
file_ref: &Path
) -> Result<Arc<Artifact>, DeserializeError>
Deserializes a WebAssembly module from a path
Safety
The file’s content must represent a serialized WebAssembly module.
sourcepub fn id(&self) -> &EngineId
pub fn id(&self) -> &EngineId
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)
pub fn set_tunables(&mut self, tunables: impl Tunables + Send + Sync + 'static)
Attach a Tunable to this engine
Trait Implementations§
source§impl AsEngineRef for Engine
impl AsEngineRef for Engine
source§fn as_engine_ref(&self) -> EngineRef<'_>
fn as_engine_ref(&self) -> EngineRef<'_>
EngineRef
pointing to the underlying context.