@@ -132,12 +132,14 @@ use the <code>subscribe</code> function to obtain a <a href="#pollable"><code>po
132132for using <code >wasi: io /poll</code >.</p >
133133<h4 ><a name =" output_stream " ><code >resource output-stream</code ></a ></h4 >
134134<p >An output bytestream.</p >
135- <h2 ><a href =" #output_stream " ><code >output-stream</code ></a >s are <em >non-blocking</em > to the extent practical on
135+ <p ><a href =" #output_stream " ><code >output-stream</code ></a >s are <em >non-blocking</em > to the extent practical on
136136underlying platforms. Except where specified otherwise, I/O operations also
137137always return promptly, after the number of bytes that can be written
138138promptly, which could even be zero. To wait for the stream to be ready to
139139accept data, the <code >subscribe</code > function to obtain a <a href =" #pollable " ><code >pollable</code ></a > which can be
140- polled for using <code >wasi: io /poll</code >.</h2 >
140+ polled for using <code >wasi: io /poll</code >.</p >
141+ <h4 ><a name =" future_forward_result " ><code >resource future-forward-result</code ></a ></h4 >
142+ <h2 >Represents a future which may eventually return trailers, or an error.</h2 >
141143<h3 >Functions</h3 >
142144<h4 ><a name =" method_input_stream.read " ><code >[method]input-stream.read: func</code ></a ></h4 >
143145<p >Perform a non-blocking read from the stream.</p >
@@ -418,3 +420,56 @@ is ready for reading, before performing the <code>splice</code>.</p>
418420<ul >
419421<li ><a name =" method_output_stream.blocking_splice.0 " ></a > result< ; <code >u64</code >, <a href =" #stream_error " ><a href =" #stream_error " ><code >stream-error</code ></a ></a >> ; </li >
420422</ul >
423+ <h4 ><a name =" forward " ><code >forward: func</code ></a ></h4 >
424+ <p >Continuously read all data from the input stream and write it to the
425+ output stream.</p >
426+ <p >Forwarding is done on a background task. The tasks runs until either
427+ stream closes or fails. After that, the streams are dropped and the
428+ returned future is resolved. Dropping the future before it has been
429+ resolved aborts the background task and drops the streams.</p >
430+ <p >The future resolves with the reason that caused the forwarding to terminate.
431+ In case one of the streams ended normally, this will be <a href =" #stream_error.closed " ><code >stream-error::closed</code ></a >.</p >
432+ <p >This function requires exclusive access to the provided streams,
433+ yet it does not change the ownership structure of them. I.e. they remain
434+ children of their parent resources. If the parents place any lifetimes
435+ restrictions on their children, those continue to apply.</p >
436+ <h5 >Params</h5 >
437+ <ul >
438+ <li ><a name =" forward.src " ><code >src</code ></a >: own< ; <a href =" #input_stream " ><a href =" #input_stream " ><code >input-stream</code ></a ></a >> ; </li >
439+ <li ><a name =" forward.dst " ><code >dst</code ></a >: own< ; <a href =" #output_stream " ><a href =" #output_stream " ><code >output-stream</code ></a ></a >> ; </li >
440+ </ul >
441+ <h5 >Return values</h5 >
442+ <ul >
443+ <li ><a name =" forward.0 " ></a > own< ; <a href =" #future_forward_result " ><a href =" #future_forward_result " ><code >future-forward-result</code ></a ></a >> ; </li >
444+ </ul >
445+ <h4 ><a name =" method_future_forward_result.subscribe " ><code >[method]future-forward-result.subscribe: func</code ></a ></h4 >
446+ <p >Returns a pollable which becomes ready when either the result is
447+ available. When this pollable is ready, the <code >get</code > method will return
448+ <code >some</code >.</p >
449+ <h5 >Params</h5 >
450+ <ul >
451+ <li ><a name =" method_future_forward_result.subscribe.self " ><code >self</code ></a >: borrow< ; <a href =" #future_forward_result " ><a href =" #future_forward_result " ><code >future-forward-result</code ></a ></a >> ; </li >
452+ </ul >
453+ <h5 >Return values</h5 >
454+ <ul >
455+ <li ><a name =" method_future_forward_result.subscribe.0 " ></a > own< ; <a href =" #pollable " ><a href =" #pollable " ><code >pollable</code ></a ></a >> ; </li >
456+ </ul >
457+ <h4 ><a name =" method_future_forward_result.get " ><code >[method]future-forward-result.get: func</code ></a ></h4 >
458+ <p >Get the resolved value.</p >
459+ <p >Returns:</p >
460+ <ul >
461+ <li ><code >none</code >: when the future hasn't resolved yet. Use <code >subscribe</code > to wait
462+ for its completion.</li >
463+ <li ><code >some(error(_))</code >: when the future is resolved, but the result value
464+ has already been taken before.</li >
465+ <li ><code >some(ok(value))</code >: when the future is ready with a value. This is
466+ returned only once.</li >
467+ </ul >
468+ <h5 >Params</h5 >
469+ <ul >
470+ <li ><a name =" method_future_forward_result.get.self " ><code >self</code ></a >: borrow< ; <a href =" #future_forward_result " ><a href =" #future_forward_result " ><code >future-forward-result</code ></a ></a >> ; </li >
471+ </ul >
472+ <h5 >Return values</h5 >
473+ <ul >
474+ <li ><a name =" method_future_forward_result.get.0 " ></a > option< ; result< ; <a href =" #stream_error " ><a href =" #stream_error " ><code >stream-error</code ></a ></a >> ;> ; </li >
475+ </ul >
0 commit comments