1//! Asynchronous values.
2//!
3//! This module contains:
4//!
5//! - The [`Future`] trait.
6//! - The [`FutureExt`] and [`TryFutureExt`] trait, which provides adapters for
7//! chaining and composing futures.
8//! - Top-level future combinators like [`lazy`](lazy()) which creates a future
9//! from a closure that defines its return value, and [`ready`](ready()),
10//! which constructs a future with an immediate defined value.
11
12#[doc(no_inline)]
13pub use core::future::Future;
14
15#[cfg(feature = "alloc")]
16pub use futures_core::future::{BoxFuture, LocalBoxFuture};
17pub use futures_core::future::{FusedFuture, TryFuture};
18pub use futures_task::{FutureObj, LocalFutureObj, UnsafeFutureObj};
19
20// Extension traits and combinators
21#[allow(clippy::module_inception)]
22mod future;
23pub use self::future::{
24 Flatten, Fuse, FutureExt, Inspect, IntoStream, Map, MapInto, NeverError, Then, UnitError,
25};
26
27#[deprecated(note = "This is now an alias for [Flatten](Flatten)")]
28pub use self::future::FlattenStream;
29
30#[cfg(feature = "std")]
31pub use self::future::CatchUnwind;
32
33#[cfg(feature = "channel")]
34#[cfg_attr(docsrs, doc(cfg(feature = "channel")))]
35#[cfg(feature = "std")]
36pub use self::future::{Remote, RemoteHandle};
37
38#[cfg(feature = "std")]
39pub use self::future::{Shared, WeakShared};
40
41mod try_future;
42pub use self::try_future::{
43 AndThen, ErrInto, InspectErr, InspectOk, IntoFuture, MapErr, MapOk, MapOkOrElse, OkInto,
44 OrElse, TryFlatten, TryFlattenStream, TryFutureExt, UnwrapOrElse,
45};
46
47#[cfg(feature = "sink")]
48#[cfg_attr(docsrs, doc(cfg(feature = "sink")))]
49pub use self::try_future::FlattenSink;
50
51// Primitive futures
52
53mod lazy;
54pub use self::lazy::{lazy, Lazy};
55
56mod pending;
57pub use self::pending::{pending, Pending};
58
59mod maybe_done;
60pub use self::maybe_done::{maybe_done, MaybeDone};
61
62mod try_maybe_done;
63pub use self::try_maybe_done::{try_maybe_done, TryMaybeDone};
64
65mod option;
66pub use self::option::OptionFuture;
67
68mod poll_fn;
69pub use self::poll_fn::{poll_fn, PollFn};
70
71mod poll_immediate;
72pub use self::poll_immediate::{poll_immediate, PollImmediate};
73
74mod ready;
75pub use self::ready::{err, ok, ready, Ready};
76
77mod join;
78pub use self::join::{join, join3, join4, join5, Join, Join3, Join4, Join5};
79
80#[cfg(feature = "alloc")]
81mod join_all;
82#[cfg(feature = "alloc")]
83pub use self::join_all::{join_all, JoinAll};
84
85mod select;
86pub use self::select::{select, Select};
87
88#[cfg(feature = "alloc")]
89mod select_all;
90#[cfg(feature = "alloc")]
91pub use self::select_all::{select_all, SelectAll};
92
93mod try_join;
94pub use self::try_join::{
95 try_join, try_join3, try_join4, try_join5, TryJoin, TryJoin3, TryJoin4, TryJoin5,
96};
97
98#[cfg(feature = "alloc")]
99mod try_join_all;
100#[cfg(feature = "alloc")]
101pub use self::try_join_all::{try_join_all, TryJoinAll};
102
103mod try_select;
104pub use self::try_select::{try_select, TrySelect};
105
106#[cfg(feature = "alloc")]
107mod select_ok;
108#[cfg(feature = "alloc")]
109pub use self::select_ok::{select_ok, SelectOk};
110
111mod either;
112pub use self::either::Either;
113
114#[cfg_attr(target_os = "none", cfg(target_has_atomic = "ptr"))]
115#[cfg(feature = "alloc")]
116mod abortable;
117#[cfg_attr(target_os = "none", cfg(target_has_atomic = "ptr"))]
118#[cfg(feature = "alloc")]
119pub use crate::abortable::{AbortHandle, AbortRegistration, Abortable, Aborted};
120#[cfg_attr(target_os = "none", cfg(target_has_atomic = "ptr"))]
121#[cfg(feature = "alloc")]
122pub use abortable::abortable;
123
124// Just a helper function to ensure the futures we're returning all have the
125// right implementations.
126pub(crate) fn assert_future<T, F>(future: F) -> F
127where
128 F: Future<Output = T>,
129{
130 future
131}
132