Lines Matching +full:is +full:- +full:stream
3 Asynchronous stream of elements.
5 Provides two macros, `stream!` and `try_stream!`, allowing the caller to
9 The `stream!` macro returns an anonymous type implementing the [`Stream`]
10 trait. The `Item` associated type is the type of the values yielded from the
11 stream. The `try_stream!` also returns an anonymous type implementing the
12 [`Stream`] trait, but the `Item` associated type is `Result<T, Error>`. The
18 A basic stream yielding numbers. Values are yielded using the `yield`
19 keyword. The stream block must return `()`.
22 use async_stream::stream;
25 use futures_util::stream::StreamExt;
29 let s = stream! {
43 Streams may be returned by using `impl Stream<Item = T>`:
46 use async_stream::stream;
48 use futures_core::stream::Stream;
50 use futures_util::stream::StreamExt;
52 fn zero_to_three() -> impl Stream<Item = u32> {
53 stream! {
71 Streams may be implemented in terms of other streams - `async-stream` provides `for await`
75 use async_stream::stream;
77 use futures_core::stream::Stream;
79 use futures_util::stream::StreamExt;
81 fn zero_to_three() -> impl Stream<Item = u32> {
82 stream! {
89 fn double<S: Stream<Item = u32>>(input: S)
90 -> impl Stream<Item = u32>
92 stream! {
111 of the returned stream is `Result` with `Ok` being the value yielded and
118 use futures_core::stream::Stream;
124 -> impl Stream<Item = io::Result<TcpStream>>
130 let (stream, addr) = listener.accept().await?;
132 yield stream;
140 The `stream!` and `try_stream!` macros are implemented using proc macros.
144 The stream uses a lightweight sender to send values from the stream
145 implementation to the caller. When entering the stream, an `Option<T>` is
146 stored on the stack. A pointer to the cell is stored in a thread local and
147 `poll` is called on the async block. When `poll` returns.
151 [`Stream`]: https://docs.rs/futures-core/*/futures_core/stream/trait.Stream.html
155 The current minimum supported Rust version is 1.56.
159 This project is licensed under the [MIT license](LICENSE).
164 for inclusion in `async-stream` by you, shall be licensed as MIT, without any