substrate_wasmtime_runtime/
imports.rs1use crate::vmcontext::{VMFunctionImport, VMGlobalImport, VMMemoryImport, VMTableImport};
2use wasmtime_environ::entity::{BoxedSlice, PrimaryMap};
3use wasmtime_environ::wasm::{FuncIndex, GlobalIndex, MemoryIndex, TableIndex};
4
5#[derive(Clone)]
7pub struct Imports {
8 pub functions: BoxedSlice<FuncIndex, VMFunctionImport>,
10
11 pub tables: BoxedSlice<TableIndex, VMTableImport>,
13
14 pub memories: BoxedSlice<MemoryIndex, VMMemoryImport>,
16
17 pub globals: BoxedSlice<GlobalIndex, VMGlobalImport>,
19}
20
21impl Imports {
22 pub fn new(
24 function_imports: PrimaryMap<FuncIndex, VMFunctionImport>,
25 table_imports: PrimaryMap<TableIndex, VMTableImport>,
26 memory_imports: PrimaryMap<MemoryIndex, VMMemoryImport>,
27 global_imports: PrimaryMap<GlobalIndex, VMGlobalImport>,
28 ) -> Self {
29 Self {
30 functions: function_imports.into_boxed_slice(),
31 tables: table_imports.into_boxed_slice(),
32 memories: memory_imports.into_boxed_slice(),
33 globals: global_imports.into_boxed_slice(),
34 }
35 }
36
37 pub fn none() -> Self {
39 Self {
40 functions: PrimaryMap::new().into_boxed_slice(),
41 tables: PrimaryMap::new().into_boxed_slice(),
42 memories: PrimaryMap::new().into_boxed_slice(),
43 globals: PrimaryMap::new().into_boxed_slice(),
44 }
45 }
46}