Module concurrent_stream

Source
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.
FromStream
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 of iter.

Enums§

ConsumerState
The state of the consumer, used to communicate back to the source.

Traits§

ConcurrentStream
Concurrently operate over items in a stream
Consumer
Describes a type which can receive data.
FromConcurrentStream
Conversion from a ConcurrentStream
IntoConcurrentStream
Conversion into a ConcurrentStream