1 mod bindings {
2     wit_bindgen::generate!({
3         path: "../misc/component-async-tests/wit",
4         world: "read-resource-stream",
5     });
6 
7     use super::Component;
8     export!(Component);
9 }
10 
11 use bindings::{exports::local::local::run::Guest, local::local::resource_stream};
12 
13 struct Component;
14 
15 impl Guest for Component {
16     async fn run() {
17         let mut count = 7;
18         let mut stream = resource_stream::foo(count).await;
19 
20         while let Some(x) = stream.next().await {
21             if count > 0 {
22                 count -= 1;
23             } else {
24                 panic!("received too many items");
25             }
26 
27             x.foo()
28         }
29 
30         if count != 0 {
31             panic!("received too few items");
32         }
33     }
34 }
35 
36 // Unused function; required since this file is built as a `bin`:
37 fn main() {}
38