linera_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 derivative::Derivative;
11use std::any::Any;
12use wasmer_types::FunctionType;
13
14/// The value of an export passed from one instance to another.
15#[cfg_attr(feature = "artifact-size", derive(loupe::MemoryUsage))]
16pub enum VMExtern {
17    /// A function export value.
18    Function(InternalStoreHandle<VMFunction>),
19
20    /// A table export value.
21    Table(InternalStoreHandle<VMTable>),
22
23    /// A memory export value.
24    Memory(InternalStoreHandle<VMMemory>),
25
26    /// A global export value.
27    Global(InternalStoreHandle<VMGlobal>),
28}
29
30/// A function export value.
31#[derive(Derivative)]
32#[derivative(Debug)]
33pub struct VMFunction {
34    /// Pointer to the `VMCallerCheckedAnyfunc` which contains data needed to
35    /// call the function and check its signature.
36    #[derivative(Debug = "ignore")]
37    pub anyfunc: MaybeInstanceOwned<VMCallerCheckedAnyfunc>,
38
39    /// The function type, used for compatibility checking.
40    pub signature: FunctionType,
41
42    /// The function kind (specifies the calling convention for the
43    /// function).
44    pub kind: VMFunctionKind,
45
46    /// Associated data owned by a host function.
47    #[derivative(Debug = "ignore")]
48    pub host_data: Box<dyn Any>,
49}