forked from feather-rs/feather
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhost_function.rs
More file actions
23 lines (19 loc) · 773 Bytes
/
host_function.rs
File metadata and controls
23 lines (19 loc) · 773 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
use std::{any::Any, marker::PhantomData, sync::Arc};
use wasmer::{FromToNativeWasmType, Store, WasmTypeList, WasmerEnv};
use crate::context::{PluginContext, PluginPtr, PluginPtrMut};
use crate::env::PluginEnv;
/// Signature of a host function.
pub trait WasmHostFunction {
/// Creates a WASM function given the plugin environment.
fn to_wasm_function(self, store: &Store, env: PluginEnv) -> wasmer::Function;
}
/// Signature of a host function for native.
/// All HostFunction types also implement NativeHostFunction.
///
/// This trait is implemented by the `#[host_function]`
/// macro attribute.
pub trait NativeHostFunction {
/// Creates a raw function pointer to be included
/// in the plugin's vtable.
fn to_function_pointer(self) -> usize;
}