Trait wasmer_engine::Engine

source ·
pub trait Engine {
    // Required methods
    fn target(&self) -> &Target;
    fn register_signature(
        &self,
        func_type: FunctionTypeRef<'_>
    ) -> VMSharedSignatureIndex;
    fn register_function_metadata(
        &self,
        func_data: VMCallerCheckedAnyfunc
    ) -> VMFuncRef;
    fn lookup_signature(
        &self,
        sig: VMSharedSignatureIndex
    ) -> Option<FunctionType>;
    fn validate(&self, binary: &[u8]) -> Result<(), CompileError>;
    fn compile(
        &self,
        binary: &[u8],
        tunables: &dyn Tunables
    ) -> Result<Box<dyn Executable>, CompileError>;
    fn load(
        &self,
        executable: &dyn Executable
    ) -> Result<Arc<dyn Artifact>, CompileError>;
    fn id(&self) -> &EngineId;
    fn cloned(&self) -> Arc<dyn Engine + Send + Sync>;
}
Expand description

A unimplemented Wasmer Engine.

This trait is used by implementors to implement custom engines such as: Universal or Native.

The product that an Engine produces and consumes is the Artifact.

Required Methods§

source

fn target(&self) -> &Target

Gets the target

source

fn register_signature( &self, func_type: FunctionTypeRef<'_> ) -> VMSharedSignatureIndex

Register a signature

source

fn register_function_metadata( &self, func_data: VMCallerCheckedAnyfunc ) -> VMFuncRef

Register a function’s data.

source

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

Lookup a signature

source

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

Validates a WebAssembly module

source

fn compile( &self, binary: &[u8], tunables: &dyn Tunables ) -> Result<Box<dyn Executable>, CompileError>

Compile a WebAssembly binary

source

fn load( &self, executable: &dyn Executable ) -> Result<Arc<dyn Artifact>, CompileError>

Load a compiled executable with this engine.

source

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

fn cloned(&self) -> Arc<dyn Engine + Send + Sync>

Clone the engine

Implementations§

source§

impl dyn Engine

source

pub fn downcast_ref<T: Engine + 'static>(&self) -> Option<&T>

Downcast a dynamic Executable object to a concrete implementation of the trait.

Implementors§