-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.rs
33 lines (24 loc) · 859 Bytes
/
main.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
use exports::example::component::backend::{RepScalars, Scalars};
use wasmtime::component::*;
use wasmtime::{Config, Engine, Store};
bindgen!({
path: "./example.wit",
resource_mode: Object,
});
#[tokio::main]
async fn main() -> wasmtime::Result<()> {
let mut config = Config::new();
config.wasm_component_model(true);
let engine = Engine::new(&config)?;
let component = Component::from_file(&engine, "./example_guest_export.wasm").unwrap();
let linker = Linker::new(&engine);
let mut store = Store::new(&engine, ());
let (bindings, instance) = Example::instantiate(&mut store, &component, &linker).unwrap();
let resource = RepScalars::new(&mut store, &instance).unwrap();
let test = bindings
.interface0
.call_scalar_arg(&mut store, resource)
.unwrap();
dbg!(test);
Ok(())
}