Skip to content

Commit 8a9812f

Browse files
authored
intbox
1 parent 0cad501 commit 8a9812f

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

src/lib.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
use std::f64::consts::PI;
22

3+
use exports::more_exports;
4+
35
// Use a procedural macro to generate bindings for the world we specified in
46
// `host.wit`
57
wit_bindgen::generate!({
@@ -13,6 +15,7 @@ wit_bindgen::generate!({
1315
exports: {
1416
world: HelloWorldRustWasmComponent,
1517
"example:hello-world-rust-wasm-component-lib/hello-world-rust-wasm-component-lib-interface": HelloWorldRustWasmComponent,
18+
"more-exports/int-box": IntBox,
1619
},
1720
});
1821

@@ -58,3 +61,15 @@ impl Guest for HelloWorldRustWasmComponent {
5861
return PI * circle.radius * circle.radius;
5962
}
6063
}
64+
65+
pub struct IntBox {
66+
value: u32,
67+
}
68+
impl more_exports::GuestIntBox for IntBox {
69+
fn new(value: u32) -> Self {
70+
Self { value }
71+
}
72+
fn get_value(&self) -> u32 {
73+
self.value
74+
}
75+
}

wit/world.wit

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,11 @@ world hello-world-rust-wasm-component-lib {
3232

3333
use hello-world-rust-wasm-component-lib-interface.{circle};
3434
export compute-area: func(circle: circle) -> float64;
35+
36+
export more-exports: interface {
37+
resource int-box {
38+
constructor(a: u32);
39+
get-value: func() -> u32;
40+
}
41+
}
3542
}

0 commit comments

Comments
 (0)