Skip to content

Commit

Permalink
wasm-compose: update example for latest cargo-component. (#802)
Browse files Browse the repository at this point in the history
This commit updates the `wasm-compose` example given the latest
cargo-component, which itself is based off of the latest out of wasm-tools and
wit-bindgen.

The server in the example needed to update to a more recent wasmtime as a
result (specifically, one that supports type exports from component/instance
types).
  • Loading branch information
peterhuene committed Oct 26, 2022
1 parent 2783d58 commit a8c4fdd
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion crates/wasm-compose/example/middleware/Cargo.toml
Expand Up @@ -12,7 +12,7 @@ wit-bindgen-guest-rust = { git = "https://github.com/bytecodealliance/wit-bindge
crate-type = ["cdylib"]

[package.metadata.component]
direct-interface-export = "service"
direct-export = "service"

[package.metadata.component.imports]
backend = "../service.wit"
Expand Down
7 changes: 5 additions & 2 deletions crates/wasm-compose/example/middleware/src/lib.rs
@@ -1,5 +1,8 @@
use bindings::{
backend,
service::{Error, Request, Response, Service},
};
use flate2::{write::GzEncoder, Compression};
use service::{Error, Request, Response, Service};
use std::io::Write;

struct Component;
Expand Down Expand Up @@ -50,4 +53,4 @@ impl Service for Component {
}
}

service::export!(Component);
bindings::export!(Component);
2 changes: 1 addition & 1 deletion crates/wasm-compose/example/server/Cargo.toml
Expand Up @@ -9,6 +9,6 @@ async-std = { version = "1.12.0", features = ["attributes"] }
clap = { version = "3.2.16", features = ["derive"] }
driftwood = "0.0.6"
tide = "0.16.0"
wasmtime = { version = "2.0.0", features = ["component-model"] }
wasmtime = { git = "https://github.com/bytecodealliance/wasmtime", rev = "b61e678", features = ["component-model"] }

[workspace]
2 changes: 1 addition & 1 deletion crates/wasm-compose/example/service/Cargo.toml
Expand Up @@ -11,7 +11,7 @@ wit-bindgen-guest-rust = { git = "https://github.com/bytecodealliance/wit-bindge
crate-type = ["cdylib"]

[package.metadata.component]
direct-interface-export = "service"
direct-export = "service"

[package.metadata.component.exports]
service = "../service.wit"
Expand Down
4 changes: 2 additions & 2 deletions crates/wasm-compose/example/service/src/lib.rs
@@ -1,4 +1,4 @@
use service::{Error, Request, Response, Service};
use bindings::service::{Error, Request, Response, Service};
use std::str;

struct Component;
Expand Down Expand Up @@ -27,4 +27,4 @@ impl Service for Component {
}
}

service::export!(Component);
bindings::export!(Component);

0 comments on commit a8c4fdd

Please sign in to comment.