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 ready;
72 pub use self::ready::{err, ok, ready, Ready};
73 
74 mod join;
75 pub use self::join::{join, join3, join4, join5, Join, Join3, Join4, Join5};
76 
77 #[cfg(feature = "alloc")]
78 mod join_all;
79 #[cfg(feature = "alloc")]
80 pub use self::join_all::{join_all, JoinAll};
81 
82 mod select;
83 pub use self::select::{select, Select};
84 
85 #[cfg(feature = "alloc")]
86 mod select_all;
87 #[cfg(feature = "alloc")]
88 pub use self::select_all::{select_all, SelectAll};
89 
90 mod try_join;
91 pub use self::try_join::{
92     try_join, try_join3, try_join4, try_join5, TryJoin, TryJoin3, TryJoin4, TryJoin5,
93 };
94 
95 #[cfg(feature = "alloc")]
96 mod try_join_all;
97 #[cfg(feature = "alloc")]
98 pub use self::try_join_all::{try_join_all, TryJoinAll};
99 
100 mod try_select;
101 pub use self::try_select::{try_select, TrySelect};
102 
103 #[cfg(feature = "alloc")]
104 mod select_ok;
105 #[cfg(feature = "alloc")]
106 pub use self::select_ok::{select_ok, SelectOk};
107 
108 mod either;
109 pub use self::either::Either;
110 
111 #[cfg(not(futures_no_atomic_cas))]
112 #[cfg(feature = "alloc")]
113 mod abortable;
114 #[cfg(not(futures_no_atomic_cas))]
115 #[cfg(feature = "alloc")]
116 pub use crate::abortable::{AbortHandle, AbortRegistration, Abortable, Aborted};
117 #[cfg(not(futures_no_atomic_cas))]
118 #[cfg(feature = "alloc")]
119 pub use abortable::abortable;
120 
121 // Just a helper function to ensure the futures we're returning all have the
122 // right implementations.
assert_future<T, F>(future: F) -> F where F: Future<Output = T>,123 pub(crate) fn assert_future<T, F>(future: F) -> F
124 where
125     F: Future<Output = T>,
126 {
127     future
128 }
129