Struct wasmer_compiler::Engine
source · pub struct Engine {
inner: Arc<Mutex<EngineInner>>,
target: Arc<Target>,
engine_id: EngineId,
tunables: Arc<dyn Tunables + Send + Sync>,
name: String,
hash_algorithm: Option<HashAlgorithm>,
}
Expand description
A WebAssembly Universal
Engine.
Fields§
§inner: Arc<Mutex<EngineInner>>
§target: Arc<Target>
The target for the compiler
engine_id: EngineId
§tunables: Arc<dyn Tunables + Send + Sync>
§name: String
§hash_algorithm: Option<HashAlgorithm>
Implementations§
source§impl Engine
impl Engine
sourcepub fn new(
compiler_config: Box<dyn CompilerConfig>,
target: Target,
features: Features,
) -> Self
pub fn new( compiler_config: Box<dyn CompilerConfig>, target: Target, features: Features, ) -> Self
Create a new Engine
with the given config
sourcepub fn set_hash_algorithm(&mut self, hash_algorithm: Option<HashAlgorithm>)
pub fn set_hash_algorithm(&mut self, hash_algorithm: Option<HashAlgorithm>)
Sets the hash algorithm
sourcepub fn hash_algorithm(&self) -> Option<HashAlgorithm>
pub fn hash_algorithm(&self) -> Option<HashAlgorithm>
Returns the hash algorithm
sourcepub fn deterministic_id(&self) -> &str
pub fn deterministic_id(&self) -> &str
Returns the deterministic id of this engine
sourcepub fn headless() -> Self
pub 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
).
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_unchecked(
&self,
bytes: OwnedBuffer,
) -> Result<Arc<Artifact>, DeserializeError>
pub unsafe fn deserialize_unchecked( &self, bytes: OwnedBuffer, ) -> Result<Arc<Artifact>, DeserializeError>
Deserializes a WebAssembly module which was previously serialized with
[Module::serialize
].
§Safety
sourcepub unsafe fn deserialize(
&self,
bytes: OwnedBuffer,
) -> Result<Arc<Artifact>, DeserializeError>
pub unsafe fn deserialize( &self, bytes: OwnedBuffer, ) -> Result<Arc<Artifact>, DeserializeError>
Deserializes a WebAssembly module which was previously serialized with
[Module::serialize
].
§Safety
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>
sourcepub unsafe fn deserialize_from_file_unchecked(
&self,
file_ref: &Path,
) -> Result<Arc<Artifact>, DeserializeError>
pub unsafe fn deserialize_from_file_unchecked( &self, file_ref: &Path, ) -> Result<Arc<Artifact>, DeserializeError>
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 From<Box<dyn CompilerConfig>> for Engine
impl From<Box<dyn CompilerConfig>> for Engine
source§fn from(config: Box<dyn CompilerConfig>) -> Self
fn from(config: Box<dyn CompilerConfig>) -> Self
source§impl From<EngineBuilder> for Engine
impl From<EngineBuilder> for Engine
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§
§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,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)