Expand description
Concurrent execution of streams
§Examples
Concurrently process items in a collection
use futures_concurrency::prelude::*;
let v: Vec<_> = vec!["chashu", "nori"]
.into_co_stream()
.map(|msg| async move { format!("hello {msg}") })
.collect()
.await;
assert_eq!(v, &["hello chashu", "hello nori"]);
Concurrently process items in a stream
use futures_concurrency::prelude::*;
use futures_lite::stream;
let v: Vec<_> = stream::repeat("chashu")
.co()
.take(2)
.map(|msg| async move { format!("hello {msg}") })
.collect()
.await;
assert_eq!(v, &["hello chashu", "hello chashu"]);
Structs§
- Enumerate
- A concurrent iterator that yields the current count and the element during iteration.
- From
Stream - A concurrent for each implementation from a
Stream
- Limit
- A concurrent iterator that limits the amount of concurrency applied.
- Map
- Convert items from one type into another
- Take
- A concurrent iterator that only iterates over the first
n
iterations ofiter
.
Enums§
- Consumer
State - The state of the consumer, used to communicate back to the source.
Traits§
- Concurrent
Stream - Concurrently operate over items in a stream
- Consumer
- Describes a type which can receive data.
- From
Concurrent Stream - Conversion from a
ConcurrentStream
- Into
Concurrent Stream - Conversion into a
ConcurrentStream