futures_concurrency

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§

  • A concurrent iterator that yields the current count and the element during iteration.
  • A concurrent for each implementation from a Stream
  • A concurrent iterator that limits the amount of concurrency applied.
  • Convert items from one type into another
  • A concurrent iterator that only iterates over the first n iterations of iter.

Enums§

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

Traits§