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)]
13 pub use core::future::Future;
14 
15 #[cfg(feature = "alloc")]
16 pub use futures_core::future::{BoxFuture, LocalBoxFuture};
17 pub use futures_core::future::{FusedFuture, TryFuture};
18 pub use futures_task::{FutureObj, LocalFutureObj, UnsafeFutureObj};
19 
20 // Extension traits and combinators
21 #[allow(clippy::module_inception)]
22 mod future;
23 pub 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)")]
28 pub use self::future::FlattenStream;
29 
30 #[cfg(feature = "std")]
31 pub use self::future::CatchUnwind;
32 
33 #[cfg(feature = "channel")]
34 #[cfg_attr(docsrs, doc(cfg(feature = "channel")))]
35 #[cfg(feature = "std")]
36 pub use self::future::{Remote, RemoteHandle};
37 
38 #[cfg(feature = "std")]
39 pub use self::future::{Shared, WeakShared};
40 
41 mod try_future;
42 pub 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")))]
49 pub use self::try_future::FlattenSink;
50 
51 // Primitive futures
52 
53 mod lazy;
54 pub use self::lazy::{lazy, Lazy};
55 
56 mod pending;
57 pub use self::pending::{pending, Pending};
58 
59 mod maybe_done;
60 pub use self::maybe_done::{maybe_done, MaybeDone};
61 
62 mod try_maybe_done;
63 pub use self::try_maybe_done::{try_maybe_done, TryMaybeDone};
64 
65 mod option;
66 pub use self::option::OptionFuture;
67 
68 mod poll_fn;
69 pub use self::poll_fn::{poll_fn, PollFn};
70 
71 mod poll_immediate;
72 pub use self::poll_immediate::{poll_immediate, PollImmediate};
73 
74 mod ready;
75 pub use self::ready::{err, ok, ready, Ready};
76 
77 mod join;
78 pub use self::join::{join, join3, join4, join5, Join, Join3, Join4, Join5};
79 
80 #[cfg(feature = "alloc")]
81 mod join_all;
82 #[cfg(feature = "alloc")]
83 pub use self::join_all::{join_all, JoinAll};
84 
85 mod select;
86 pub use self::select::{select, Select};
87 
88 #[cfg(feature = "alloc")]
89 mod select_all;
90 #[cfg(feature = "alloc")]
91 pub use self::select_all::{select_all, SelectAll};
92 
93 mod try_join;
94 pub use self::try_join::{
95     try_join, try_join3, try_join4, try_join5, TryJoin, TryJoin3, TryJoin4, TryJoin5,
96 };
97 
98 #[cfg(feature = "alloc")]
99 mod try_join_all;
100 #[cfg(feature = "alloc")]
101 pub use self::try_join_all::{try_join_all, TryJoinAll};
102 
103 mod try_select;
104 pub use self::try_select::{try_select, TrySelect};
105 
106 #[cfg(feature = "alloc")]
107 mod select_ok;
108 #[cfg(feature = "alloc")]
109 pub use self::select_ok::{select_ok, SelectOk};
110 
111 mod either;
112 pub use self::either::Either;
113 
114 #[cfg(not(futures_no_atomic_cas))]
115 #[cfg(feature = "alloc")]
116 mod abortable;
117 #[cfg(not(futures_no_atomic_cas))]
118 #[cfg(feature = "alloc")]
119 pub use crate::abortable::{AbortHandle, AbortRegistration, Abortable, Aborted};
120 #[cfg(not(futures_no_atomic_cas))]
121 #[cfg(feature = "alloc")]
122 pub use abortable::abortable;
123 
124 // Just a helper function to ensure the futures we're returning all have the
125 // right implementations.
assert_future<T, F>(future: F) -> F where F: Future<Output = T>,126 pub(crate) fn assert_future<T, F>(future: F) -> F
127 where
128     F: Future<Output = T>,
129 {
130     future
131 }
132