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],
tunables: &dyn Tunables
) -> Result<Arc<Artifact>, CompileError>
pub fn compile(
&self,
binary: &[u8],
tunables: &dyn Tunables
) -> 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.