use crate::vmcontext::{
VMCallerCheckedAnyfunc, VMContext, VMGlobalDefinition, VMMemoryDefinition, VMTableDefinition,
};
use std::ptr::NonNull;
use wasmtime_environ::{DefinedMemoryIndex, Global, MemoryPlan, TablePlan};
pub enum Export {
Function(ExportFunction),
Table(ExportTable),
Memory(ExportMemory),
Global(ExportGlobal),
}
#[derive(Debug, Clone, Copy)]
pub struct ExportFunction {
pub anyfunc: NonNull<VMCallerCheckedAnyfunc>,
}
unsafe impl Send for ExportFunction {}
unsafe impl Sync for ExportFunction {}
impl From<ExportFunction> for Export {
fn from(func: ExportFunction) -> Export {
Export::Function(func)
}
}
#[derive(Debug, Clone)]
pub struct ExportTable {
pub definition: *mut VMTableDefinition,
pub vmctx: *mut VMContext,
pub table: TablePlan,
}
unsafe impl Send for ExportTable {}
unsafe impl Sync for ExportTable {}
impl From<ExportTable> for Export {
fn from(func: ExportTable) -> Export {
Export::Table(func)
}
}
#[derive(Debug, Clone)]
pub struct ExportMemory {
pub definition: *mut VMMemoryDefinition,
pub vmctx: *mut VMContext,
pub memory: MemoryPlan,
pub index: DefinedMemoryIndex,
}
unsafe impl Send for ExportMemory {}
unsafe impl Sync for ExportMemory {}
impl From<ExportMemory> for Export {
fn from(func: ExportMemory) -> Export {
Export::Memory(func)
}
}
#[derive(Debug, Clone)]
pub struct ExportGlobal {
pub definition: *mut VMGlobalDefinition,
pub global: Global,
}
unsafe impl Send for ExportGlobal {}
unsafe impl Sync for ExportGlobal {}
impl From<ExportGlobal> for Export {
fn from(func: ExportGlobal) -> Export {
Export::Global(func)
}
}