futures-async-stream
Async stream API experiment that may be introduced as a language feature in the future.
This crate provides useful features for streams, using unstable async_await
and generators
.
Usage
Add this to your Cargo.toml
:
[]
= "0.1.0-alpha.1"
= "0.3.0-alpha.17"
The current futures-async-stream requires Rust nightly 2019-07-02 or later.
#[for_await]
Processes streams using a for loop.
This is a reimplement of [futures-await]'s #[async]
for loops for futures 0.3 and is an experimental implementation of the idea listed as the next step of async/await.
use *;
use for_await;
async
value
has the Item
type of the stream passed in. Note that async for loops can only be used inside of async
functions, closures, blocks, #[async_stream]
functions and async_stream_block!
macros.
#[async_stream]
Creates streams via generators.
This is a reimplement of [futures-await]'s #[async_stream]
for futures 0.3 and is an experimental implementation of the idea listed as the next step of async/await.
use *;
use async_stream;
// Returns a stream of i32
async
#[async_stream]
must have an item type specified via item = some::Path
and the values output from the stream must be yielded via the yield
expression.
License
Licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.