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

source

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

Create a new Engine with the given config

source

pub fn name(&self) -> &str

Returns the name of this engine

source

pub fn set_hash_algorithm(&mut self, hash_algorithm: Option<HashAlgorithm>)

Sets the hash algorithm

source

pub fn hash_algorithm(&self) -> Option<HashAlgorithm>

Returns the hash algorithm

source

pub fn deterministic_id(&self) -> &str

Returns the deterministic id of this engine

source

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).

source

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

Get reference to EngineInner.

source

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

Get mutable reference to EngineInner.

source

pub fn target(&self) -> &Target

Gets the target

source

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

Register a signature

source

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

Lookup a signature

source

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

Validates a WebAssembly module

source

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

Compile a WebAssembly binary

source

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

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

§Safety

See Artifact::deserialize_unchecked.

source

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

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

§Safety

See Artifact::deserialize.

source

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

Deserializes a WebAssembly module from a path.

§Safety

See Artifact::deserialize.

source

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

Deserialize from a file path.

§Safety

See Artifact::deserialize_unchecked.

source

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.

source

pub fn cloned(&self) -> Self

Clone the engine

source

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

Attach a Tunable to this engine

source

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

Get a reference to attached Tunable of this engine

Trait Implementations§

source§

impl Clone for Engine

source§

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

impl Debug for Engine

source§

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

Formats the value using the given formatter. Read more
source§

impl From<&Engine> for Engine

source§

fn from(engine_ref: &Self) -> Self

Converts to this type from the input type.
source§

impl From<Box<dyn CompilerConfig>> for Engine

source§

fn from(config: Box<dyn CompilerConfig>) -> Self

Converts to this type from the input type.
source§

impl From<EngineBuilder> for Engine

source§

fn from(engine_builder: EngineBuilder) -> Self

Converts to this type from the input type.

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§

source§

impl<T> Any for T
where 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 T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where 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.

§

impl<T> LayoutRaw for T

§

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

Returns the layout of the type.
§

impl<T> Pointee for T

§

type Metadata = ()

The metadata type for pointers and references to this type.
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where 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 T
where 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 T
where 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.
source§

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

source§

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

upcast ref
source§

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

upcast mut ref
source§

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

upcast boxed dyn