| Crates.io | rs_coroutine_core |
| lib.rs | rs_coroutine_core |
| version | 0.1.1 |
| created_at | 2025-12-06 05:39:15.846113+00 |
| updated_at | 2025-12-06 09:38:39.341641+00 |
| description | Composable coroutine utilities and flow abstractions built on top of Rust's async ecosystem |
| homepage | |
| repository | https://github.com/samoylenkodmitry/rs-coroutine-rs-flow |
| max_upload_size | |
| id | 1969664 |
| size | 25,679 |
Core primitives for building coroutine-style asynchronous workflows in Rust with structured concurrency and dispatcher-aware execution.
CoroutineScope for lifecycle-managed coroutines and hierarchical cancellation.Tokio executors (Main, IO, Default) or custom executors.async_task and Deferred<T> for parallel work with join-style awaiting.CURRENT_SCOPE.suspend_block! macro for reusable suspending computations.Add the crate to your project:
[dependencies]
rs_coroutine_core = "0.1.1"
tokio = { version = "1.35", features = ["full"] }
Launch a coroutine and switch dispatchers for blocking work:
use rs_coroutine_core::{CoroutineScope, Dispatchers};
use std::sync::Arc;
#[tokio::main]
async fn main() {
let scope = Arc::new(CoroutineScope::new(Dispatchers::main()));
let job = scope.launch(async move {
let data = scope.with_dispatcher(Dispatchers::io(), async {
// Background work
"data".to_string()
}).await;
println!("Received: {}", data);
});
job.join().await;
}
For more examples, run cargo run --example basic_usage from the workspace root.
MIT OR Apache-2.0