safina-select
This is a Rust library for awaiting multiple futures and getting the value of the first one that completes.
It is part of safina
, a safe async runtime.
Features
forbid(unsafe_code)
- Depends only on
std
- Good test coverage (92%)
- Works with
safina-executor
or any async executor
Limitations
- Can await 2-5 futures. Nest them if you need more.
Examples
use async_test;
use ;
let conn = match select_ab.await ;
// When both futures return the same type, you can use `take`:
let conn = select_ab.await.take?;
use async_test;
use ;
start_timer_thread;
let data = match select_ab.await ;
Documentation
TO DO - Alternatives
- tokio::select
- very popular
- Fast
- internally incredibly complicated
- full of
unsafe
- futures::select
- very popular
- proc macro, very complicated
- contains a little
unsafe
code
Release Process
- Edit
Cargo.toml
and bump version number. - Run
./release.sh
Changelog
- v0.1.1 - Add badges to readme. Rename
safina
package tosafina-executor
. - v0.1.0 - First published version
TO DO
- DONE - Implement
sleep_ab
- DONE - Add tests
- DONE - Add docs
- DONE - Add
sleep_abc
,sleep_abcd
, andsleep_abcde
- DONE - Publish on crates.io
License: Apache-2.0