Trait wasm_runtime_layer::backend::WasmFunc

source ·
pub trait WasmFunc<E: WasmEngine>: Clone + Sized + Send + Sync {
    // Required methods
    fn new<T>(
        ctx: impl AsContextMut<E, UserState = T>,
        ty: FuncType,
        func: impl 'static + Send + Sync + Fn(E::StoreContextMut<'_, T>, &[Value<E>], &mut [Value<E>]) -> Result<()>
    ) -> Self;
    fn ty(&self, ctx: impl AsContext<E>) -> FuncType;
    fn call<T>(
        &self,
        ctx: impl AsContextMut<E>,
        args: &[Value<E>],
        results: &mut [Value<E>]
    ) -> Result<()>;
}
Expand description

Provides a Wasm or host function reference.

Required Methods§

source

fn new<T>( ctx: impl AsContextMut<E, UserState = T>, ty: FuncType, func: impl 'static + Send + Sync + Fn(E::StoreContextMut<'_, T>, &[Value<E>], &mut [Value<E>]) -> Result<()> ) -> Self

Creates a new function with the given arguments.

source

fn ty(&self, ctx: impl AsContext<E>) -> FuncType

Gets the function type of this object.

source

fn call<T>( &self, ctx: impl AsContextMut<E>, args: &[Value<E>], results: &mut [Value<E>] ) -> Result<()>

Calls the object with the given arguments.

Object Safety§

This trait is not object safe.

Implementors§