mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-27 00:00:12 +02:00
tcp: move tokio-tcp into tokio-net (#1456)
This commit is contained in:
@@ -14,7 +14,6 @@ members = [
|
||||
"tokio-sync",
|
||||
"tokio-test",
|
||||
"tokio-timer",
|
||||
"tokio-tcp",
|
||||
"tokio-tls",
|
||||
"tokio-udp",
|
||||
"tokio-uds",
|
||||
|
||||
@@ -140,10 +140,7 @@ The crates included as part of Tokio are:
|
||||
|
||||
* [`tokio-macros`]: Macros for usage with Tokio.
|
||||
|
||||
* [`tokio-net`]: Event loop that drives I/O resources (like TCP and UDP
|
||||
sockets).
|
||||
|
||||
* [`tokio-tcp`]: TCP listener and acceptor.
|
||||
* [`tokio-net`]: Event loop that drives I/O resources as well as TCP apis.
|
||||
|
||||
* [ `tokio-timer`]: Time related APIs.
|
||||
|
||||
@@ -158,7 +155,6 @@ The crates included as part of Tokio are:
|
||||
[`tokio-io`]: tokio-io
|
||||
[`tokio-macros`]: tokio-macros
|
||||
[`tokio-net`]: tokio-net
|
||||
[`tokio-tcp`]: tokio-tcp
|
||||
[`tokio-timer`]: tokio-timer
|
||||
[`tokio-udp`]: tokio-udp
|
||||
[`tokio-uds`]: tokio-uds
|
||||
|
||||
+6
-3
@@ -47,11 +47,10 @@ jobs:
|
||||
rust: $(nightly)
|
||||
crates:
|
||||
tokio-fs: []
|
||||
tokio-net: []
|
||||
tokio-net:
|
||||
- tcp
|
||||
tokio-process: []
|
||||
tokio-signal: []
|
||||
tokio-tcp:
|
||||
- async-traits
|
||||
tokio-udp: []
|
||||
tokio-uds:
|
||||
- async-traits
|
||||
@@ -85,7 +84,11 @@ jobs:
|
||||
rust: $(nightly)
|
||||
crates:
|
||||
ui-tests:
|
||||
- tokio-executor
|
||||
- tokio-net
|
||||
- executor-without-current-thread
|
||||
- net-no-features
|
||||
- net-with-tcp
|
||||
- tokio-no-features
|
||||
- tokio-with-net
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@ tokio-net = { path = "tokio-net" }
|
||||
tokio-signal = { path = "tokio-signal" }
|
||||
tokio-sync = { path = "tokio-sync" }
|
||||
tokio-timer = { path = "tokio-timer" }
|
||||
tokio-tcp = { path = "tokio-tcp" }
|
||||
tokio-tls = { path = "tokio-tls" }
|
||||
tokio-udp = { path = "tokio-udp" }
|
||||
tokio-uds = { path = "tokio-uds" }
|
||||
|
||||
+21
-5
@@ -20,20 +20,36 @@ Event loop that drives Tokio I/O resources.
|
||||
"""
|
||||
categories = ["asynchronous", "network-programming"]
|
||||
|
||||
[features]
|
||||
async-traits = []
|
||||
tcp = [
|
||||
"bytes",
|
||||
"futures-util-preview",
|
||||
"iovec",
|
||||
]
|
||||
|
||||
[dependencies]
|
||||
tokio-executor = { version = "=0.2.0-alpha.1", path = "../tokio-executor" }
|
||||
tokio-io = { version = "=0.2.0-alpha.1", path = "../tokio-io" }
|
||||
tokio-sync = { version = "=0.2.0-alpha.1", path = "../tokio-sync" }
|
||||
|
||||
# driver implementation
|
||||
crossbeam-utils = "0.6.0"
|
||||
futures-core-preview = "=0.3.0-alpha.18"
|
||||
lazy_static = "1.0.2"
|
||||
log = "0.4.6"
|
||||
mio = "0.6.14"
|
||||
num_cpus = "1.8.0"
|
||||
parking_lot = "0.9"
|
||||
slab = "0.4.0"
|
||||
tokio-executor = { version = "=0.2.0-alpha.1", path = "../tokio-executor" }
|
||||
tokio-io = { version = "=0.2.0-alpha.1", path = "../tokio-io" }
|
||||
tokio-sync = { version = "=0.2.0-alpha.1", path = "../tokio-sync" }
|
||||
futures-core-preview = "=0.3.0-alpha.18"
|
||||
|
||||
# TCP
|
||||
bytes = { version = "0.4", optional = true }
|
||||
futures-util-preview = { version = "=0.3.0-alpha.18", optional = true }
|
||||
iovec = { version = "0.1", optional = true }
|
||||
|
||||
[dev-dependencies]
|
||||
num_cpus = "1.8.0"
|
||||
tokio = { version = "=0.2.0-alpha.1", path = "../tokio" }
|
||||
tokio-test = { version = "=0.2.0-alpha.1", path = "../tokio-test" }
|
||||
num_cpus = "1.8.0"
|
||||
tokio-io-pool = "0.1.4"
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
unreachable_pub
|
||||
)]
|
||||
#![doc(test(no_crate_inject, attr(deny(rust_2018_idioms))))]
|
||||
#![feature(async_await)]
|
||||
|
||||
//! Event loop that drives Tokio I/O resources.
|
||||
//!
|
||||
@@ -38,3 +39,6 @@
|
||||
|
||||
pub mod driver;
|
||||
pub mod util;
|
||||
|
||||
#[cfg(feature = "tcp")]
|
||||
pub mod tcp;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
use super::TcpListener;
|
||||
use super::TcpStream;
|
||||
|
||||
use futures_core::ready;
|
||||
use futures_core::stream::Stream;
|
||||
use std::io;
|
||||
@@ -1,9 +1,8 @@
|
||||
#[cfg(feature = "async-traits")]
|
||||
use super::incoming::Incoming;
|
||||
use super::TcpStream;
|
||||
|
||||
use tokio_net::driver::Handle;
|
||||
use tokio_net::util::PollEvented;
|
||||
use crate::driver::Handle;
|
||||
use crate::util::PollEvented;
|
||||
|
||||
use futures_core::ready;
|
||||
use futures_util::future::poll_fn;
|
||||
@@ -1,13 +1,3 @@
|
||||
#![doc(html_root_url = "https://docs.rs/tokio-tcp/0.2.0-alpha.1")]
|
||||
#![warn(
|
||||
missing_debug_implementations,
|
||||
missing_docs,
|
||||
rust_2018_idioms,
|
||||
unreachable_pub
|
||||
)]
|
||||
#![doc(test(no_crate_inject, attr(deny(rust_2018_idioms))))]
|
||||
#![feature(async_await)]
|
||||
|
||||
//! TCP bindings for `tokio`.
|
||||
//!
|
||||
//! This module contains the TCP networking types, similar to the standard
|
||||
@@ -13,6 +13,9 @@
|
||||
//! addresses, to get and set socket options, and to shutdown the sockets.
|
||||
|
||||
use super::TcpStream;
|
||||
|
||||
use tokio_io::{AsyncRead, AsyncWrite};
|
||||
|
||||
use bytes::{Buf, BufMut};
|
||||
use std::error::Error;
|
||||
use std::fmt;
|
||||
@@ -21,7 +24,6 @@ use std::net::Shutdown;
|
||||
use std::pin::Pin;
|
||||
use std::sync::Arc;
|
||||
use std::task::{Context, Poll};
|
||||
use tokio_io::{AsyncRead, AsyncWrite};
|
||||
|
||||
/// Read half of a `TcpStream`.
|
||||
#[derive(Debug)]
|
||||
@@ -89,7 +91,7 @@ impl TcpStreamReadHalf {
|
||||
// reader and one for the writer, and those `Arc`s are never exposed
|
||||
// externally. And so when we drop one here, the other one must be
|
||||
// the only remaining one.
|
||||
Ok(Arc::try_unwrap(self.0).expect("tokio_tcp: try_unwrap failed in reunite"))
|
||||
Ok(Arc::try_unwrap(self.0).expect("tcp: try_unwrap failed in reunite"))
|
||||
} else {
|
||||
Err(ReuniteError(self, other))
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
use crate::split::{
|
||||
use super::split::{
|
||||
split, split_mut, TcpStreamReadHalf, TcpStreamReadHalfMut, TcpStreamWriteHalf,
|
||||
TcpStreamWriteHalfMut,
|
||||
};
|
||||
use crate::driver::Handle;
|
||||
use crate::util::PollEvented;
|
||||
|
||||
use tokio_io::{AsyncRead, AsyncWrite};
|
||||
use tokio_net::driver::Handle;
|
||||
use tokio_net::util::PollEvented;
|
||||
|
||||
use bytes::{Buf, BufMut};
|
||||
use futures_core::ready;
|
||||
@@ -1,6 +1,6 @@
|
||||
#![feature(async_await)]
|
||||
|
||||
use tokio_tcp::{TcpListener, TcpStream};
|
||||
use tokio_net::tcp::{TcpListener, TcpStream};
|
||||
|
||||
#[tokio::test]
|
||||
async fn split_reunite() -> std::io::Result<()> {
|
||||
@@ -1,21 +0,0 @@
|
||||
# 0.2.0-alpha.1 (August 8, 2019)
|
||||
|
||||
### Changed
|
||||
- Switch to `async`, `await`, and `std::future`.
|
||||
|
||||
# 0.1.3 (January 6, 2019)
|
||||
|
||||
* Deprecate `TcpStream::try_clone()` (#824).
|
||||
* Add examples to TcpListener and TcpStream API docs (#775).
|
||||
|
||||
# 0.1.2 (September 27, 2018)
|
||||
|
||||
* Documentation tweaks
|
||||
|
||||
# 0.1.1 (August 6, 2018)
|
||||
|
||||
* Add `TcpStream::try_clone` (#448)
|
||||
|
||||
# 0.1.0 (March 23, 2018)
|
||||
|
||||
* Initial release
|
||||
@@ -1,38 +0,0 @@
|
||||
[package]
|
||||
name = "tokio-tcp"
|
||||
# When releasing to crates.io:
|
||||
# - Remove path dependencies
|
||||
# - Update html_root_url.
|
||||
# - Update doc url
|
||||
# - Cargo.toml
|
||||
# - Update CHANGELOG.md.
|
||||
# - Create "v0.2.x" git tag.
|
||||
version = "0.2.0-alpha.1"
|
||||
edition = "2018"
|
||||
authors = ["Tokio Contributors <[email protected]>"]
|
||||
license = "MIT"
|
||||
repository = "https://github.com/tokio-rs/tokio"
|
||||
homepage = "https://tokio.rs"
|
||||
documentation = "https://docs.rs/tokio-tcp/0.2.0-alpha.1/tokio_tcp"
|
||||
description = """
|
||||
TCP bindings for tokio.
|
||||
"""
|
||||
categories = ["asynchronous"]
|
||||
|
||||
[features]
|
||||
async-traits = []
|
||||
|
||||
[dependencies]
|
||||
tokio-io = { version = "=0.2.0-alpha.1", path = "../tokio-io" }
|
||||
tokio-net = { version = "=0.2.0-alpha.1", path = "../tokio-net" }
|
||||
|
||||
futures-core-preview = "=0.3.0-alpha.18"
|
||||
futures-util-preview = "=0.3.0-alpha.18"
|
||||
bytes = "0.4"
|
||||
mio = "0.6.14"
|
||||
iovec = "0.1"
|
||||
|
||||
|
||||
[dev-dependencies]
|
||||
tokio = { version = "=0.2.0-alpha.1", path = "../tokio" }
|
||||
tokio-test = { version = "=0.2.0-alpha.1", path = "../tokio-test" }
|
||||
@@ -1,25 +0,0 @@
|
||||
Copyright (c) 2019 Tokio Contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any
|
||||
person obtaining a copy of this software and associated
|
||||
documentation files (the "Software"), to deal in the
|
||||
Software without restriction, including without
|
||||
limitation the rights to use, copy, modify, merge,
|
||||
publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software
|
||||
is furnished to do so, subject to the following
|
||||
conditions:
|
||||
|
||||
The above copyright notice and this permission notice
|
||||
shall be included in all copies or substantial portions
|
||||
of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
|
||||
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
||||
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
|
||||
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
|
||||
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
@@ -1,13 +0,0 @@
|
||||
# tokio-tcp
|
||||
|
||||
TCP bindings for `tokio`.
|
||||
|
||||
## License
|
||||
|
||||
This project is licensed under the [MIT license](./LICENSE).
|
||||
|
||||
### Contribution
|
||||
|
||||
Unless you explicitly state otherwise, any contribution intentionally submitted
|
||||
for inclusion in Tokio by you, shall be licensed as MIT, without any additional
|
||||
terms or conditions.
|
||||
@@ -30,7 +30,7 @@ tokio-io = { version = "=0.2.0-alpha.1", path = "../tokio-io" }
|
||||
|
||||
[dev-dependencies]
|
||||
tokio = { version = "=0.2.0-alpha.1", path = "../tokio" }
|
||||
tokio-tcp = { version = "=0.2.0-alpha.1", path = "../tokio-tcp", features = ["async-traits"] }
|
||||
tokio-net = { version = "=0.2.0-alpha.1", path = "../tokio-net", features = ["tcp", "async-traits"] }
|
||||
|
||||
cfg-if = "0.1"
|
||||
env_logger = { version = "0.6", default-features = false }
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#![doc(html_root_url = "https://docs.rs/tokio-tcp/0.2.0-alpha.1")]
|
||||
#![doc(html_root_url = "https://docs.rs/tokio-udp/0.2.0-alpha.1")]
|
||||
#![warn(
|
||||
missing_debug_implementations,
|
||||
missing_docs,
|
||||
|
||||
+2
-3
@@ -49,7 +49,7 @@ rt-full = [
|
||||
"tracing-core",
|
||||
]
|
||||
sync = ["tokio-sync"]
|
||||
tcp = ["io", "tokio-net", "tokio-tcp"]
|
||||
tcp = ["io", "tokio-net/tcp"]
|
||||
timer = ["tokio-timer"]
|
||||
udp = ["io", "tokio-net", "tokio-udp"]
|
||||
uds = ["io", "tokio-net", "tokio-uds"]
|
||||
@@ -67,9 +67,8 @@ tokio-fs = { version = "=0.2.0-alpha.1", optional = true, path = "../tokio-fs" }
|
||||
tokio-io = { version = "=0.2.0-alpha.1", optional = true, features = ["util"], path = "../tokio-io" }
|
||||
tokio-executor = { version = "=0.2.0-alpha.1", optional = true, path = "../tokio-executor" }
|
||||
tokio-macros = { version = "=0.2.0-alpha.1", optional = true, path = "../tokio-macros" }
|
||||
tokio-net = { version = "=0.2.0-alpha.1", optional = true, path = "../tokio-net" }
|
||||
tokio-net = { version = "=0.2.0-alpha.1", optional = true, features = ["async-traits"], path = "../tokio-net" }
|
||||
tokio-sync = { version = "=0.2.0-alpha.1", optional = true, path = "../tokio-sync", features = ["async-traits"] }
|
||||
tokio-tcp = { version = "=0.2.0-alpha.1", optional = true, path = "../tokio-tcp", features = ["async-traits"] }
|
||||
tokio-udp = { version = "=0.2.0-alpha.1", optional = true, path = "../tokio-udp" }
|
||||
tokio-timer = { version = "=0.3.0-alpha.1", optional = true, path = "../tokio-timer", features = ["async-traits"] }
|
||||
tracing-core = { version = "0.1", optional = true }
|
||||
|
||||
+1
-1
@@ -40,7 +40,7 @@ pub mod tcp {
|
||||
//! [`TcpListener`]: struct.TcpListener.html
|
||||
//! [incoming_method]: struct.TcpListener.html#method.incoming
|
||||
//! [`Incoming`]: struct.Incoming.html
|
||||
pub use tokio_tcp::{split, TcpListener, TcpStream};
|
||||
pub use tokio_net::tcp::{split, TcpListener, TcpStream};
|
||||
}
|
||||
#[cfg(feature = "tcp")]
|
||||
pub use self::tcp::{TcpListener, TcpStream};
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#![cfg(feature = "default")]
|
||||
|
||||
use tokio_net::driver::Reactor;
|
||||
use tokio_tcp::TcpListener;
|
||||
use tokio_net::tcp::TcpListener;
|
||||
use tokio_test::{assert_ok, assert_pending};
|
||||
|
||||
use futures_util::task::{waker_ref, ArcWake};
|
||||
|
||||
@@ -7,6 +7,8 @@ publish = false
|
||||
|
||||
[features]
|
||||
executor-without-current-thread = ["tokio-executor"]
|
||||
net-no-features = ["tokio-net"]
|
||||
net-with-tcp = ["tokio-net/tcp"]
|
||||
tokio-no-features = ["tokio"]
|
||||
tokio-with-net = ["tokio/net"]
|
||||
|
||||
@@ -14,6 +16,7 @@ tokio-with-net = ["tokio/net"]
|
||||
|
||||
[dependencies]
|
||||
tokio-executor = { path = "../tokio-executor", optional = true }
|
||||
tokio-net = { path = "../tokio-net", optional = true }
|
||||
tokio = { path = "../tokio", optional = true, default-features = false }
|
||||
|
||||
[dev-dependencies]
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
#[cfg(feature = "tokio-executor")]
|
||||
pub use tokio_executor;
|
||||
|
||||
#[cfg(feature = "tokio-net")]
|
||||
pub use tokio_net;
|
||||
|
||||
#[cfg(feature = "tokio")]
|
||||
pub use tokio;
|
||||
|
||||
@@ -1,6 +1,20 @@
|
||||
#![allow(unused_imports)]
|
||||
|
||||
#[test]
|
||||
#[cfg(feature = "tokio-net")]
|
||||
fn net_default() {
|
||||
use ui_tests::tokio_net::driver::{set_default, Handle, Reactor, Registration};
|
||||
use ui_tests::tokio_net::util::PollEvented;
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(feature = "net-with-tcp")]
|
||||
fn net_with_tcp() {
|
||||
use ui_tests::tokio_net::tcp;
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(feature = "tokio-with-net")]
|
||||
#[allow(unused_imports)]
|
||||
fn tokio_with_net() {
|
||||
// net is present
|
||||
use ui_tests::tokio::net;
|
||||
@@ -12,6 +26,9 @@ fn compile_fail() {
|
||||
#[cfg(feature = "executor-without-current-thread")]
|
||||
t.compile_fail("tests/ui/executor_without_current_thread.rs");
|
||||
|
||||
#[cfg(feature = "net-no-features")]
|
||||
t.compile_fail("tests/ui/net_without_tcp_missing_tcp.rs");
|
||||
|
||||
#[cfg(feature = "tokio-no-features")]
|
||||
t.compile_fail("tests/ui/tokio_without_net_missing_net.rs");
|
||||
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
use ui_tests::tokio_net::tcp;
|
||||
|
||||
fn main() {}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
error[E0432]: unresolved import `ui_tests::tokio_net::tcp`
|
||||
--> $DIR/net_without_tcp_missing_tcp.rs:1:5
|
||||
|
|
||||
1 | use ui_tests::tokio_net::tcp;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ no `tcp` in `tokio_net`
|
||||
|
||||
For more information about this error, try `rustc --explain E0432`.
|
||||
Reference in New Issue
Block a user