wasmtime/runtime/vm/
export.rs1use crate::runtime::vm::vmcontext::{
2 VMContext, VMFuncRef, VMGlobalDefinition, VMMemoryDefinition, VMTableDefinition,
3 VMTagDefinition,
4};
5use core::ptr::NonNull;
6use wasmtime_environ::{DefinedMemoryIndex, Global, Memory, Table, Tag};
7
8pub enum Export {
10 Function(ExportFunction),
12
13 Table(ExportTable),
15
16 Memory(ExportMemory),
18
19 Global(ExportGlobal),
21
22 Tag(ExportTag),
24}
25
26#[derive(Debug, Clone, Copy)]
28pub struct ExportFunction {
29 pub func_ref: NonNull<VMFuncRef>,
34}
35
36unsafe impl Send for ExportFunction {}
40unsafe impl Sync for ExportFunction {}
41
42impl From<ExportFunction> for Export {
43 fn from(func: ExportFunction) -> Export {
44 Export::Function(func)
45 }
46}
47
48#[derive(Debug, Clone)]
50pub struct ExportTable {
51 pub definition: NonNull<VMTableDefinition>,
53 pub vmctx: NonNull<VMContext>,
55 pub table: Table,
57}
58
59unsafe impl Send for ExportTable {}
61unsafe impl Sync for ExportTable {}
62
63impl From<ExportTable> for Export {
64 fn from(func: ExportTable) -> Export {
65 Export::Table(func)
66 }
67}
68
69#[derive(Debug, Clone)]
71pub struct ExportMemory {
72 pub definition: NonNull<VMMemoryDefinition>,
74 pub vmctx: NonNull<VMContext>,
76 pub memory: Memory,
78 pub index: DefinedMemoryIndex,
80}
81
82unsafe impl Send for ExportMemory {}
84unsafe impl Sync for ExportMemory {}
85
86impl From<ExportMemory> for Export {
87 fn from(func: ExportMemory) -> Export {
88 Export::Memory(func)
89 }
90}
91
92#[derive(Debug, Clone)]
94pub struct ExportGlobal {
95 pub definition: NonNull<VMGlobalDefinition>,
97 pub vmctx: Option<NonNull<VMContext>>,
100 pub global: Global,
102}
103
104unsafe impl Send for ExportGlobal {}
106unsafe impl Sync for ExportGlobal {}
107
108impl From<ExportGlobal> for Export {
109 fn from(func: ExportGlobal) -> Export {
110 Export::Global(func)
111 }
112}
113
114#[derive(Debug, Clone)]
116pub struct ExportTag {
117 pub definition: NonNull<VMTagDefinition>,
119 pub tag: Tag,
121}
122
123unsafe impl Send for ExportTag {}
125unsafe impl Sync for ExportTag {}
126
127impl From<ExportTag> for Export {
128 fn from(func: ExportTag) -> Export {
129 Export::Tag(func)
130 }
131}