File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -204,6 +204,20 @@ impl get_stream_async::Guest for Component {
204204 } ) ;
205205 Ok ( rx)
206206 }
207+
208+ async fn get_stream_stream_string (
209+ vals : Vec < String > ,
210+ ) -> Result < StreamReader < StreamReader < String > > , String > {
211+ let ( mut tx, rx) = wit_stream:: new ( ) ;
212+ wit_bindgen:: spawn ( async move {
213+ for v in vals {
214+ let ( mut nested_tx, nested_rx) = wit_stream:: new ( ) ;
215+ tx. write ( vec ! [ nested_rx] ) . await ;
216+ nested_tx. write ( vec ! [ v] ) . await ;
217+ }
218+ } ) ;
219+ Ok ( rx)
220+ }
207221}
208222
209223fn stream_values_async < T : StreamPayload > ( vals : Vec < T > ) -> Result < StreamReader < T > , String > {
Original file line number Diff line number Diff line change @@ -110,7 +110,8 @@ interface get-stream-async {
110110
111111 get-stream-example-resource-own-attr : async func (vals : list <example-resource >) -> result <stream <u32 >, string >;
112112
113- //get-stream-stream-string: async func(vals: list<stream<string>>) -> result<stream<stream<string>>, string>;
113+ get-stream-stream-string : async func (vals : list <string >) -> result <stream <stream <string >>, string >;
114+
114115 //get-stream-future-string: async func(vals: list<future<string>>) -> result<stream<future<string>>, string>;
115116}
116117
Original file line number Diff line number Diff line change @@ -345,6 +345,16 @@ suite("stream<T> lifts", () => {
345345 expectedValues : [ 2 , 1 , 0 ] ,
346346 } ) ;
347347 } ) ;
348+
349+ test ( "stream<string>" , async ( ) => {
350+ assert . instanceOf ( instance [ "jco:test-components/get-stream-async" ] . getStreamStreamString , AsyncFunction ) ;
351+ let vals = [ "first" , "third" , "second" ] ;
352+ let stream = await instance [ "jco:test-components/get-stream-async" ] . getStreamStreamString ( vals ) ;
353+ for ( const v of vals ) {
354+ const nestedStream = await stream . next ( ) ;
355+ assert . strictEqual ( v , await nestedStream . next ( ) ) ;
356+ }
357+ } ) ;
348358} ) ;
349359
350360async function checkStreamValues ( args ) {
You can’t perform that action at this time.
0 commit comments