WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 3017941

Browse files
committed
fix: allow components to *not* import resources from WASI interfaces
Signed-off-by: Roman Volosatovs <[email protected]>
1 parent 769c4b1 commit 3017941

File tree

4 files changed

+17
-38
lines changed

4 files changed

+17
-38
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,5 +184,5 @@ wrpc-transport-web = { version = "0.2", path = "./crates/transport-web", default
184184
wrpc-wasi-keyvalue = { version = "0.1.1", path = "./crates/wasi-keyvalue", default-features = false }
185185
wrpc-wasi-keyvalue-mem = { version = "0.1", path = "./crates/wasi-keyvalue-mem", default-features = false }
186186
wrpc-wasi-keyvalue-redis = { version = "0.1", path = "./crates/wasi-keyvalue-redis", default-features = false }
187-
wrpc-wasmtime-cli = { version = "0.8", path = "./crates/wasmtime-cli", default-features = false }
187+
wrpc-wasmtime-cli = { version = "0.8.1", path = "./crates/wasmtime-cli", default-features = false }
188188
wtransport = { version = "0.6.1", default-features = false }

crates/wasmtime-cli/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "wrpc-wasmtime-cli"
3-
version = "0.8.0"
3+
version = "0.8.1"
44
description = "wRPC Wasmtime CLI"
55

66
authors.workspace = true

crates/wasmtime-cli/src/lib.rs

Lines changed: 14 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -235,58 +235,37 @@ where
235235
Bound::Included("wasi:io/[email protected]"),
236236
Bound::Excluded("wasi:io/[email protected]"),
237237
))
238-
.map(|(name, instance)| {
239-
instance
240-
.get("error")
241-
.copied()
242-
.with_context(|| format!("{name} instance import missing `error` resource"))
243-
})
244-
.collect::<anyhow::Result<Box<[_]>>>()?;
238+
.flat_map(|(_, instance)| instance.get("error"))
239+
.copied()
240+
.collect::<Box<[_]>>();
245241
let io_pollable_tys = host_resources
246242
.range::<str, _>((
247243
Bound::Included("wasi:io/[email protected]"),
248244
Bound::Excluded("wasi:io/[email protected]"),
249245
))
250-
.map(|(name, instance)| {
251-
instance
252-
.get("pollable")
253-
.copied()
254-
.with_context(|| format!("{name} instance import missing `pollable` resource"))
255-
})
256-
.collect::<anyhow::Result<Box<[_]>>>()?;
246+
.flat_map(|(_, instance)| instance.get("pollable"))
247+
.copied()
248+
.collect::<Box<[_]>>();
257249
let io_input_stream_tys = host_resources
258250
.range::<str, _>((
259251
Bound::Included("wasi:io/[email protected]"),
260252
Bound::Excluded("wasi:io/[email protected]"),
261253
))
262-
.map(|(name, instance)| {
263-
instance
264-
.get("input-stream")
265-
.copied()
266-
.with_context(|| format!("{name} instance import missing `input-stream` resource"))
267-
})
268-
.collect::<anyhow::Result<Box<[_]>>>()?;
254+
.flat_map(|(_, instance)| instance.get("input-stream"))
255+
.copied()
256+
.collect::<Box<[_]>>();
269257
let io_output_stream_tys = host_resources
270258
.range::<str, _>((
271259
Bound::Included("wasi:io/[email protected]"),
272260
Bound::Excluded("wasi:io/[email protected]"),
273261
))
274-
.map(|(name, instance)| {
275-
instance
276-
.get("output-stream")
277-
.copied()
278-
.with_context(|| format!("{name} instance import missing `output-stream` resource"))
279-
})
280-
.collect::<anyhow::Result<Box<[_]>>>()?;
262+
.flat_map(|(_, instance)| instance.get("output-stream"))
263+
.copied()
264+
.collect::<Box<[_]>>();
281265
let rpc_err_ty = host_resources
282266
.get("wrpc:rpc/[email protected]")
283-
.map(|instance| {
284-
instance
285-
.get("error")
286-
.copied()
287-
.context("`wrpc:rpc/[email protected]` instance import missing `error` resource")
288-
})
289-
.transpose()?;
267+
.and_then(|instance| instance.get("error"))
268+
.copied();
290269
// TODO: This should include `wasi:http` resources
291270
let host_resources = host_resources
292271
.into_iter()

0 commit comments

Comments
 (0)