1804060c8SJoel Dice mod bindings { 2804060c8SJoel Dice wit_bindgen::generate!({ 3804060c8SJoel Dice path: "../misc/component-async-tests/wit", 4804060c8SJoel Dice world: "read-resource-stream", 5804060c8SJoel Dice }); 6804060c8SJoel Dice 7804060c8SJoel Dice use super::Component; 8804060c8SJoel Dice export!(Component); 9804060c8SJoel Dice } 10804060c8SJoel Dice 11804060c8SJoel Dice use bindings::{exports::local::local::run::Guest, local::local::resource_stream}; 12804060c8SJoel Dice 13804060c8SJoel Dice struct Component; 14804060c8SJoel Dice 15804060c8SJoel Dice impl Guest for Component { run()16804060c8SJoel Dice async fn run() { 17804060c8SJoel Dice let mut count = 7; 18*8992b99bSJoel Dice let mut stream = resource_stream::foo(count).await; 19804060c8SJoel Dice 20804060c8SJoel Dice while let Some(x) = stream.next().await { 21804060c8SJoel Dice if count > 0 { 22804060c8SJoel Dice count -= 1; 23804060c8SJoel Dice } else { 24804060c8SJoel Dice panic!("received too many items"); 25804060c8SJoel Dice } 26804060c8SJoel Dice 27804060c8SJoel Dice x.foo() 28804060c8SJoel Dice } 29804060c8SJoel Dice 30804060c8SJoel Dice if count != 0 { 31804060c8SJoel Dice panic!("received too few items"); 32804060c8SJoel Dice } 33804060c8SJoel Dice } 34804060c8SJoel Dice } 35804060c8SJoel Dice 36804060c8SJoel Dice // Unused function; required since this file is built as a `bin`: main()37804060c8SJoel Dicefn main() {} 38