diff options
Diffstat (limited to 'tokio')
60 files changed, 105 insertions, 52 deletions
diff --git a/tokio/Cargo.toml b/tokio/Cargo.toml index 320e5b38..4f0161ae 100644 --- a/tokio/Cargo.toml +++ b/tokio/Cargo.toml @@ -24,7 +24,8 @@ categories = ["asynchronous", "network-programming"] keywords = ["io", "async", "non-blocking", "futures"] [features] -default = ["full"] +# Include nothing by default +default = [] # enable everything full = [ @@ -48,7 +49,7 @@ full = [ blocking = ["rt-core"] dns = ["rt-core"] fs = ["rt-core"] -io-driver = ["rt-core", "mio", "lazy_static"] +io-driver = ["mio", "lazy_static"] io-util = ["memchr"] # stdin, stdout, stderr io-std = ["rt-core"] @@ -83,7 +84,7 @@ stream = ["futures-core"] sync = ["fnv"] test-util = [] tcp = ["io-driver"] -time = ["rt-core", "slab"] +time = ["slab"] udp = ["io-driver"] uds = ["io-driver", "mio-uds", "libc"] diff --git a/tokio/README.md b/tokio/README.md index 087ab025..530f0bac 100644 --- a/tokio/README.md +++ b/tokio/README.md @@ -52,6 +52,15 @@ an asynchronous application. ## Example +To get started, add the following to `Cargo.toml`. + +```toml +tokio = { version = "0.2.0", features = ["full"] } +``` + +Tokio requires components to be explicitly enabled using feature flags. As a +shorthand, the `full` feature enables all components. + A basic TCP echo server with Tokio: ```rust diff --git a/tokio/src/lib.rs b/tokio/src/lib.rs index c213ee89..cd7a62ea 100644 --- a/tokio/src/lib.rs +++ b/tokio/src/lib.rs @@ -52,6 +52,13 @@ //! control what features are present, so that unused code can be eliminated. //! This documentation also lists what feature flags are necessary to enable each API. //! +//! The easiest way to get started is to enable all features. Do this by +//! enabling the `full` feature flag: +//! +//! ```toml +//! tokio = { version = "0.2", features = ["full"] } +//! ``` +//! //! [features]: https://doc.rust-lang.org/cargo/reference/manifest.html#the-features-section //! //! ## Working With Tasks diff --git a/tokio/src/sync/mod.rs b/tokio/src/sync/mod.rs index 2954eb85..0db703bb 100644 --- a/tokio/src/sync/mod.rs +++ b/tokio/src/sync/mod.rs @@ -40,9 +40,11 @@ cfg_not_sync! { pub(crate) use task::AtomicWaker; } - cfg_rt_core! { - pub(crate) mod oneshot; - } + #[cfg(any( + feature = "rt-core", + feature = "process", + feature = "signal"))] + pub(crate) mod oneshot; cfg_signal! { pub(crate) mod mpsc; diff --git a/tokio/tests/_require_full.rs b/tokio/tests/_require_full.rs new file mode 100644 index 00000000..98455bed --- /dev/null +++ b/tokio/tests/_require_full.rs @@ -0,0 +1,2 @@ +#![cfg(not(feature = "full"))] +compile_error!("run main Tokio tests with `--features full`"); diff --git a/tokio/tests/buffered.rs b/tokio/tests/buffered.rs index 5d77f866..7ce3d01c 100644 --- a/tokio/tests/buffered.rs +++ b/tokio/tests/buffered.rs @@ -1,4 +1,5 @@ #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] use tokio::net::TcpListener; use tokio::prelude::*; diff --git a/tokio/tests/fs_dir.rs b/tokio/tests/fs_dir.rs index 40e20bdb..c8b32fc6 100644 --- a/tokio/tests/fs_dir.rs +++ b/tokio/tests/fs_dir.rs @@ -1,4 +1,5 @@ #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] use tokio::fs; use tokio_test::assert_ok; diff --git a/tokio/tests/fs_file.rs b/tokio/tests/fs_file.rs index 555a1e64..3a56276e 100644 --- a/tokio/tests/fs_file.rs +++ b/tokio/tests/fs_file.rs @@ -1,4 +1,5 @@ #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] use tokio::fs::File; use tokio::prelude::*; diff --git a/tokio/tests/fs_file_mocked.rs b/tokio/tests/fs_file_mocked.rs index 12463cfc..0c572240 100644 --- a/tokio/tests/fs_file_mocked.rs +++ b/tokio/tests/fs_file_mocked.rs @@ -1,4 +1,5 @@ #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] macro_rules! ready { ($e:expr $(,)?) => { diff --git a/tokio/tests/fs_link.rs b/tokio/tests/fs_link.rs index faf6e75e..cbbe27ef 100644 --- a/tokio/tests/fs_link.rs +++ b/tokio/tests/fs_link.rs @@ -1,4 +1,5 @@ #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] use tokio::fs; diff --git a/tokio/tests/io_async_read.rs b/tokio/tests/io_async_read.rs index 0b9509e1..2be2aa1a 100644 --- a/tokio/tests/io_async_read.rs +++ b/tokio/tests/io_async_read.rs @@ -1,3 +1,6 @@ +#![warn(rust_2018_idioms)] +#![cfg(feature = "full")] + use tokio::io::AsyncRead; use tokio_test::task; use tokio_test::{assert_ready_err, assert_ready_ok}; diff --git a/tokio/tests/io_chain.rs b/tokio/tests/io_chain.rs index d7cb47ca..e2d59411 100644 --- a/tokio/tests/io_chain.rs +++ b/tokio/tests/io_chain.rs @@ -1,4 +1,5 @@ #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] use tokio::io::AsyncReadExt; use tokio_test::assert_ok; diff --git a/tokio/tests/io_copy.rs b/tokio/tests/io_copy.rs index a9df7430..75d77435 100644 --- a/tokio/tests/io_copy.rs +++ b/tokio/tests/io_copy.rs @@ -1,4 +1,5 @@ #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] use tokio::io::{AsyncRead, AsyncReadExt}; use tokio_test::assert_ok; diff --git a/tokio/tests/io_driver.rs b/tokio/tests/io_driver.rs index ec51373f..b85abd8c 100644 --- a/tokio/tests/io_driver.rs +++ b/tokio/tests/io_driver.rs @@ -1,4 +1,5 @@ #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] use tokio::net::TcpListener; use tokio::runtime; diff --git a/tokio/tests/io_driver_drop.rs b/tokio/tests/io_driver_drop.rs index 6b923dd3..0a5ce625 100644 --- a/tokio/tests/io_driver_drop.rs +++ b/tokio/tests/io_driver_drop.rs @@ -1,4 +1,5 @@ #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] use tokio::net::TcpListener; use tokio::runtime; diff --git a/tokio/tests/io_lines.rs b/tokio/tests/io_lines.rs index 83240d62..3775cae0 100644 --- a/tokio/tests/io_lines.rs +++ b/tokio/tests/io_lines.rs @@ -1,4 +1,5 @@ #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] use tokio::io::AsyncBufReadExt; use tokio_test::assert_ok; diff --git a/tokio/tests/io_read.rs b/tokio/tests/io_read.rs index 01cd2fd6..d18615e4 100644 --- a/tokio/tests/io_read.rs +++ b/tokio/tests/io_read.rs @@ -1,4 +1,5 @@ #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] use tokio::io::{AsyncRead, AsyncReadExt}; use tokio_test::assert_ok; diff --git a/tokio/tests/io_read_exact.rs b/tokio/tests/io_read_exact.rs index 8b2f20ec..d0e659bd 100644 --- a/tokio/tests/io_read_exact.rs +++ b/tokio/tests/io_read_exact.rs @@ -1,4 +1,5 @@ #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] use tokio::io::AsyncReadExt; use tokio_test::assert_ok; diff --git a/tokio/tests/io_read_line.rs b/tokio/tests/io_read_line.rs index 684eb14a..57ae37ce 100644 --- a/tokio/tests/io_read_line.rs +++ b/tokio/tests/io_read_line.rs @@ -1,4 +1,5 @@ #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] use tokio::io::AsyncBufReadExt; use tokio_test::assert_ok; diff --git a/tokio/tests/io_read_to_end.rs b/tokio/tests/io_read_to_end.rs index 89782aa3..ee636ba5 100644 --- a/tokio/tests/io_read_to_end.rs +++ b/tokio/tests/io_read_to_end.rs @@ -1,4 +1,5 @@ #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] use tokio::io::AsyncReadExt; use tokio_test::assert_ok; diff --git a/tokio/tests/io_read_to_string.rs b/tokio/tests/io_read_to_string.rs index 270d1e48..6b384b89 100644 --- a/tokio/tests/io_read_to_string.rs +++ b/tokio/tests/io_read_to_string.rs @@ -1,4 +1,5 @@ #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] use tokio::io::AsyncReadExt; use tokio_test::assert_ok; diff --git a/tokio/tests/io_read_until.rs b/tokio/tests/io_read_until.rs index 270d0221..4e0e0d10 100644 --- a/tokio/tests/io_read_until.rs +++ b/tokio/tests/io_read_until.rs @@ -1,4 +1,5 @@ #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] use tokio::io::AsyncBufReadExt; use tokio_test::assert_ok; diff --git a/tokio/tests/io_split.rs b/tokio/tests/io_split.rs index 054a415f..0080f46a 100644 --- a/tokio/tests/io_split.rs +++ b/tokio/tests/io_split.rs @@ -1,3 +1,6 @@ +#![warn(rust_2018_idioms)] +#![cfg(feature = "full")] + use tokio::io::{split, AsyncRead, AsyncWrite, ReadHalf, WriteHalf}; use std::io; diff --git a/tokio/tests/io_take.rs b/tokio/tests/io_take.rs index 7b3363e0..683606f7 100644 --- a/tokio/tests/io_take.rs +++ b/tokio/tests/io_take.rs @@ -1,4 +1,5 @@ #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] use tokio::io::AsyncReadExt; use tokio_test::assert_ok; diff --git a/tokio/tests/io_write.rs b/tokio/tests/io_write.rs index 15c5be7c..96cebc33 100644 --- a/tokio/tests/io_write.rs +++ b/tokio/tests/io_write.rs @@ -1,4 +1,5 @@ #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] use tokio::io::{AsyncWrite, AsyncWriteExt}; use tokio_test::assert_ok; diff --git a/tokio/tests/io_write_all.rs b/tokio/tests/io_write_all.rs index fea46dc3..7ca02228 100644 --- a/tokio/tests/io_write_all.rs +++ b/tokio/tests/io_write_all.rs @@ -1,4 +1,5 @@ #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] use tokio::io::{AsyncWrite, AsyncWriteExt}; use tokio_test::assert_ok; diff --git a/tokio/tests/net_bind_resource.rs b/tokio/tests/net_bind_resource.rs index bb507fcc..d4a0b8da 100644 --- a/tokio/tests/net_bind_resource.rs +++ b/tokio/tests/net_bind_resource.rs @@ -1,3 +1,6 @@ +#![warn(rust_2018_idioms)] +#![cfg(feature = "full")] + use tokio::net::TcpListener; use std::convert::TryFrom; diff --git a/tokio/tests/process_issue_42.rs b/tokio/tests/process_issue_42.rs index 1b8dcc95..f84c204f 100644 --- a/tokio/tests/process_issue_42.rs +++ b/tokio/tests/process_issue_42.rs @@ -1,6 +1,6 @@ -#![cfg(feature = "process")] -#![cfg(unix)] #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] +#![cfg(unix)] use tokio::process::Command; use tokio::runtime; diff --git a/tokio/tests/process_smoke.rs b/tokio/tests/process_smoke.rs index a952f7f6..d16d1d72 100644 --- a/tokio/tests/process_smoke.rs +++ b/tokio/tests/process_smoke.rs @@ -1,5 +1,5 @@ -#![cfg(feature = "process")] #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] use tokio::process::Command; use tokio_test::assert_ok; diff --git a/tokio/tests/rt_basic.rs b/tokio/tests/rt_basic.rs index 700f1029..68e09ef3 100644 --- a/tokio/tests/rt_basic.rs +++ b/tokio/tests/rt_basic.rs @@ -1,4 +1,5 @@ #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] use tokio::runtime::Runtime; use tokio::sync::oneshot; diff --git a/tokio/tests/rt_common.rs b/tokio/tests/rt_common.rs index b360158d..fe0cf84a 100644 --- a/tokio/tests/rt_common.rs +++ b/tokio/tests/rt_common.rs @@ -1,6 +1,7 @@ -// Tests to run on both current-thread & therad-pool runtime variants. - #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] + +// Tests to run on both current-thread & therad-pool runtime variants. macro_rules! rt_test { ($($t:tt)*) => { diff --git a/tokio/tests/rt_threaded.rs b/tokio/tests/rt_threaded.rs index 4b4c880e..2b67b5a4 100644 --- a/tokio/tests/rt_threaded.rs +++ b/tokio/tests/rt_threaded.rs @@ -1,4 +1,5 @@ #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] use tokio::io::{AsyncReadExt, AsyncWriteExt}; use tokio::net::{TcpListener, TcpStream}; diff --git a/tokio/tests/signal_ctrl_c.rs b/tokio/tests/signal_ctrl_c.rs index 13eeaa81..4b057ee7 100644 --- a/tokio/tests/signal_ctrl_c.rs +++ b/tokio/tests/signal_ctrl_c.rs @@ -1,5 +1,6 @@ -#![cfg(unix)] #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] +#![cfg(unix)] mod support { pub mod signal; diff --git a/tokio/tests/signal_drop_recv.rs b/tokio/tests/signal_drop_recv.rs index 06dffe12..b0d9213e 100644 --- a/tokio/tests/signal_drop_recv.rs +++ b/tokio/tests/signal_drop_recv.rs @@ -1,5 +1,6 @@ -#![cfg(unix)] #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] +#![cfg(unix)] mod support { pub mod signal; diff --git a/tokio/tests/signal_drop_rt.rs b/tokio/tests/signal_drop_rt.rs index fc790c28..aeedd96e 100644 --- a/tokio/tests/signal_drop_rt.rs +++ b/tokio/tests/signal_drop_rt.rs @@ -1,5 +1,6 @@ -#![cfg(unix)] #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] +#![cfg(unix)] mod support { pub mod signal; diff --git a/tokio/tests/signal_drop_signal.rs b/tokio/tests/signal_drop_signal.rs index b5bc7dd8..92ac4050 100644 --- a/tokio/tests/signal_drop_signal.rs +++ b/tokio/tests/signal_drop_signal.rs @@ -1,5 +1,6 @@ -#![cfg(unix)] #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] +#![cfg(unix)] mod support { pub mod signal; diff --git a/tokio/tests/signal_multi_rt.rs b/tokio/tests/signal_multi_rt.rs index e34e7c09..9d784695 100644 --- a/tokio/tests/signal_multi_rt.rs +++ b/tokio/tests/signal_multi_rt.rs @@ -1,5 +1,6 @@ -#![cfg(unix)] #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] +#![cfg(unix)] mod support { pub mod signal; diff --git a/tokio/tests/signal_no_rt.rs b/tokio/tests/signal_no_rt.rs index b512e5e7..b0f32b2d 100644 --- a/tokio/tests/signal_no_rt.rs +++ b/tokio/tests/signal_no_rt.rs @@ -1,5 +1,6 @@ -#![cfg(unix)] #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] +#![cfg(unix)] use tokio::signal::unix::{signal, SignalKind}; diff --git a/tokio/tests/signal_notify_both.rs b/tokio/tests/signal_notify_both.rs index 7d830686..3481f808 100644 --- a/tokio/tests/signal_notify_both.rs +++ b/tokio/tests/signal_notify_both.rs @@ -1,5 +1,6 @@ -#![cfg(unix)] #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] +#![cfg(unix)] mod support { pub mod signal; diff --git a/tokio/tests/signal_twice.rs b/tokio/tests/signal_twice.rs index 171d18e6..8f33d22a 100644 --- a/tokio/tests/signal_twice.rs +++ b/tokio/tests/signal_twice.rs @@ -1,5 +1,6 @@ -#![cfg(unix)] #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] +#![cfg(unix)] mod support { pub mod signal; diff --git a/tokio/tests/signal_usr1.rs b/tokio/tests/signal_usr1.rs index 95fc6c10..d74c7d31 100644 --- a/tokio/tests/signal_usr1.rs +++ b/tokio/tests/signal_usr1.rs @@ -1,5 +1,6 @@ -#![cfg(unix)] #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] +#![cfg(unix)] mod support { pub mod signal; diff --git a/tokio/tests/sync_barrier.rs b/tokio/tests/sync_barrier.rs index 170e8c2b..e6f32c7a 100644 --- a/tokio/tests/sync_barrier.rs +++ b/tokio/tests/sync_barrier.rs @@ -1,4 +1,5 @@ #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] use tokio::sync::Barrier; diff --git a/tokio/tests/sync_errors.rs b/tokio/tests/sync_errors.rs index 8cc0c0cd..260f3be6 100644 --- a/tokio/tests/sync_errors.rs +++ b/tokio/tests/sync_errors.rs @@ -1,4 +1,5 @@ #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] fn is_error<T: ::std::error::Error + Send + Sync>() {} diff --git a/tokio/tests/sync_mpsc.rs b/tokio/tests/sync_mpsc.rs index 040904e4..127e7572 100644 --- a/tokio/tests/sync_mpsc.rs +++ b/tokio/tests/sync_mpsc.rs @@ -1,4 +1,5 @@ #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] use tokio::sync::mpsc; use tokio::sync::mpsc::error::TrySendError; diff --git a/tokio/tests/sync_mutex.rs b/tokio/tests/sync_mutex.rs index b100f270..e4be400e 100644 --- a/tokio/tests/sync_mutex.rs +++ b/tokio/tests/sync_mutex.rs @@ -1,4 +1,5 @@ #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] use tokio::sync::Mutex; use tokio_test::task::spawn; diff --git a/tokio/tests/sync_oneshot.rs b/tokio/tests/sync_oneshot.rs index c1d44db8..13e526d4 100644 --- a/tokio/tests/sync_oneshot.rs +++ b/tokio/tests/sync_oneshot.rs @@ -1,4 +1,5 @@ #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] use tokio::sync::oneshot; use tokio_test::*; diff --git a/tokio/tests/sync_watch.rs b/tokio/tests/sync_watch.rs index 7ccad5c2..f13b145d 100644 --- a/tokio/tests/sync_watch.rs +++ b/tokio/tests/sync_watch.rs @@ -1,4 +1,5 @@ #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] use tokio::sync::watch; use tokio_test::task::spawn; diff --git a/tokio/tests/tcp_accept.rs b/tokio/tests/tcp_accept.rs index 09a2a603..eec4338f 100644 --- a/tokio/tests/tcp_accept.rs +++ b/tokio/tests/tcp_accept.rs @@ -1,4 +1,5 @@ #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] use tokio::net::{TcpListener, TcpStream}; use tokio::sync::oneshot; diff --git a/tokio/tests/tcp_connect.rs b/tokio/tests/tcp_connect.rs index daf0b3c9..de1cead8 100644 --- a/tokio/tests/tcp_connect.rs +++ b/tokio/tests/tcp_connect.rs @@ -1,4 +1,5 @@ #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] use tokio::net::{TcpListener, TcpStream}; use tokio::sync::oneshot; diff --git a/tokio/tests/tcp_echo.rs b/tokio/tests/tcp_echo.rs index 0325ecbb..38377702 100644 --- a/tokio/tests/tcp_echo.rs +++ b/tokio/tests/tcp_echo.rs @@ -1,4 +1,5 @@ #![warn(rust_2018_idioms)] +#![cfg(feature = "full")] use tokio::net::{TcpListener, TcpStream}; use tokio::prelude::*; diff --git a/tokio/tests/tcp_peek.rs b/tokio/tests/tcp_peek.rs index 34f1ba3a..c5781daf 100644 --- a/tokio/tests/tcp_peek.rs +++ b/tokio/tests/tcp_peek.rs @@ -1,4 +1,5 @@ < |