Add more complexity to example with custom record and parameters
This commit is contained in:
@@ -12,8 +12,8 @@ struct TestState {
|
||||
}
|
||||
|
||||
impl TestImports for TestState {
|
||||
fn hello(&mut self) -> std::result::Result<(), wasmtime::Error> {
|
||||
println!("{}", self.name);
|
||||
fn hello(&mut self, hello_string: RecordString) -> std::result::Result<(), wasmtime::Error> {
|
||||
println!("{} - {}", self.name, hello_string.hello_string);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,7 @@ 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, "target/wasm32-wasi/release/component.wasm")?;
|
||||
let component = Component::from_file(&engine, "target/wasm32-wasip1/release/component.wasm")?;
|
||||
let mut linker = Linker::new(&engine);
|
||||
Test::add_to_linker(&mut linker, |state: &mut TestState| state)?;
|
||||
let mut store = Store::new(
|
||||
@@ -32,6 +32,6 @@ fn main() -> wasmtime::Result<()> {
|
||||
},
|
||||
);
|
||||
let (bindings, _) = Test::instantiate(&mut store, &component, &linker)?;
|
||||
bindings.call_greet(&mut store)?;
|
||||
bindings.call_greet(&mut store, &RecordString { hello_string: "Hello".to_owned() })?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user