wasmtime/trampoline/
table.rs

1use crate::store::{InstanceId, StoreOpaque};
2use crate::trampoline::create_handle;
3use crate::TableType;
4use anyhow::Result;
5use wasmtime_environ::{EntityIndex, Module};
6
7pub fn create_table(store: &mut StoreOpaque, table: &TableType) -> Result<InstanceId> {
8    let mut module = Module::new();
9    let table_plan = wasmtime_environ::TablePlan::for_table(
10        table.wasmtime_table().clone(),
11        &store.engine().config().tunables,
12    );
13    let table_id = module.table_plans.push(table_plan);
14    // TODO: can this `exports.insert` get removed?
15    module
16        .exports
17        .insert(String::new(), EntityIndex::Table(table_id));
18
19    create_handle(module, store, Box::new(()), &[], None)
20}