pub trait Engine: MemoryUsage {
// Required methods
fn target(&self) -> &Target;
fn register_signature(
&self,
func_type: &FunctionType,
) -> 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<Arc<dyn Artifact>, CompileError>;
unsafe fn deserialize(
&self,
bytes: &[u8],
) -> Result<Arc<dyn Artifact>, DeserializeError>;
fn id(&self) -> &EngineId;
fn cloned(&self) -> Arc<dyn Engine + Send + Sync>;
// Provided method
unsafe fn deserialize_from_file(
&self,
file_ref: &Path,
) -> Result<Arc<dyn Artifact>, DeserializeError> { ... }
}
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§
Sourcefn register_signature(&self, func_type: &FunctionType) -> VMSharedSignatureIndex
fn register_signature(&self, func_type: &FunctionType) -> VMSharedSignatureIndex
Register a signature
Sourcefn register_function_metadata(
&self,
func_data: VMCallerCheckedAnyfunc,
) -> VMFuncRef
fn register_function_metadata( &self, func_data: VMCallerCheckedAnyfunc, ) -> VMFuncRef
Register a function’s data.
Sourcefn lookup_signature(&self, sig: VMSharedSignatureIndex) -> Option<FunctionType>
fn lookup_signature(&self, sig: VMSharedSignatureIndex) -> Option<FunctionType>
Lookup a signature
Sourcefn compile(
&self,
binary: &[u8],
tunables: &dyn Tunables,
) -> Result<Arc<dyn Artifact>, CompileError>
fn compile( &self, binary: &[u8], tunables: &dyn Tunables, ) -> Result<Arc<dyn Artifact>, CompileError>
Compile a WebAssembly binary
Sourceunsafe fn deserialize(
&self,
bytes: &[u8],
) -> Result<Arc<dyn Artifact>, DeserializeError>
unsafe fn deserialize( &self, bytes: &[u8], ) -> Result<Arc<dyn Artifact>, DeserializeError>
Deserializes a WebAssembly module
§Safety
The serialized content must represent a serialized WebAssembly module.
Provided Methods§
Sourceunsafe fn deserialize_from_file(
&self,
file_ref: &Path,
) -> Result<Arc<dyn Artifact>, DeserializeError>
unsafe fn deserialize_from_file( &self, file_ref: &Path, ) -> Result<Arc<dyn Artifact>, DeserializeError>
Deserializes a WebAssembly module from a path
§Safety
The file’s content must represent a serialized WebAssembly module.