wasmtime_runtime/
export.rs1use crate::vmcontext::{
2 VMContext, VMFuncRef, VMGlobalDefinition, VMMemoryDefinition, VMTableDefinition,
3};
4use std::ptr::NonNull;
5use wasmtime_environ::{DefinedMemoryIndex, Global, MemoryPlan, TablePlan};
6
7pub enum Export {
9 Function(ExportFunction),
11
12 Table(ExportTable),
14
15 Memory(ExportMemory),
17
18 Global(ExportGlobal),
20}
21
22#[derive(Debug, Clone, Copy)]
24pub struct ExportFunction {
25 pub func_ref: NonNull<VMFuncRef>,
30}
31
32unsafe impl Send for ExportFunction {}
36unsafe impl Sync for ExportFunction {}
37
38impl From<ExportFunction> for Export {
39 fn from(func: ExportFunction) -> Export {
40 Export::Function(func)
41 }
42}
43
44#[derive(Debug, Clone)]
46pub struct ExportTable {
47 pub definition: *mut VMTableDefinition,
49 pub vmctx: *mut VMContext,
51 pub table: TablePlan,
53}
54
55unsafe impl Send for ExportTable {}
57unsafe impl Sync for ExportTable {}
58
59impl From<ExportTable> for Export {
60 fn from(func: ExportTable) -> Export {
61 Export::Table(func)
62 }
63}
64
65#[derive(Debug, Clone)]
67pub struct ExportMemory {
68 pub definition: *mut VMMemoryDefinition,
70 pub vmctx: *mut VMContext,
72 pub memory: MemoryPlan,
74 pub index: DefinedMemoryIndex,
76}
77
78unsafe impl Send for ExportMemory {}
80unsafe impl Sync for ExportMemory {}
81
82impl From<ExportMemory> for Export {
83 fn from(func: ExportMemory) -> Export {
84 Export::Memory(func)
85 }
86}
87
88#[derive(Debug, Clone)]
90pub struct ExportGlobal {
91 pub definition: *mut VMGlobalDefinition,
93 pub vmctx: *mut VMContext,
96 pub global: Global,
98}
99
100unsafe impl Send for ExportGlobal {}
102unsafe impl Sync for ExportGlobal {}
103
104impl From<ExportGlobal> for Export {
105 fn from(func: ExportGlobal) -> Export {
106 Export::Global(func)
107 }
108}