Ended up doing
async fn process_parallel() -> Result<(), MyError> {
let mut par_things = FuturesUnordered::new();
// ...
par_things.push(async move {
// ...
});
while let Some(data_result) = par_things.next().await {
let _ = data_result?;
}
}
These posts contained some further helpful tips that I will be looking at shortly:
- Asynchronous streams in Rust (part 1) - Futures, buffering and mysterious compilation error messages | Blog | Guillaume Endignoux
- Batch execution of futures in the tokio runtime (or max number of active futures at a time) - #4 by alice
Thanks for the input, everyone!