Path: blob/main/crates/test-programs/src/bin/async_read_resource_stream.rs
1693 views
mod bindings {1wit_bindgen::generate!({2path: "../misc/component-async-tests/wit",3world: "read-resource-stream",4});56use super::Component;7export!(Component);8}910use bindings::{exports::local::local::run::Guest, local::local::resource_stream};1112struct Component;1314impl Guest for Component {15async fn run() {16let mut count = 7;17let mut stream = resource_stream::foo(count);1819while let Some(x) = stream.next().await {20if count > 0 {21count -= 1;22} else {23panic!("received too many items");24}2526x.foo()27}2829if count != 0 {30panic!("received too few items");31}32}33}3435// Unused function; required since this file is built as a `bin`:36fn main() {}373839