Add example wasm component and runner which embeds the component

This commit is contained in:
michaelpivato
2024-05-11 14:22:49 +09:30
commit fca84b9240
10 changed files with 1560 additions and 0 deletions

13
component/Cargo.toml Normal file
View File

@@ -0,0 +1,13 @@
[package]
name = "component"
version = "0.1.0"
edition = "2021"
[dependencies]
wit-bindgen-rt = { version = "0.24.0", features = ["bitflags"] }
[lib]
crate-type = ["cdylib"]
[package.metadata.component]
package = "component:test"

14
component/src/lib.rs Normal file
View File

@@ -0,0 +1,14 @@
#[allow(warnings)]
mod bindings;
use bindings::{hello, Guest};
struct Component;
impl Guest for Component {
fn greet() {
hello();
}
}
bindings::export!(Component with_types_in bindings);

6
component/wit/test.wit Normal file
View File

@@ -0,0 +1,6 @@
package my:project;
world test {
import hello: func();
export greet: func();
}