coroflow

Crates.iocoroflow
lib.rscoroflow
version0.1.1
created_at2025-12-06 08:05:40.531759+00
updated_at2025-12-06 09:38:44.46824+00
descriptionComposable coroutine utilities and flow abstractions built on top of Rust's async ecosystem
homepage
repositoryhttps://github.com/samoylenkodmitry/rs-coroutine-rs-flow
max_upload_size
id1969808
size102,410
Dmitry Samoylenko (samoylenkodmitry)

documentation

README

coroflow

Composable Flow utilities inspired by Kotlin's Flow API, built on top of rs_coroutine_core for coroutine-style structured concurrency in Rust.

Features

  • Cold Flow<T> builders that only execute when collected.
  • Hot SharedFlow<T> and StateFlow<T> for broadcasting values.
  • Rich operators including map, filter, take, buffer, flow_on, and flat_map_latest.
  • Conversion from suspending computations via SuspendingExt::as_flow.

Installation

Add coroflow and its companion runtime to your Cargo.toml:

[dependencies]
rs_coroutine_core = "0.1.1"
coroflow = "0.1.1"
tokio = { version = "1.35", features = ["full"] }

Example

Create and collect a simple flow with operators:

use coroflow::{flow, FlowExt};

#[tokio::main]
async fn main() {
    let numbers = flow(|collector| async move {
        for i in 1..=5 {
            collector.emit(i).await;
        }
    });

    numbers
        .map(|x| async move { x * 2 })
        .filter(|x| {
            let x = *x;
            async move { x > 5 }
        })
        .collect(|x| async move {
            println!("Value: {}", x);
        })
        .await;
}

For more examples, run cargo run --example basic_usage from the workspace root.

License

MIT OR Apache-2.0

Commit count: 0

cargo fmt