pub struct Engine {
inner: Arc<Mutex<EngineInner>, Global>,
target: Arc<Target, Global>,
engine_id: EngineId,
tunables: Arc<dyn Tunables + Sync + Send, Global>,
name: String,
}
Expand description
A WebAssembly Universal
Engine.
Fields§
§inner: Arc<Mutex<EngineInner>, Global>
§target: Arc<Target, Global>
§engine_id: EngineId
§tunables: Arc<dyn Tunables + Sync + Send, Global>
§name: String
Implementations§
§impl Engine
impl Engine
pub fn new(
compiler_config: Box<dyn CompilerConfig, Global>,
target: Target,
features: Features
) -> Engine
pub fn new( compiler_config: Box<dyn CompilerConfig, Global>, target: Target, features: Features ) -> Engine
Create a new Engine
with the given config
pub fn deterministic_id(&self) -> &str
pub fn deterministic_id(&self) -> &str
Returns the deterministic id of this engine
pub 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
).
pub fn inner(&self) -> MutexGuard<'_, EngineInner>
pub fn inner(&self) -> MutexGuard<'_, EngineInner>
Get reference to EngineInner
.
pub fn inner_mut(&self) -> MutexGuard<'_, EngineInner>
pub fn inner_mut(&self) -> MutexGuard<'_, EngineInner>
Get mutable reference to EngineInner
.
pub fn register_signature(
&self,
func_type: &FunctionType
) -> VMSharedSignatureIndex
pub fn register_signature( &self, func_type: &FunctionType ) -> VMSharedSignatureIndex
Register a signature
pub fn lookup_signature(
&self,
sig: VMSharedSignatureIndex
) -> Option<FunctionType>
pub fn lookup_signature( &self, sig: VMSharedSignatureIndex ) -> Option<FunctionType>
Lookup a signature
pub fn validate(&self, binary: &[u8]) -> Result<(), CompileError>
pub fn validate(&self, binary: &[u8]) -> Result<(), CompileError>
Validates a WebAssembly module
pub fn compile(
&self,
binary: &[u8]
) -> Result<Arc<Artifact, Global>, CompileError>
pub fn compile( &self, binary: &[u8] ) -> Result<Arc<Artifact, Global>, CompileError>
Compile a WebAssembly binary
pub unsafe fn deserialize_unchecked(
&self,
bytes: OwnedBuffer
) -> Result<Arc<Artifact, Global>, DeserializeError>
pub unsafe fn deserialize_unchecked( &self, bytes: OwnedBuffer ) -> Result<Arc<Artifact, Global>, DeserializeError>
Deserializes a WebAssembly module which was previously serialized with
[Module::serialize
].
Safety
pub unsafe fn deserialize(
&self,
bytes: OwnedBuffer
) -> Result<Arc<Artifact, Global>, DeserializeError>
pub unsafe fn deserialize( &self, bytes: OwnedBuffer ) -> Result<Arc<Artifact, Global>, DeserializeError>
Deserializes a WebAssembly module which was previously serialized with
[Module::serialize
].
Safety
pub unsafe fn deserialize_from_file(
&self,
file_ref: &Path
) -> Result<Arc<Artifact, Global>, DeserializeError>
pub unsafe fn deserialize_from_file( &self, file_ref: &Path ) -> Result<Arc<Artifact, Global>, DeserializeError>
pub unsafe fn deserialize_from_file_unchecked(
&self,
file_ref: &Path
) -> Result<Arc<Artifact, Global>, DeserializeError>
pub unsafe fn deserialize_from_file_unchecked( &self, file_ref: &Path ) -> Result<Arc<Artifact, Global>, DeserializeError>
pub 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.
pub 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§
§impl From<EngineBuilder> for Engine
impl From<EngineBuilder> for Engine
§fn from(engine_builder: EngineBuilder) -> Engine
fn from(engine_builder: EngineBuilder) -> Engine
§impl From<Singlepass> for Engine
impl From<Singlepass> for Engine
§fn from(config: Singlepass) -> Engine
fn from(config: Singlepass) -> Engine
Auto Trait Implementations§
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
§impl<F, W, T, D> Deserialize<With<T, W>, D> for Fwhere
W: DeserializeWith<F, T, D>,
D: Fallible + ?Sized,
F: ?Sized,
impl<F, W, T, D> Deserialize<With<T, W>, D> for Fwhere W: DeserializeWith<F, T, D>, D: Fallible + ?Sized, F: ?Sized,
§fn deserialize(
&self,
deserializer: &mut D
) -> Result<With<T, W>, <D as Fallible>::Error>
fn deserialize( &self, deserializer: &mut D ) -> Result<With<T, W>, <D as Fallible>::Error>
§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>where
F: FnOnce(&Self) -> bool,
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>where F: FnOnce(&Self) -> bool,
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