pasts/lib.rs
1//! Minimal and simpler alternative to the futures crate.
2//!
3//! # Optional Features
4//! Only the _`std`_ feature is enabled by default
5//!
6//! - Disable _`std`_ to use pasts without the standard library.
7//! - Enable _`web`_ to use pasts within the javascript DOM.
8//!
9//! # Getting Started
10//!
11//! Add the following to your **`./Cargo.toml`**:
12//! ```toml
13//! [dependencies]
14//! pasts = "0.14"
15//!
16//! ## This example uses async_main for convenience, but it is *not* required to
17//! ## use pasts.
18//! async_main = { version = "0.4", features = ["pasts"] }
19//!
20//! ## This example uses async-std for a sleep future, but async-std is *not*
21//! ## required to use pasts.
22//! async-std = "1.12"
23//!
24//! ## Also not required for pasts, but allows for portability with WebAssembly
25//! ## in the browser.
26//! [features]
27//! web = ["async_main/web", "pasts/web"]
28//! ```
29//!
30//! ## Multi-Tasking On Multiple Iterators of Futures
31//! This example runs two timers in parallel using the `async-std` crate
32//! counting from 0 to 6. The "one" task will always be run for count 6 and
33//! stop the program, although which task will run for count 5 may be either
34//! "one" or "two" because they trigger at the same time.
35//!
36//! ```rust,no_run
37#![doc = include_str!("../examples/counter.rs")]
38//! ```
39
40#![cfg_attr(not(feature = "std"), no_std)]
41#![forbid(unsafe_code, missing_docs)]
42#![doc(
43 html_logo_url = "https://ardaku.github.io/mm/logo.svg",
44 html_favicon_url = "https://ardaku.github.io/mm/icon.svg",
45 html_root_url = "https://docs.rs/pasts"
46)]
47
48extern crate alloc;
49
50pub mod notify;
51
52mod r#loop;
53mod spawn;
54
55use self::prelude::*;
56pub use self::{
57 r#loop::Loop,
58 spawn::{Executor, Park, Pool},
59};
60
61pub mod prelude {
62 //! Items that are almost always needed.
63
64 #[doc(no_inline)]
65 pub use alloc::boxed::Box;
66 #[doc(no_inline)]
67 pub use core::{
68 future::Future,
69 pin::Pin,
70 task::{
71 Context as Task,
72 Poll::{Pending, Ready},
73 },
74 };
75
76 #[doc(no_inline)]
77 pub use crate::notify::{
78 BoxNotify, Fuse, LocalBoxNotify, Notify, NotifyExt,
79 };
80
81 /// Indicates whether a value is available or if the current task has been
82 /// scheduled to receive a wakeup instead.
83 pub type Poll<T = ()> = core::task::Poll<T>;
84}