mirror of
https://github.com/tokio-rs/tokio.git
synced 2025-10-01 12:20:39 +00:00
default all feature flags to off (#1811)
Changes the set of `default` feature flags to `[]`. By default, only core traits are included without specifying feature flags. This makes it easier for users to pick the components they need. For convenience, a `full` feature flag is included that includes all components. Tests are configured to require the `full` feature. Testing individual feature flags will need to be moved to a separate crate. Closes #1791
This commit is contained in:
parent
e1b1e216c5
commit
7b4c999341
10
README.md
10
README.md
@ -54,15 +54,13 @@ an asynchronous application.
|
|||||||
|
|
||||||
A basic TCP echo server with Tokio:
|
A basic TCP echo server with Tokio:
|
||||||
|
|
||||||
```rust
|
```rust,no_run
|
||||||
use tokio::net::TcpListener;
|
use tokio::net::TcpListener;
|
||||||
use tokio::prelude::*;
|
use tokio::prelude::*;
|
||||||
use std::net::SocketAddr;
|
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let addr = "127.0.0.1:8080".parse::<SocketAddr>()?;
|
let mut listener = TcpListener::bind("127.0.0.1:8080").await?;
|
||||||
let mut listener = TcpListener::bind(&addr).await?;
|
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
let (mut socket, _) = listener.accept().await?;
|
let (mut socket, _) = listener.accept().await?;
|
||||||
@ -77,14 +75,14 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
Ok(n) if n == 0 => return,
|
Ok(n) if n == 0 => return,
|
||||||
Ok(n) => n,
|
Ok(n) => n,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
println!("failed to read from socket; err = {:?}", e);
|
eprintln!("failed to read from socket; err = {:?}", e);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Write the data back
|
// Write the data back
|
||||||
if let Err(e) = socket.write_all(&buf[0..n]).await {
|
if let Err(e) = socket.write_all(&buf[0..n]).await {
|
||||||
println!("failed to write to socket; err = {:?}", e);
|
eprintln!("failed to write to socket; err = {:?}", e);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,14 +22,6 @@ jobs:
|
|||||||
- template: azure-is-release.yml
|
- template: azure-is-release.yml
|
||||||
|
|
||||||
- ${{ each crate in parameters.crates }}:
|
- ${{ each crate in parameters.crates }}:
|
||||||
# Run with default crate features
|
|
||||||
- script: cargo test
|
|
||||||
env:
|
|
||||||
LOOM_MAX_PREEMPTIONS: 2
|
|
||||||
CI: 'True'
|
|
||||||
displayName: ${{ crate }} - cargo test
|
|
||||||
workingDirectory: $(Build.SourcesDirectory)/${{ crate }}
|
|
||||||
|
|
||||||
# Run with all crate features
|
# Run with all crate features
|
||||||
- script: cargo test --all-features
|
- script: cargo test --all-features
|
||||||
env:
|
env:
|
||||||
@ -41,14 +33,6 @@ jobs:
|
|||||||
- template: azure-patch-crates.yml
|
- template: azure-patch-crates.yml
|
||||||
|
|
||||||
- ${{ each crate in parameters.crates }}:
|
- ${{ each crate in parameters.crates }}:
|
||||||
# Run with default crate features
|
|
||||||
- script: cargo test
|
|
||||||
env:
|
|
||||||
LOOM_MAX_PREEMPTIONS: 2
|
|
||||||
CI: 'True'
|
|
||||||
displayName: ${{ crate }} - cargo test
|
|
||||||
workingDirectory: $(Build.SourcesDirectory)/${{ crate }}
|
|
||||||
|
|
||||||
# Run with all crate features
|
# Run with all crate features
|
||||||
- script: cargo test --all-features
|
- script: cargo test --all-features
|
||||||
env:
|
env:
|
||||||
|
@ -5,8 +5,8 @@ publish = false
|
|||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
tokio = { version = "=0.2.0-alpha.6", path = "../tokio" }
|
tokio = { version = "=0.2.0-alpha.6", path = "../tokio", features = ["full"] }
|
||||||
tokio-util = { version = "=0.2.0-alpha.6", path = "../tokio-util" }
|
tokio-util = { version = "=0.2.0-alpha.6", path = "../tokio-util", features = ["full"] }
|
||||||
|
|
||||||
bytes = { git = "https://github.com/tokio-rs/bytes" }
|
bytes = { git = "https://github.com/tokio-rs/bytes" }
|
||||||
futures = "0.3.0"
|
futures = "0.3.0"
|
||||||
|
@ -6,9 +6,10 @@ edition = "2018"
|
|||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
tokio = { path = "../tokio", features = ["full"] }
|
||||||
|
doc-comment = "0.3.1"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
tokio = { path = "../tokio" }
|
|
||||||
tokio-test = { path = "../tokio-test" }
|
tokio-test = { path = "../tokio-test" }
|
||||||
|
|
||||||
futures = { version = "0.3.0", features = ["async-await"] }
|
futures = { version = "0.3.0", features = ["async-await"] }
|
||||||
|
4
tests-integration/src/lib.rs
Normal file
4
tests-integration/src/lib.rs
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
use doc_comment::doc_comment;
|
||||||
|
|
||||||
|
// #[doc = include_str!("../../README.md")]
|
||||||
|
doc_comment!(include_str!("../../README.md"));
|
@ -29,7 +29,7 @@ quote = "1"
|
|||||||
syn = { version = "1.0.3", features = ["full"] }
|
syn = { version = "1.0.3", features = ["full"] }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
tokio = { version = "=0.2.0-alpha.6", path = "../tokio" }
|
tokio = { version = "=0.2.0-alpha.6", path = "../tokio", features = ["full"] }
|
||||||
|
|
||||||
[package.metadata.docs.rs]
|
[package.metadata.docs.rs]
|
||||||
all-features = true
|
all-features = true
|
||||||
|
@ -20,12 +20,13 @@ Testing utilities for Tokio- and futures-based code
|
|||||||
categories = ["asynchronous", "testing"]
|
categories = ["asynchronous", "testing"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
tokio = { version = "=0.2.0-alpha.6", path = "../tokio", features = ["test-util"] }
|
tokio = { version = "=0.2.0-alpha.6", path = "../tokio", features = ["rt-core", "sync", "time", "test-util"] }
|
||||||
|
|
||||||
bytes = { git = "https://github.com/tokio-rs/bytes" }
|
bytes = { git = "https://github.com/tokio-rs/bytes" }
|
||||||
futures-core = "0.3.0"
|
futures-core = "0.3.0"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
|
tokio = { version = "=0.2.0-alpha.6", path = "../tokio", features = ["full"] }
|
||||||
futures-util = "0.3.0"
|
futures-util = "0.3.0"
|
||||||
|
|
||||||
[package.metadata.docs.rs]
|
[package.metadata.docs.rs]
|
||||||
|
@ -29,6 +29,8 @@ native-tls = "0.2"
|
|||||||
tokio = { version = "=0.2.0-alpha.6", path = "../tokio" }
|
tokio = { version = "=0.2.0-alpha.6", path = "../tokio" }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
|
tokio = { version = "=0.2.0-alpha.6", path = "../tokio", features = ["macros", "stream", "rt-core", "io-util", "net"] }
|
||||||
|
|
||||||
cfg-if = "0.1"
|
cfg-if = "0.1"
|
||||||
env_logger = { version = "0.6", default-features = false }
|
env_logger = { version = "0.6", default-features = false }
|
||||||
futures = { version = "0.3.0", features = ["async-await"] }
|
futures = { version = "0.3.0", features = ["async-await"] }
|
||||||
|
@ -19,6 +19,16 @@ Additional utilities for working with Tokio.
|
|||||||
"""
|
"""
|
||||||
categories = ["asynchronous"]
|
categories = ["asynchronous"]
|
||||||
|
|
||||||
|
[features]
|
||||||
|
# No features on by default
|
||||||
|
default = []
|
||||||
|
|
||||||
|
# Shorthand for enabling everything
|
||||||
|
full = ["codec", "udp"]
|
||||||
|
|
||||||
|
codec = []
|
||||||
|
udp = ["tokio/udp"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
tokio = { version = "=0.2.0-alpha.6", path = "../tokio" }
|
tokio = { version = "=0.2.0-alpha.6", path = "../tokio" }
|
||||||
|
|
||||||
@ -29,10 +39,11 @@ log = "0.4"
|
|||||||
pin-project-lite = "0.1.1"
|
pin-project-lite = "0.1.1"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
tokio = { version = "=0.2.0-alpha.6", path = "../tokio" }
|
tokio = { version = "=0.2.0-alpha.6", path = "../tokio", features = ["full"] }
|
||||||
tokio-test = { version = "=0.2.0-alpha.6", path = "../tokio-test" }
|
tokio-test = { version = "=0.2.0-alpha.6", path = "../tokio-test" }
|
||||||
|
|
||||||
futures = "0.3.0"
|
futures = "0.3.0"
|
||||||
|
|
||||||
[package.metadata.docs.rs]
|
[package.metadata.docs.rs]
|
||||||
all-features = true
|
all-features = true
|
||||||
|
rustdoc-args = ["--cfg", "docsrs"]
|
||||||
|
19
tokio-util/src/cfg.rs
Normal file
19
tokio-util/src/cfg.rs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
macro_rules! cfg_codec {
|
||||||
|
($($item:item)*) => {
|
||||||
|
$(
|
||||||
|
#[cfg(feature = "codec")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "codec")))]
|
||||||
|
$item
|
||||||
|
)*
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
macro_rules! cfg_udp {
|
||||||
|
($($item:item)*) => {
|
||||||
|
$(
|
||||||
|
#[cfg(all(feature = "udp", feature = "codec"))]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(all(feature = "udp", feature = "codec"))))]
|
||||||
|
$item
|
||||||
|
)*
|
||||||
|
}
|
||||||
|
}
|
@ -10,8 +10,17 @@
|
|||||||
no_crate_inject,
|
no_crate_inject,
|
||||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))
|
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))
|
||||||
))]
|
))]
|
||||||
|
#![cfg_attr(docsrs, feature(doc_cfg))]
|
||||||
|
|
||||||
//! Utilities for working with Tokio.
|
//! Utilities for working with Tokio.
|
||||||
|
|
||||||
|
#[macro_use]
|
||||||
|
mod cfg;
|
||||||
|
|
||||||
|
cfg_codec! {
|
||||||
pub mod codec;
|
pub mod codec;
|
||||||
|
}
|
||||||
|
|
||||||
|
cfg_udp! {
|
||||||
pub mod udp;
|
pub mod udp;
|
||||||
|
}
|
||||||
|
@ -27,6 +27,7 @@ use std::task::{Context, Poll};
|
|||||||
/// calling `split` on the `UdpFramed` returned by this method, which will break
|
/// calling `split` on the `UdpFramed` returned by this method, which will break
|
||||||
/// them into separate objects, allowing them to interact more easily.
|
/// them into separate objects, allowing them to interact more easily.
|
||||||
#[must_use = "sinks do nothing unless polled"]
|
#[must_use = "sinks do nothing unless polled"]
|
||||||
|
#[cfg_attr(docsrs, doc(feature = "codec-udp"))]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct UdpFramed<C> {
|
pub struct UdpFramed<C> {
|
||||||
socket: UdpSocket,
|
socket: UdpSocket,
|
||||||
|
@ -24,7 +24,8 @@ categories = ["asynchronous", "network-programming"]
|
|||||||
keywords = ["io", "async", "non-blocking", "futures"]
|
keywords = ["io", "async", "non-blocking", "futures"]
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["full"]
|
# Include nothing by default
|
||||||
|
default = []
|
||||||
|
|
||||||
# enable everything
|
# enable everything
|
||||||
full = [
|
full = [
|
||||||
@ -48,7 +49,7 @@ full = [
|
|||||||
blocking = ["rt-core"]
|
blocking = ["rt-core"]
|
||||||
dns = ["rt-core"]
|
dns = ["rt-core"]
|
||||||
fs = ["rt-core"]
|
fs = ["rt-core"]
|
||||||
io-driver = ["rt-core", "mio", "lazy_static"]
|
io-driver = ["mio", "lazy_static"]
|
||||||
io-util = ["memchr"]
|
io-util = ["memchr"]
|
||||||
# stdin, stdout, stderr
|
# stdin, stdout, stderr
|
||||||
io-std = ["rt-core"]
|
io-std = ["rt-core"]
|
||||||
@ -83,7 +84,7 @@ stream = ["futures-core"]
|
|||||||
sync = ["fnv"]
|
sync = ["fnv"]
|
||||||
test-util = []
|
test-util = []
|
||||||
tcp = ["io-driver"]
|
tcp = ["io-driver"]
|
||||||
time = ["rt-core", "slab"]
|
time = ["slab"]
|
||||||
udp = ["io-driver"]
|
udp = ["io-driver"]
|
||||||
uds = ["io-driver", "mio-uds", "libc"]
|
uds = ["io-driver", "mio-uds", "libc"]
|
||||||
|
|
||||||
|
@ -52,6 +52,15 @@ an asynchronous application.
|
|||||||
|
|
||||||
## Example
|
## 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:
|
A basic TCP echo server with Tokio:
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
|
@ -52,6 +52,13 @@
|
|||||||
//! control what features are present, so that unused code can be eliminated.
|
//! 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.
|
//! 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
|
//! [features]: https://doc.rust-lang.org/cargo/reference/manifest.html#the-features-section
|
||||||
//!
|
//!
|
||||||
//! ## Working With Tasks
|
//! ## Working With Tasks
|
||||||
|
@ -40,9 +40,11 @@ cfg_not_sync! {
|
|||||||
pub(crate) use task::AtomicWaker;
|
pub(crate) use task::AtomicWaker;
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg_rt_core! {
|
#[cfg(any(
|
||||||
|
feature = "rt-core",
|
||||||
|
feature = "process",
|
||||||
|
feature = "signal"))]
|
||||||
pub(crate) mod oneshot;
|
pub(crate) mod oneshot;
|
||||||
}
|
|
||||||
|
|
||||||
cfg_signal! {
|
cfg_signal! {
|
||||||
pub(crate) mod mpsc;
|
pub(crate) mod mpsc;
|
||||||
|
2
tokio/tests/_require_full.rs
Normal file
2
tokio/tests/_require_full.rs
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
#![cfg(not(feature = "full"))]
|
||||||
|
compile_error!("run main Tokio tests with `--features full`");
|
@ -1,4 +1,5 @@
|
|||||||
#![warn(rust_2018_idioms)]
|
#![warn(rust_2018_idioms)]
|
||||||
|
#![cfg(feature = "full")]
|
||||||
|
|
||||||
use tokio::net::TcpListener;
|
use tokio::net::TcpListener;
|
||||||
use tokio::prelude::*;
|
use tokio::prelude::*;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#![warn(rust_2018_idioms)]
|
#![warn(rust_2018_idioms)]
|
||||||
|
#![cfg(feature = "full")]
|
||||||
|
|
||||||
use tokio::fs;
|
use tokio::fs;
|
||||||
use tokio_test::assert_ok;
|
use tokio_test::assert_ok;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#![warn(rust_2018_idioms)]
|
#![warn(rust_2018_idioms)]
|
||||||
|
#![cfg(feature = "full")]
|
||||||
|
|
||||||
use tokio::fs::File;
|
use tokio::fs::File;
|
||||||
use tokio::prelude::*;
|
use tokio::prelude::*;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#![warn(rust_2018_idioms)]
|
#![warn(rust_2018_idioms)]
|
||||||
|
#![cfg(feature = "full")]
|
||||||
|
|
||||||
macro_rules! ready {
|
macro_rules! ready {
|
||||||
($e:expr $(,)?) => {
|
($e:expr $(,)?) => {
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#![warn(rust_2018_idioms)]
|
#![warn(rust_2018_idioms)]
|
||||||
|
#![cfg(feature = "full")]
|
||||||
|
|
||||||
use tokio::fs;
|
use tokio::fs;
|
||||||
|
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
#![warn(rust_2018_idioms)]
|
||||||
|
#![cfg(feature = "full")]
|
||||||
|
|
||||||
use tokio::io::AsyncRead;
|
use tokio::io::AsyncRead;
|
||||||
use tokio_test::task;
|
use tokio_test::task;
|
||||||
use tokio_test::{assert_ready_err, assert_ready_ok};
|
use tokio_test::{assert_ready_err, assert_ready_ok};
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#![warn(rust_2018_idioms)]
|
#![warn(rust_2018_idioms)]
|
||||||
|
#![cfg(feature = "full")]
|
||||||
|
|
||||||
use tokio::io::AsyncReadExt;
|
use tokio::io::AsyncReadExt;
|
||||||
use tokio_test::assert_ok;
|
use tokio_test::assert_ok;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#![warn(rust_2018_idioms)]
|
#![warn(rust_2018_idioms)]
|
||||||
|
#![cfg(feature = "full")]
|
||||||
|
|
||||||
use tokio::io::{AsyncRead, AsyncReadExt};
|
use tokio::io::{AsyncRead, AsyncReadExt};
|
||||||
use tokio_test::assert_ok;
|
use tokio_test::assert_ok;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#![warn(rust_2018_idioms)]
|
#![warn(rust_2018_idioms)]
|
||||||
|
#![cfg(feature = "full")]
|
||||||
|
|
||||||
use tokio::net::TcpListener;
|
use tokio::net::TcpListener;
|
||||||
use tokio::runtime;
|
use tokio::runtime;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#![warn(rust_2018_idioms)]
|
#![warn(rust_2018_idioms)]
|
||||||
|
#![cfg(feature = "full")]
|
||||||
|
|
||||||
use tokio::net::TcpListener;
|
use tokio::net::TcpListener;
|
||||||
use tokio::runtime;
|
use tokio::runtime;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#![warn(rust_2018_idioms)]
|
#![warn(rust_2018_idioms)]
|
||||||
|
#![cfg(feature = "full")]
|
||||||
|
|
||||||
use tokio::io::AsyncBufReadExt;
|
use tokio::io::AsyncBufReadExt;
|
||||||
use tokio_test::assert_ok;
|
use tokio_test::assert_ok;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#![warn(rust_2018_idioms)]
|
#![warn(rust_2018_idioms)]
|
||||||
|
#![cfg(feature = "full")]
|
||||||
|
|
||||||
use tokio::io::{AsyncRead, AsyncReadExt};
|
use tokio::io::{AsyncRead, AsyncReadExt};
|
||||||
use tokio_test::assert_ok;
|
use tokio_test::assert_ok;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#![warn(rust_2018_idioms)]
|
#![warn(rust_2018_idioms)]
|
||||||
|
#![cfg(feature = "full")]
|
||||||
|
|
||||||
use tokio::io::AsyncReadExt;
|
use tokio::io::AsyncReadExt;
|
||||||
use tokio_test::assert_ok;
|
use tokio_test::assert_ok;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#![warn(rust_2018_idioms)]
|
#![warn(rust_2018_idioms)]
|
||||||
|
#![cfg(feature = "full")]
|
||||||
|
|
||||||
use tokio::io::AsyncBufReadExt;
|
use tokio::io::AsyncBufReadExt;
|
||||||
use tokio_test::assert_ok;
|
use tokio_test::assert_ok;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#![warn(rust_2018_idioms)]
|
#![warn(rust_2018_idioms)]
|
||||||
|
#![cfg(feature = "full")]
|
||||||
|
|
||||||
use tokio::io::AsyncReadExt;
|
use tokio::io::AsyncReadExt;
|
||||||
use tokio_test::assert_ok;
|
use tokio_test::assert_ok;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#![warn(rust_2018_idioms)]
|
#![warn(rust_2018_idioms)]
|
||||||
|
#![cfg(feature = "full")]
|
||||||
|
|
||||||
use tokio::io::AsyncReadExt;
|
use tokio::io::AsyncReadExt;
|
||||||
use tokio_test::assert_ok;
|
use tokio_test::assert_ok;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#![warn(rust_2018_idioms)]
|
#![warn(rust_2018_idioms)]
|
||||||
|
#![cfg(feature = "full")]
|
||||||
|
|
||||||
use tokio::io::AsyncBufReadExt;
|
use tokio::io::AsyncBufReadExt;
|
||||||
use tokio_test::assert_ok;
|
use tokio_test::assert_ok;
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
#![warn(rust_2018_idioms)]
|
||||||
|
#![cfg(feature = "full")]
|
||||||
|
|
||||||
use tokio::io::{split, AsyncRead, AsyncWrite, ReadHalf, WriteHalf};
|
use tokio::io::{split, AsyncRead, AsyncWrite, ReadHalf, WriteHalf};
|
||||||
|
|
||||||
use std::io;
|
use std::io;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#![warn(rust_2018_idioms)]
|
#![warn(rust_2018_idioms)]
|
||||||
|
#![cfg(feature = "full")]
|
||||||
|
|
||||||
use tokio::io::AsyncReadExt;
|
use tokio::io::AsyncReadExt;
|
||||||
use tokio_test::assert_ok;
|
use tokio_test::assert_ok;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#![warn(rust_2018_idioms)]
|
#![warn(rust_2018_idioms)]
|
||||||
|
#![cfg(feature = "full")]
|
||||||
|
|
||||||
use tokio::io::{AsyncWrite, AsyncWriteExt};
|
use tokio::io::{AsyncWrite, AsyncWriteExt};
|
||||||
use tokio_test::assert_ok;
|
use tokio_test::assert_ok;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#![warn(rust_2018_idioms)]
|
#![warn(rust_2018_idioms)]
|
||||||
|
#![cfg(feature = "full")]
|
||||||
|
|
||||||
use tokio::io::{AsyncWrite, AsyncWriteExt};
|
use tokio::io::{AsyncWrite, AsyncWriteExt};
|
||||||
use tokio_test::assert_ok;
|
use tokio_test::assert_ok;
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
#![warn(rust_2018_idioms)]
|
||||||
|
#![cfg(feature = "full")]
|
||||||
|
|
||||||
use tokio::net::TcpListener;
|
use tokio::net::TcpListener;
|
||||||
|
|
||||||
use std::convert::TryFrom;
|
use std::convert::TryFrom;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#![cfg(feature = "process")]
|
|
||||||
#![cfg(unix)]
|
|
||||||
#![warn(rust_2018_idioms)]
|
#![warn(rust_2018_idioms)]
|
||||||
|
#![cfg(feature = "full")]
|
||||||
|
#![cfg(unix)]
|
||||||
|
|
||||||
use tokio::process::Command;
|
use tokio::process::Command;
|
||||||
use tokio::runtime;
|
use tokio::runtime;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#![cfg(feature = "process")]
|
|
||||||
#![warn(rust_2018_idioms)]
|
#![warn(rust_2018_idioms)]
|
||||||
|
#![cfg(feature = "full")]
|
||||||
|
|
||||||
use tokio::process::Command;
|
use tokio::process::Command;
|
||||||
use tokio_test::assert_ok;
|
use tokio_test::assert_ok;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#![warn(rust_2018_idioms)]
|
#![warn(rust_2018_idioms)]
|
||||||
|
#![cfg(feature = "full")]
|
||||||
|
|
||||||
use tokio::runtime::Runtime;
|
use tokio::runtime::Runtime;
|
||||||
use tokio::sync::oneshot;
|
use tokio::sync::oneshot;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// Tests to run on both current-thread & therad-pool runtime variants.
|
|
||||||
|
|
||||||
#![warn(rust_2018_idioms)]
|
#![warn(rust_2018_idioms)]
|
||||||
|
#![cfg(feature = "full")]
|
||||||
|
|
||||||
|
// Tests to run on both current-thread & therad-pool runtime variants.
|
||||||
|
|
||||||
macro_rules! rt_test {
|
macro_rules! rt_test {
|
||||||
($($t:tt)*) => {
|
($($t:tt)*) => {
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#![warn(rust_2018_idioms)]
|
#![warn(rust_2018_idioms)]
|
||||||
|
#![cfg(feature = "full")]
|
||||||
|
|
||||||
use tokio::io::{AsyncReadExt, AsyncWriteExt};
|
use tokio::io::{AsyncReadExt, AsyncWriteExt};
|
||||||
use tokio::net::{TcpListener, TcpStream};
|
use tokio::net::{TcpListener, TcpStream};
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#![cfg(unix)]
|
|
||||||
#![warn(rust_2018_idioms)]
|
#![warn(rust_2018_idioms)]
|
||||||
|
#![cfg(feature = "full")]
|
||||||
|
#![cfg(unix)]
|
||||||
|
|
||||||
mod support {
|
mod support {
|
||||||
pub mod signal;
|
pub mod signal;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#![cfg(unix)]
|
|
||||||
#![warn(rust_2018_idioms)]
|
#![warn(rust_2018_idioms)]
|
||||||
|
#![cfg(feature = "full")]
|
||||||
|
#![cfg(unix)]
|
||||||
|
|
||||||
mod support {
|
mod support {
|
||||||
pub mod signal;
|
pub mod signal;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#![cfg(unix)]
|
|
||||||
#![warn(rust_2018_idioms)]
|
#![warn(rust_2018_idioms)]
|
||||||
|
#![cfg(feature = "full")]
|
||||||
|
#![cfg(unix)]
|
||||||
|
|
||||||
mod support {
|
mod support {
|
||||||
pub mod signal;
|
pub mod signal;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#![cfg(unix)]
|
|
||||||
#![warn(rust_2018_idioms)]
|
#![warn(rust_2018_idioms)]
|
||||||
|
#![cfg(feature = "full")]
|
||||||
|
#![cfg(unix)]
|
||||||
|
|
||||||
mod support {
|
mod support {
|
||||||
pub mod signal;
|
pub mod signal;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#![cfg(unix)]
|
|
||||||
#![warn(rust_2018_idioms)]
|
#![warn(rust_2018_idioms)]
|
||||||
|
#![cfg(feature = "full")]
|
||||||
|
#![cfg(unix)]
|
||||||
|
|
||||||
mod support {
|
mod support {
|
||||||
pub mod signal;
|
pub mod signal;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#![cfg(unix)]
|
|
||||||
#![warn(rust_2018_idioms)]
|
#![warn(rust_2018_idioms)]
|
||||||
|
#![cfg(feature = "full")]
|
||||||
|
#![cfg(unix)]
|
||||||
|
|
||||||
use tokio::signal::unix::{signal, SignalKind};
|
use tokio::signal::unix::{signal, SignalKind};
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#![cfg(unix)]
|
|
||||||
#![warn(rust_2018_idioms)]
|
#![warn(rust_2018_idioms)]
|
||||||
|
#![cfg(feature = "full")]
|
||||||
|
#![cfg(unix)]
|
||||||
|
|
||||||
mod support {
|
mod support {
|
||||||
pub mod signal;
|
pub mod signal;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#![cfg(unix)]
|
|
||||||
#![warn(rust_2018_idioms)]
|
#![warn(rust_2018_idioms)]
|
||||||
|
#![cfg(feature = "full")]
|
||||||
|
#![cfg(unix)]
|
||||||
|
|
||||||
mod support {
|
mod support {
|
||||||
pub mod signal;
|
pub mod signal;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#![cfg(unix)]
|
|
||||||
#![warn(rust_2018_idioms)]
|
#![warn(rust_2018_idioms)]
|
||||||
|
#![cfg(feature = "full")]
|
||||||
|
#![cfg(unix)]
|
||||||
|
|
||||||
mod support {
|
mod support {
|
||||||
pub mod signal;
|
pub mod signal;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#![warn(rust_2018_idioms)]
|
#![warn(rust_2018_idioms)]
|
||||||
|
#![cfg(feature = "full")]
|
||||||
|
|
||||||
use tokio::sync::Barrier;
|
use tokio::sync::Barrier;
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#![warn(rust_2018_idioms)]
|
#![warn(rust_2018_idioms)]
|
||||||
|
#![cfg(feature = "full")]
|
||||||
|
|
||||||
fn is_error<T: ::std::error::Error + Send + Sync>() {}
|
fn is_error<T: ::std::error::Error + Send + Sync>() {}
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#![warn(rust_2018_idioms)]
|
#![warn(rust_2018_idioms)]
|
||||||
|
#![cfg(feature = "full")]
|
||||||
|
|
||||||
use tokio::sync::mpsc;
|
use tokio::sync::mpsc;
|
||||||
use tokio::sync::mpsc::error::TrySendError;
|
use tokio::sync::mpsc::error::TrySendError;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#![warn(rust_2018_idioms)]
|
#![warn(rust_2018_idioms)]
|
||||||
|
#![cfg(feature = "full")]
|
||||||
|
|
||||||
use tokio::sync::Mutex;
|
use tokio::sync::Mutex;
|
||||||
use tokio_test::task::spawn;
|
use tokio_test::task::spawn;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#![warn(rust_2018_idioms)]
|
#![warn(rust_2018_idioms)]
|
||||||
|
#![cfg(feature = "full")]
|
||||||
|
|
||||||
use tokio::sync::oneshot;
|
use tokio::sync::oneshot;
|
||||||
use tokio_test::*;
|
use tokio_test::*;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#![warn(rust_2018_idioms)]
|
#![warn(rust_2018_idioms)]
|
||||||
|
#![cfg(feature = "full")]
|
||||||
|
|
||||||
use tokio::sync::watch;
|
use tokio::sync::watch;
|
||||||
use tokio_test::task::spawn;
|
use tokio_test::task::spawn;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#![warn(rust_2018_idioms)]
|
#![warn(rust_2018_idioms)]
|
||||||
|
#![cfg(feature = "full")]
|
||||||
|
|
||||||
use tokio::net::{TcpListener, TcpStream};
|
use tokio::net::{TcpListener, TcpStream};
|
||||||
use tokio::sync::oneshot;
|
use tokio::sync::oneshot;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#![warn(rust_2018_idioms)]
|
#![warn(rust_2018_idioms)]
|
||||||
|
#![cfg(feature = "full")]
|
||||||
|
|
||||||
use tokio::net::{TcpListener, TcpStream};
|
use tokio::net::{TcpListener, TcpStream};
|
||||||
use tokio::sync::oneshot;
|
use tokio::sync::oneshot;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#![warn(rust_2018_idioms)]
|
#![warn(rust_2018_idioms)]
|
||||||
|
#![cfg(feature = "full")]
|
||||||
|
|
||||||
use tokio::net::{TcpListener, TcpStream};
|
use tokio::net::{TcpListener, TcpStream};
|
||||||
use tokio::prelude::*;
|
use tokio::prelude::*;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#![warn(rust_2018_idioms)]
|
#![warn(rust_2018_idioms)]
|
||||||
|
#![cfg(feature = "full")]
|
||||||
|
|
||||||
use tokio::io::AsyncReadExt;
|
use tokio::io::AsyncReadExt;
|
||||||
use tokio::net::TcpStream;
|
use tokio::net::TcpStream;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#![warn(rust_2018_idioms)]
|
#![warn(rust_2018_idioms)]
|
||||||
|
#![cfg(feature = "full")]
|
||||||
|
|
||||||
use tokio::io::AsyncWriteExt;
|
use tokio::io::AsyncWriteExt;
|
||||||
use tokio::net::{TcpListener, TcpStream};
|
use tokio::net::{TcpListener, TcpStream};
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#![warn(rust_2018_idioms)]
|
#![warn(rust_2018_idioms)]
|
||||||
|
#![cfg(feature = "full")]
|
||||||
|
|
||||||
use tokio::time::{self, Duration, Instant};
|
use tokio::time::{self, Duration, Instant};
|
||||||
use tokio_test::{assert_pending, assert_ready_eq, task};
|
use tokio_test::{assert_pending, assert_ready_eq, task};
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#![warn(rust_2018_idioms)]
|
#![warn(rust_2018_idioms)]
|
||||||
|
#![cfg(feature = "full")]
|
||||||
|
|
||||||
use tokio::time::*;
|
use tokio::time::*;
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#![warn(rust_2018_idioms)]
|
#![warn(rust_2018_idioms)]
|
||||||
|
#![cfg(feature = "full")]
|
||||||
|
|
||||||
use tokio::sync::oneshot;
|
use tokio::sync::oneshot;
|
||||||
use tokio::time::{self, timeout, timeout_at, Instant};
|
use tokio::time::{self, timeout, timeout_at, Instant};
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#![warn(rust_2018_idioms)]
|
#![warn(rust_2018_idioms)]
|
||||||
|
#![cfg(feature = "full")]
|
||||||
|
|
||||||
use tokio::net::UdpSocket;
|
use tokio::net::UdpSocket;
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#![cfg(unix)]
|
#![warn(rust_2018_idioms)]
|
||||||
#![cfg(not(target_os = "dragonfly"))]
|
#![cfg(feature = "full")]
|
||||||
|
#![cfg(all(unix, not(target_os = "dragonfly")))]
|
||||||
|
|
||||||
use tokio::net::UnixStream;
|
use tokio::net::UnixStream;
|
||||||
|
|
||||||
|
@ -1,37 +1,11 @@
|
|||||||
#![cfg(unix)]
|
|
||||||
#![warn(rust_2018_idioms)]
|
#![warn(rust_2018_idioms)]
|
||||||
|
#![cfg(feature = "full")]
|
||||||
|
#![cfg(unix)]
|
||||||
|
|
||||||
use tokio::net::unix::*;
|
use tokio::net::unix::*;
|
||||||
|
|
||||||
use std::io;
|
use std::io;
|
||||||
|
|
||||||
// struct StringDatagramCodec;
|
|
||||||
|
|
||||||
// /// A codec to decode datagrams from a unix domain socket as utf-8 text messages.
|
|
||||||
// impl Encoder for StringDatagramCodec {
|
|
||||||
// type Item = String;
|
|
||||||
// type Error = io::Error;
|
|
||||||
|
|
||||||
// fn encode(&mut self, item: Self::Item, dst: &mut BytesMut) -> Result<(), Self::Error> {
|
|
||||||
// dst.extend_from_slice(&item.into_bytes());
|
|
||||||
// Ok(())
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// /// A codec to decode datagrams from a unix domain socket as utf-8 text messages.
|
|
||||||
// impl Decoder for StringDatagramCodec {
|
|
||||||
// type Item = String;
|
|
||||||
// type Error = io::Error;
|
|
||||||
|
|
||||||
// fn decode(&mut self, buf: &mut BytesMut) -> Result<Option<Self::Item>, Self::Error> {
|
|
||||||
// let decoded = str::from_utf8(buf)
|
|
||||||
// .map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))?
|
|
||||||
// .to_string();
|
|
||||||
|
|
||||||
// Ok(Some(decoded))
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
async fn echo_server(mut socket: UnixDatagram) -> io::Result<()> {
|
async fn echo_server(mut socket: UnixDatagram) -> io::Result<()> {
|
||||||
let mut recv_buf = vec![0u8; 1024];
|
let mut recv_buf = vec![0u8; 1024];
|
||||||
loop {
|
loop {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
|
#![warn(rust_2018_idioms)]
|
||||||
|
#![cfg(feature = "full")]
|
||||||
#![cfg(unix)]
|
#![cfg(unix)]
|
||||||
#![deny(warnings, rust_2018_idioms)]
|
|
||||||
|
|
||||||
use tokio::net::UnixStream;
|
use tokio::net::UnixStream;
|
||||||
use tokio::prelude::*;
|
use tokio::prelude::*;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#![cfg(unix)]
|
#![cfg(feature = "full")]
|
||||||
#![warn(rust_2018_idioms)]
|
#![warn(rust_2018_idioms)]
|
||||||
|
#![cfg(unix)]
|
||||||
|
|
||||||
use tokio::io::{AsyncReadExt, AsyncWriteExt};
|
use tokio::io::{AsyncReadExt, AsyncWriteExt};
|
||||||
use tokio::net::unix::*;
|
use tokio::net::unix::*;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user