Skip to content

Commit

Permalink
GOL-209 Resource support (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
vigoo authored Feb 21, 2024
1 parent b6aa445 commit 73a4fd4
Show file tree
Hide file tree
Showing 17 changed files with 925 additions and 280 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions wasm-rpc-stubgen/example/main.wit
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,40 @@ interface iface1 {
new-point: func(x: s32, y: s32, metadata: metadata) -> point;

get-metadata: func() -> option<metadata>;

record product-item {
product-id: string,
name: string,
price: float32,
quantity: u32,
}

record order {
order-id: string,
items: list<product-item>,
total: float32,
timestamp: u64,
}

record order-confirmation {
order-id: string,
}

variant checkout-result {
error(string),
success(order-confirmation),
}

resource cart {
constructor(user-id: string);
add-item: func(item: product-item) -> ();
remove-item: func(product-id: string) -> ();
update-item-quantity: func(product-id: string, quantity: u32) -> ();
checkout: func() -> checkout-result;
get-cart-contents: func() -> list<product-item>;
merge-with: func(other-cart: borrow<cart>) -> ();
merge: static func(cart1: borrow<cart>, cart2: borrow<cart>) -> cart;
}
}

world api {
Expand Down
2 changes: 1 addition & 1 deletion wasm-rpc-stubgen/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ fn render_error<T>(result: anyhow::Result<T>) -> Option<T> {
match result {
Ok(value) => Some(value),
Err(err) => {
eprintln!("Error: {}", err);
eprintln!("Error: {:?}", err);
None
}
}
Expand Down
Loading

0 comments on commit 73a4fd4

Please sign in to comment.