| Crates.io | n0-future |
| lib.rs | n0-future |
| version | 0.2.0 |
| created_at | 2025-01-27 12:13:35.318352+00 |
| updated_at | 2025-07-28 12:56:14.776141+00 |
| description | Number 0's way of doing rust futures. Re-exports what we think are useful abstractions and good implementations. |
| homepage | |
| repository | https://github.com/n0-computer/n0-future |
| max_upload_size | |
| id | 1532353 |
| size | 115,690 |
number 0's way of doing async rust.
This crate is supposed to fulfill two purposes:
future-related codeWe re-expose futures-lite, futures-buffered and futures-util (but mostly for Sink and its combinators).
If you're wondering why we're not re-exposing/using X Y or Z, please first read our article about some of our challenges with async rust: https://www.iroh.computer/blog/async-rust-challenges-in-iroh
Writing code that works in the wasm*-*-unknown targets is not easy:
std::time::Instant::now() panics on usewasm-bindgen (practically your only option), structs like JsValue are !Send.We aim to solve these issues by providing similar-looking APIs that are easy to #[cfg(...)] between Wasm and non-wasm targets, ideally not requiring any cfg at all, but instead the cfg-ing is limited to happen inside this library only.
We do this in a couple of ways:
n0_future::time re-exports tokio::time::Instant and friends natively, but web_time::Instant and friends in Wasm.n0_future::task re-exports tokio with its spawn, JoinHandle, JoinSet, Sleep, Timeout, Interval, etc. utilities, but in Wasm re-exports a very similar API that's based on wasm-bindgen-futures.Send, while re-exports in browsers are !Send. There's quickly a need for utilities such as n0_future::boxed which re-exports Box<dyn Future + Send> natively, but just Box<dyn Future> in Wasm (and the same for Stream).It's entirely possible that we'll expand the scope of this library, that currently is mostly a re-exports crate to a crate that provides our own flavor of async APIs that we deem are safer to use, we write about some of these ideas in this issue: https://github.com/n0-computer/iroh/issues/2979
git-cliff, cargo-release and cargo-semver-checks installed.cargo semver-checks check-release --release-type=major/minor/patch and see which one fitscargo release major/minor/patch to check if the release would go through well.cargo release major/minor/patch --execute to run the releaseCopyright 2024 N0, INC.
This project is licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this project by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.