wasmer_vm/
export.rs

1// This file contains code from external sources.
2// Attributions: https://github.com/wasmerio/wasmer/blob/main/docs/ATTRIBUTIONS.md
3
4use crate::global::VMGlobal;
5use crate::memory::VMMemory;
6use crate::store::InternalStoreHandle;
7use crate::table::VMTable;
8use crate::vmcontext::VMFunctionKind;
9use crate::{MaybeInstanceOwned, VMCallerCheckedAnyfunc};
10use std::any::Any;
11use wasmer_types::FunctionType;
12
13/// The value of an export passed from one instance to another.
14#[cfg_attr(feature = "artifact-size", derive(loupe::MemoryUsage))]
15pub enum VMExtern {
16    /// A function export value.
17    Function(InternalStoreHandle<VMFunction>),
18
19    /// A table export value.
20    Table(InternalStoreHandle<VMTable>),
21
22    /// A memory export value.
23    Memory(InternalStoreHandle<VMMemory>),
24
25    /// A global export value.
26    Global(InternalStoreHandle<VMGlobal>),
27}
28
29/// A function export value.
30#[derive(Debug)]
31pub struct VMFunction {
32    /// Pointer to the `VMCallerCheckedAnyfunc` which contains data needed to
33    /// call the function and check its signature.
34    pub anyfunc: MaybeInstanceOwned<VMCallerCheckedAnyfunc>,
35
36    /// The function type, used for compatibility checking.
37    pub signature: FunctionType,
38
39    /// The function kind (specifies the calling convention for the
40    /// function).
41    pub kind: VMFunctionKind,
42
43    /// Associated data owned by a host function.
44    pub host_data: Box<dyn Any>,
45}