2 releases
new 0.1.1 | Feb 20, 2025 |
---|---|
0.1.0 | Feb 20, 2025 |
#5 in #constructing
31 downloads per month
14KB
150 lines

Introduction
This is a helper library for automatically constructing a thread pool that communicates via message pipes. It is based on the flume
library that is used to communicate between threads.
The name ichika
comes from the character ichika in the game Blue Archive.
Still in development, the API may change in the future.
Quick Start
let pool = pipe! [
async |(name: String, checksum: Vec<u8>, url: String)| {
Ok((name, id, reqwest::get(url).await?))
},
|(name, checksum, buffer)| {
let mut sha3 = sha3::Sha3_256::new();
sha3.update(&buffer);
ensure!(sha3[..] == checksum, "oops!");
Ok((name, buffer))
},
|(name, buffer)| {
let mut decoder = flate2::read::GzDecoder::new();
let mut ret = vec![];
decoder.read_to_end(&mut ret)?;
Ok((name, data))
},
async |(name, data)| {
tokio::fs::write(
format!("./{name}.dat"),
&data
);
Ok(())
}
]?;
for i in 0..10 {
pool.send(("sth", vec![0; 32], "https://example.com".to_string()));
}
for i in 0..10 {
pool.recv().await?;
}
TODO
-
async
, includingtokio
andasync-std
. - Named task.
- Limit steps' thread usage.
- Multiple target
match
with any depth. - Error handle target
catch
. - Retryable target
retry
with timeout parameter.
Dependencies
~3–14MB
~180K SLoC