Asynchronous streams for Rust
Asynchronous stream of elements.
Provides two macros,
try_stream!, allowing the caller to
define asynchronous streams of elements. These are implemented using
await notation. This crate works without unstable features.
stream! macro returns an anonymous type implementing the
Item associated type is the type of the values yielded from the
try_stream! also returns an anonymous type implementing the
Stream trait, but the
Item associated type is
Result<T, Error>. The
try_stream! macro supports using
? notation as part of the
A basic stream yielding numbers. Values are yielded using the
keyword. The stream block must return
Streams may be returned by using
impl Stream<Item = T>:
Streams may be implemented in terms of other streams -
syntax to assist with this:
Rust try notation (
?) can be used with the
try_stream! macro. The
of the returned stream is
Ok being the value yielded and
Err the error type returned by
try_stream! macros are implemented using proc macros.
The macro searches the syntax tree for instances of
yield $expr and
transforms them into
The stream uses a lightweight sender to send values from the stream
implementation to the caller. When entering the stream, an
stored on the stack. A pointer to the cell is stored in a thread local and
poll is called on the async block. When
sender.send(value) stores the value that cell and yields back to the
Supported Rust Versions
The current minimum supported Rust version is 1.56.
This project is licensed under the MIT license.
Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in
async-stream by you, shall be licensed as MIT, without any
additional terms or conditions.