safina-select

crates.io version license: Apache 2.0 unsafe forbidden pipeline status

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

Limitations

Examples

rust use safina_async_test::async_test; use safina_select::{select_ab, OptionAb}; let conn = match select_ab(make_new(addr.clone()), get_from_pool(addr.clone())).await { OptionAb::A(result) => result?, OptionAb::B(result) => result?, }; // When both futures return the same type, you can use `take`: let conn = select_ab(make_new(addr.clone()), get_from_pool(addr.clone())).await.take()?; rust use safina_async_test::async_test; use safina_select::{select_ab, OptionAb}; safina_timer::start_timer_thread(); let data = match select_ab(read_data(), safina_timer::sleep_until(deadline)).await { OptionAb::A(result) => Ok(result?), OptionAb::B(()) => Err("timeout"), };

Documentation

https://docs.rs/safina-select

TO DO - Alternatives

Changelog

TO DO

Release Process

  1. Edit Cargo.toml and bump version number.
  2. Run ./release.sh

License: Apache-2.0