Struct wasmer::sys::engine::Engine

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

pub fn new( compiler_config: Box<dyn CompilerConfig, Global>, target: Target, features: Features ) -> Engine

Create a new Engine with the given config

pub fn name(&self) -> &str

Returns the name of this engine

pub fn deterministic_id(&self) -> &str

Returns the deterministic id of this 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>

Get reference to EngineInner.

pub fn inner_mut(&self) -> MutexGuard<'_, EngineInner>

Get mutable reference to EngineInner.

pub fn target(&self) -> &Target

Gets the target

pub fn register_signature( &self, func_type: &FunctionType ) -> VMSharedSignatureIndex

Register a signature

pub fn lookup_signature( &self, sig: VMSharedSignatureIndex ) -> Option<FunctionType>

Lookup a signature

pub fn validate(&self, binary: &[u8]) -> Result<(), CompileError>

Validates a WebAssembly module

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>

Deserializes a WebAssembly module which was previously serialized with [Module::serialize].

Safety

See Artifact::deserialize_unchecked.

pub unsafe fn deserialize( &self, bytes: OwnedBuffer ) -> Result<Arc<Artifact, Global>, DeserializeError>

Deserializes a WebAssembly module which was previously serialized with [Module::serialize].

Safety

See Artifact::deserialize.

pub unsafe fn deserialize_from_file( &self, file_ref: &Path ) -> Result<Arc<Artifact, Global>, DeserializeError>

Deserializes a WebAssembly module from a path.

Safety

See Artifact::deserialize.

pub unsafe fn deserialize_from_file_unchecked( &self, file_ref: &Path ) -> Result<Arc<Artifact, Global>, DeserializeError>

Deserialize from a file path.

Safety

See Artifact::deserialize_unchecked.

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 cloned(&self) -> Engine

Clone the engine

pub fn set_tunables(&mut self, tunables: impl Tunables + Send + Sync + 'static)

Attach a Tunable to this engine

pub fn tunables(&self) -> &dyn Tunables

Get a reference to attached Tunable of this engine

Trait Implementations§

§

impl Clone for Engine

§

fn clone(&self) -> Engine

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl Debug for Engine

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
§

impl From<&Engine> for Engine

§

fn from(engine_ref: &Engine) -> Engine

Converts to this type from the input type.
§

impl From<Box<dyn CompilerConfig, Global>> for Engine

§

fn from(config: Box<dyn CompilerConfig, Global>) -> Engine

Converts to this type from the input type.
source§

impl From<Cranelift> for Engine

source§

fn from(config: Cranelift) -> Engine

Converts to this type from the input type.
§

impl From<EngineBuilder> for Engine

§

fn from(engine_builder: EngineBuilder) -> Engine

Converts to this type from the input type.
source§

impl From<LLVM> for Engine

source§

fn from(config: LLVM) -> Engine

Converts to this type from the input type.
§

impl From<Singlepass> for Engine

§

fn from(config: Singlepass) -> Engine

Converts to this type from the input type.

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§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> ArchivePointee for T

§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

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>

Deserializes using the given deserializer
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> LayoutRaw for T

§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Gets the layout of the type.
§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> Pointee for T

§

type Metadata = ()

The type for metadata in pointers and references to Self.
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> Upcastable for Twhere T: Any + Send + Sync + 'static,

§

fn upcast_any_ref(&self) -> &(dyn Any + 'static)

upcast ref
§

fn upcast_any_mut(&mut self) -> &mut (dyn Any + 'static)

upcast mut ref
§

fn upcast_any_box(self: Box<T, Global>) -> Box<dyn Any, Global>

upcast boxed dyn
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more