Skip to content

Commit

Permalink
intbox
Browse files Browse the repository at this point in the history
  • Loading branch information
jcbhmr authored Dec 28, 2023
1 parent 0cad501 commit 8a9812f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use std::f64::consts::PI;

use exports::more_exports;

// Use a procedural macro to generate bindings for the world we specified in
// `host.wit`
wit_bindgen::generate!({
Expand All @@ -13,6 +15,7 @@ wit_bindgen::generate!({
exports: {
world: HelloWorldRustWasmComponent,
"example:hello-world-rust-wasm-component-lib/hello-world-rust-wasm-component-lib-interface": HelloWorldRustWasmComponent,
"more-exports/int-box": IntBox,
},
});

Expand Down Expand Up @@ -58,3 +61,15 @@ impl Guest for HelloWorldRustWasmComponent {
return PI * circle.radius * circle.radius;
}
}

pub struct IntBox {
value: u32,
}
impl more_exports::GuestIntBox for IntBox {
fn new(value: u32) -> Self {
Self { value }
}
fn get_value(&self) -> u32 {
self.value
}
}
7 changes: 7 additions & 0 deletions wit/world.wit
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,11 @@ world hello-world-rust-wasm-component-lib {

use hello-world-rust-wasm-component-lib-interface.{circle};
export compute-area: func(circle: circle) -> float64;

export more-exports: interface {
resource int-box {
constructor(a: u32);
get-value: func() -> u32;
}
}
}

0 comments on commit 8a9812f

Please sign in to comment.