futures_util/
lib.rs

1//! Combinators and utilities for working with `Future`s, `Stream`s, `Sink`s,
2//! and the `AsyncRead` and `AsyncWrite` traits.
3
4#![no_std]
5#![deny(missing_docs, missing_debug_implementations, warnings)]
6#![doc(html_root_url = "https://docs.rs/futures/0.1")]
7
8#[cfg(test)]
9extern crate futures_channel;
10#[macro_use]
11extern crate futures_core;
12#[cfg(test)]
13extern crate futures_executor;
14extern crate futures_io;
15extern crate futures_sink;
16extern crate either;
17
18#[cfg(feature = "std")]
19use futures_core::{Async, Future, Poll, task};
20
21macro_rules! if_std {
22    ($($i:item)*) => ($(
23        #[cfg(feature = "std")]
24        $i
25    )*)
26}
27
28#[cfg(feature = "std")]
29#[macro_use]
30extern crate std;
31
32macro_rules! delegate_sink {
33    ($field:ident) => {
34        fn poll_ready(&mut self, cx: &mut task::Context) -> Poll<(), Self::SinkError> {
35            self.$field.poll_ready(cx)
36        }
37
38        fn start_send(&mut self, item: Self::SinkItem) -> Result<(), Self::SinkError> {
39            self.$field.start_send(item)
40        }
41
42        fn poll_flush(&mut self, cx: &mut task::Context) -> Poll<(), Self::SinkError> {
43            self.$field.poll_flush(cx)
44        }
45
46        fn poll_close(&mut self, cx: &mut task::Context) -> Poll<(), Self::SinkError> {
47            self.$field.poll_close(cx)
48        }
49
50    }
51}
52
53#[cfg(all(feature = "std", any(test, feature = "bench")))]
54pub mod lock;
55#[cfg(all(feature = "std", not(any(test, feature = "bench"))))]
56mod lock;
57
58pub mod future;
59pub use future::FutureExt;
60
61#[cfg(feature = "std")]
62pub mod io;
63#[cfg(feature = "std")]
64pub use io::{AsyncReadExt, AsyncWriteExt};
65
66pub mod stream;
67pub use stream::StreamExt;
68
69pub mod sink;
70pub use sink::SinkExt;
71
72pub mod prelude {
73    //! Prelude containing the extension traits, which add functionality to
74    //! existing asynchronous types.
75    pub use {FutureExt, StreamExt, SinkExt};
76    #[cfg(feature = "std")]
77    pub use {AsyncReadExt, AsyncWriteExt};
78}