summaryrefslogtreecommitdiffstats
path: root/tokio/src/io/util/mod.rs
diff options
context:
space:
mode:
authorCarl Lerche <me@carllerche.com>2019-11-18 07:00:55 -0800
committerGitHub <noreply@github.com>2019-11-18 07:00:55 -0800
commit0d38936b35779b604770120da2e98560bbb6241f (patch)
tree843d46e999becdb580cb02655b4290acadd64474 /tokio/src/io/util/mod.rs
parent13b6e9939e062dc01bcf34abe3d75de4b66e20e1 (diff)
chore: refine feature flags (#1785)
Removes dependencies between Tokio feature flags. For example, `process` should not depend on `sync` simply because it uses the `mpsc` channel. Instead, feature flags represent **public** APIs that become available with the feature enabled. When the feature is not enabled, the functionality is removed. If another Tokio component requires the functionality, it is stays as `pub(crate)`. The threaded scheduler is now exposed under `rt-threaded`. This feature flag only enables the threaded scheduler and does not include I/O, networking, or time. Those features must be explictly enabled. A `full` feature flag is added that enables all features. `stdin`, `stdout`, `stderr` are exposed under `io-std`. Macros are used to scope code by feature flag.
Diffstat (limited to 'tokio/src/io/util/mod.rs')
-rw-r--r--tokio/src/io/util/mod.rs110
1 files changed, 57 insertions, 53 deletions
diff --git a/tokio/src/io/util/mod.rs b/tokio/src/io/util/mod.rs
index 8d4e7678..24451ef6 100644
--- a/tokio/src/io/util/mod.rs
+++ b/tokio/src/io/util/mod.rs
@@ -1,71 +1,75 @@
-mod async_buf_read_ext;
-#[allow(unreachable_pub)] // https://github.com/rust-lang/rust/issues/57411
-pub use self::async_buf_read_ext::AsyncBufReadExt;
+#![allow(unreachable_pub)] // https://github.com/rust-lang/rust/issues/57411
-mod async_read_ext;
-#[allow(unreachable_pub)] // https://github.com/rust-lang/rust/issues/57411
-pub use self::async_read_ext::AsyncReadExt;
+cfg_io_util! {
+ mod async_buf_read_ext;
+ pub use async_buf_read_ext::AsyncBufReadExt;
-mod async_write_ext;
-#[allow(unreachable_pub)] // https://github.com/rust-lang/rust/issues/57411
-pub use self::async_write_ext::AsyncWriteExt;
+ mod async_read_ext;
+ pub use async_read_ext::AsyncReadExt;
-mod buf_reader;
-#[allow(unreachable_pub)] // https://github.com/rust-lang/rust/issues/57411
-pub use self::buf_reader::BufReader;
+ mod async_write_ext;
+ pub use async_write_ext::AsyncWriteExt;
-mod buf_stream;
-#[allow(unreachable_pub)] // https://github.com/rust-lang/rust/issues/57411
-pub use self::buf_stream::BufStream;
+ mod buf_reader;
+ pub use buf_reader::BufReader;
-mod buf_writer;
-#[allow(unreachable_pub)] // https://github.com/rust-lang/rust/issues/57411
-pub use self::buf_writer::BufWriter;
+ mod buf_stream;
+ pub use buf_stream::BufStream;
-mod chain;
+ mod buf_writer;
+ pub use buf_writer::BufWriter;
-mod copy;
-#[allow(unreachable_pub)] // https://github.com/rust-lang/rust/issues/57411
-pub use self::copy::{copy, Copy};
+ mod chain;
-mod empty;
-#[allow(unreachable_pub)] // https://github.com/rust-lang/rust/issues/57411
-pub use self::empty::{empty, Empty};
+ mod copy;
+ pub use copy::{copy, Copy};
-mod flush;
+ mod empty;
+ pub use empty::{empty, Empty};
-mod lines;
-#[allow(unreachable_pub)] // https://github.com/rust-lang/rust/issues/57411
-pub use self::lines::Lines;
+ mod flush;
-mod read;
-mod read_exact;
-mod read_line;
-mod read_to_end;
-mod read_to_string;
-mod read_until;
+ mod lines;
+ pub use lines::Lines;
-mod repeat;
-#[allow(unreachable_pub)] // https://github.com/rust-lang/rust/issues/57411
-pub use self::repeat::{repeat, Repeat};
+ mod read;
+ mod read_exact;
+ mod read_line;
-mod shutdown;
+ mod read_to_end;
+ cfg_process! {
+ pub(crate) use read_to_end::read_to_end;
+ }
-mod sink;
-#[allow(unreachable_pub)] // https://github.com/rust-lang/rust/issues/57411
-pub use self::sink::{sink, Sink};
+ mod read_to_string;
+ mod read_until;
-mod split;
-#[allow(unreachable_pub)] // https://github.com/rust-lang/rust/issues/57411
-pub use self::split::Split;
+ mod repeat;
+ pub use repeat::{repeat, Repeat};
-mod take;
-#[allow(unreachable_pub)] // https://github.com/rust-lang/rust/issues/57411
-pub use self::take::Take;
+ mod shutdown;
-mod write;
-mod write_all;
+ mod sink;
+ pub use sink::{sink, Sink};
-// used by `BufReader` and `BufWriter`
-// https://github.com/rust-lang/rust/blob/master/src/libstd/sys_common/io.rs#L1
-const DEFAULT_BUF_SIZE: usize = 8 * 1024;
+ mod split;
+ pub use split::Split;
+
+ mod take;
+ pub use take::Take;
+
+ mod write;
+ mod write_all;
+
+ // used by `BufReader` and `BufWriter`
+ // https://github.com/rust-lang/rust/blob/master/src/libstd/sys_common/io.rs#L1
+ const DEFAULT_BUF_SIZE: usize = 8 * 1024;
+}
+
+cfg_not_io_util! {
+ cfg_process! {
+ mod read_to_end;
+ // Used by process
+ pub(crate) use read_to_end::read_to_end;
+ }
+}