Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -179,13 +179,13 @@ wasmtime-cli-flags = { version = "45", default-features = false }
wasmtime-wasi = { version = "45", default-features = false }
wasmtime-wasi-http = { version = "45", default-features = false }
wit-bindgen = { version = "0.45", default-features = false }
wit-bindgen-core = { version = "0.37", default-features = false }
wit-bindgen-core = { version = "0.38", default-features = false }
wit-bindgen-wrpc = { version = "0.11", default-features = false, path = "./crates/wit-bindgen" }
wit-bindgen-wrpc-go = { version = "0.13", default-features = false, path = "./crates/wit-bindgen-go" }
wit-bindgen-wrpc-rust = { version = "0.11", default-features = false, path = "./crates/wit-bindgen-rust" }
wit-bindgen-wrpc-rust-macro = { version = "0.11", default-features = false, path = "./crates/wit-bindgen-rust-macro" }
wit-component = { version = "0.252", default-features = false }
wit-parser = { version = "0.223", default-features = false }
wit-parser = { version = "0.224", default-features = false }
wrpc-cli = { version = "0.8", path = "./crates/cli", default-features = false }
wrpc-introspect = { version = "0.7", default-features = false, path = "./crates/introspect" }
wrpc-nats = { version = "0.1", path = "./crates/nats", default-features = false }
Expand Down
16 changes: 9 additions & 7 deletions crates/introspect/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,13 +190,15 @@ pub fn async_paths_tyid(resolve: &Resolve, id: TypeId) -> (BTreeSet<VecDeque<Opt
}
TypeDefKind::Stream(element) => {
let mut paths = BTreeSet::new();
let (nested, fut) = async_paths_ty(resolve, element);
for mut path in nested {
path.push_front(None);
paths.insert(path);
}
if fut {
paths.insert(vec![None].into());
if let Some(ty) = element {
let (nested, fut) = async_paths_ty(resolve, ty);
for mut path in nested {
path.push_front(None);
paths.insert(path);
}
if fut {
paths.insert(vec![None].into());
}
}
(paths.into_iter().collect(), true)
}
Expand Down
14 changes: 7 additions & 7 deletions crates/wit-bindgen-go/src/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1069,8 +1069,8 @@ impl InterfaceGenerator<'_> {
}
}

fn print_read_stream(&mut self, element: &Type, reader: &str, path: &str) {
match Some(element) {
fn print_read_stream(&mut self, element: &Option<Type>, reader: &str, path: &str) {
match element {
Some(ty) if is_ty(self.resolve, Type::U8, ty) => {
let bytes = self.deps.bytes();
let io = self.deps.io();
Expand Down Expand Up @@ -2065,8 +2065,8 @@ impl InterfaceGenerator<'_> {
}
}

fn print_write_stream(&mut self, element: &Type, name: &str, writer: &str) {
match Some(element) {
fn print_write_stream(&mut self, element: &Option<Type>, name: &str, writer: &str) {
match element {
Some(ty) if is_ty(self.resolve, Type::U8, ty) => {
let fmt = self.deps.fmt();
let io = self.deps.io();
Expand Down Expand Up @@ -3256,8 +3256,8 @@ func ServeInterface(s {wrpc}.Server, h Handler) (stop func() error, err error) {
}
}

fn print_stream(&mut self, element: &Type) {
match Some(element) {
fn print_stream(&mut self, element: &Option<Type>) {
match element {
Some(ty) if is_ty(self.resolve, Type::U8, ty) => {
let io = self.deps.io();
self.push_str(io);
Expand Down Expand Up @@ -3884,7 +3884,7 @@ func (v *{name}) WriteToIndex(w {wrpc}.ByteWriter) (func({wrpc}.IndexWriter) err
}
}

fn type_stream(&mut self, id: TypeId, _name: &str, ty: &Type, docs: &Docs) {
fn type_stream(&mut self, id: TypeId, _name: &str, ty: &Option<Type>, docs: &Docs) {
if let Some(name) = self.name_of(id) {
self.godoc(docs);
uwrite!(self.src, "type {name} = ");
Expand Down
10 changes: 7 additions & 3 deletions crates/wit-bindgen-rust/src/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -998,13 +998,17 @@ pub fn serve_interface<'a, T: {wrpc_transport}::Serve>(
self.push_str("> + ::core::marker::Send>>");
}

fn print_stream(&mut self, element: &Type, submodule: bool) {
fn print_stream(&mut self, element: &Option<Type>, submodule: bool) {
uwrite!(
self.src,
"::core::pin::Pin<::std::boxed::Box<dyn {futures}::Stream<Item = ",
futures = self.gen.futures_path()
);
self.print_list(element, true, submodule);
if let Some(ty) = element {
self.print_list(ty, true, submodule);
} else {
self.push_str("Vec<()>");
}
self.push_str("> + ::core::marker::Send>>");
}

Expand Down Expand Up @@ -2468,7 +2472,7 @@ mod {mod_name} {{
}
}

fn type_stream(&mut self, id: TypeId, _name: &str, ty: &Type, docs: &Docs) {
fn type_stream(&mut self, id: TypeId, _name: &str, ty: &Option<Type>, docs: &Docs) {
if let Some(name) = self.name_of(id) {
self.rustdoc(docs);
uwrite!(self.src, "pub type {name} = ");
Expand Down
2 changes: 1 addition & 1 deletion tests/codegen/futures.wit
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ interface futures {
future-f32-param: func(x: future<f32>);
future-f64-param: func(x: future<f64>);

future-ret: func(x: future);
future-ret: func() -> future;
future-u8-ret: func() -> future<u8>;
future-u16-ret: func() -> future<u16>;
future-u32-ret: func() -> future<u32>;
Expand Down
2 changes: 2 additions & 0 deletions tests/codegen/streams.wit
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ interface transmit {
}

interface streams {
stream-param: func(x: stream);
stream-u8-param: func(x: stream<u8>);
stream-u16-param: func(x: stream<u16>);
stream-u32-param: func(x: stream<u32>);
Expand All @@ -26,6 +27,7 @@ interface streams {
stream-f32-param: func(x: stream<f32>);
stream-f64-param: func(x: stream<f64>);

stream-ret: func() -> stream;
stream-u8-ret: func() -> stream<u8>;
stream-u16-ret: func() -> stream<u16>;
stream-u32-ret: func() -> stream<u32>;
Expand Down
Loading