| 1 | # futures-micro |
| 2 | |
| 3 | [](https://github.com/irrustible/futures-micro/blob/main/LICENSE) |
| 4 | [](https://crates.io/crates/futures-micro) |
| 5 | [](https://docs.rs/futures-micro) |
| 6 | |
| 7 | To futures-lite as futures-lite is to futures: smaller. |
| 8 | |
| 9 | Features: |
| 10 | * Fun tools to write everything as async fns. |
| 11 | * Tiny, with a single dependency. |
| 12 | * 100% `no_std` support, no heap allocation required! |
| 13 | * Complete stable compiler support - Uses no nightly features! |
| 14 | |
| 15 | * Bootstrap tools: |
| 16 | * `poll_fn` - wrap a function into a future. |
| 17 | * `pin!()` - pin a value to the stack. |
| 18 | * Futures interface subversion (poll interface from async fns): |
| 19 | * `waker()` to get the current waker. |
| 20 | * `sleep()` to wait until you are woken. |
| 21 | * Common stuff: |
| 22 | * `yield_once()` - lets some other futures do some work . |
| 23 | * `or()` - return the result of the first future to complete. |
| 24 | * `or!()` - `or()`, but varargs. |
| 25 | * `zip()` - return the result of both futures when they both complete. |
| 26 | * `zip!()` - `zip()`, but varargs. |
| 27 | * `ready!()` - unwraps a ready value or returns pending. |
| 28 | |
| 29 | ## Status |
| 30 | |
| 31 | Beta? The API we have here seems pretty reasonable now. |
| 32 | |
| 33 | If there's something you're missing, you may be looking for |
| 34 | [futures-lite](https://github.com/smol-rs/futures-lite). |
| 35 | |
| 36 | ## Missing/Removed APIs |
| 37 | |
| 38 | There are many APIs you will *not* find in this crate. Some are absent to keep the crate small and quick to compile, others used to be here but have since been removed. These are: |
| 39 | |
| 40 | * `pending()` - never completes, now in libcore as `core::future::pending()` |
| 41 | * `ready()` - completes on first poll, now in libcore as `core::future::ready()` |
| 42 | * `poll_state` - wrap a function and some state into a future. |
| 43 | ```rust |
| 44 | /// outdated |
| 45 | poll_state(INITIAL, |state, ctx| {...}).await |
| 46 | |
| 47 | /// replacement (NOTE: `*state` should be replaced by `state`) |
| 48 | let mut state = INITIAL; |
| 49 | poll_fn(move |ctx| { ... }).await |
| 50 | ``` |
| 51 | |
| 52 | ## Changelog |
| 53 | |
| 54 | ### 0.5.0 - 2021-03-13 |
| 55 | |
| 56 | * Switch to using `pin-project-lite` for pin projections, removing |
| 57 | most of the unsafe code. |
| 58 | * Removed `next_poll`. It wasn't very useful and our implementation |
| 59 | may not have been sound. This may explain why I can't find it in `futures-lite`. |
| 60 | |
| 61 | ## Copyright and License |
| 62 | |
| 63 | Copyright (c) 2020 James Laver, Matthieu le Brazidec, Stjepan Glavina, Erik Zscheile, |
| 64 | futures-micro contributors, futures-lite contributors |
| 65 | |
| 66 | [Licensed](LICENSE) under Apache License, Version 2.0 (https://www.apache.org/licenses/LICENSE-2.0), |
| 67 | with LLVM Exceptions (https://spdx.org/licenses/LLVM-exception.html). |
| 68 | |
| 69 | Unless you explicitly state otherwise, any contribution intentionally submitted |
| 70 | for inclusion in the work by you, as defined in the Apache-2.0 license, shall be |
| 71 | licensed as above, without any additional terms or conditions. |