diff options
-rw-r--r-- | Cargo.toml | 13 | ||||
-rw-r--r-- | README.md | 6 | ||||
-rw-r--r-- | src/lib.rs | 24 | ||||
-rw-r--r-- | src/net.rs (renamed from src/net/mod.rs) | 9 | ||||
-rw-r--r-- | src/net/tcp/mod.rs | 8 | ||||
-rw-r--r-- | src/net/udp/mod.rs | 9 | ||||
-rw-r--r-- | tokio-tcp/CHANGELOG.md | 3 | ||||
-rw-r--r-- | tokio-tcp/Cargo.toml | 33 | ||||
-rw-r--r-- | tokio-tcp/LICENSE | 25 | ||||
-rw-r--r-- | tokio-tcp/README.md | 15 | ||||
-rw-r--r-- | tokio-tcp/src/incoming.rs (renamed from src/net/tcp/incoming.rs) | 4 | ||||
-rw-r--r-- | tokio-tcp/src/lib.rs | 59 | ||||
-rw-r--r-- | tokio-tcp/src/listener.rs (renamed from src/net/tcp/listener.rs) | 13 | ||||
-rw-r--r-- | tokio-tcp/src/stream.rs (renamed from src/net/tcp/stream.rs) | 13 | ||||
-rw-r--r-- | tokio-tcp/tests/chain.rs (renamed from tests/chain.rs) | 4 | ||||
-rw-r--r-- | tokio-tcp/tests/echo.rs (renamed from tests/echo.rs) | 4 | ||||
-rw-r--r-- | tokio-tcp/tests/limit.rs (renamed from tests/limit.rs) | 4 | ||||
-rw-r--r-- | tokio-tcp/tests/stream-buffered.rs (renamed from tests/stream-buffered.rs) | 4 | ||||
-rw-r--r-- | tokio-tcp/tests/tcp.rs (renamed from tests/tcp.rs) | 14 | ||||
-rw-r--r-- | tokio-udp/CHANGELOG.md | 3 | ||||
-rw-r--r-- | tokio-udp/Cargo.toml | 33 | ||||
-rw-r--r-- | tokio-udp/LICENSE | 25 | ||||
-rw-r--r-- | tokio-udp/README.md | 15 | ||||
-rw-r--r-- | tokio-udp/src/frame.rs (renamed from src/net/udp/frame.rs) | 2 | ||||
-rw-r--r-- | tokio-udp/src/lib.rs | 42 | ||||
-rw-r--r-- | tokio-udp/src/recv_dgram.rs (renamed from src/net/udp/recv_dgram.rs) | 2 | ||||
-rw-r--r-- | tokio-udp/src/send_dgram.rs (renamed from src/net/udp/send_dgram.rs) | 2 | ||||
-rw-r--r-- | tokio-udp/src/socket.rs (renamed from src/net/udp/socket.rs) | 10 | ||||
-rw-r--r-- | tokio-udp/tests/udp.rs (renamed from tests/udp.rs) | 4 |
29 files changed, 312 insertions, 90 deletions
@@ -27,6 +27,8 @@ members = [ "tokio-io", "tokio-reactor", "tokio-threadpool", + "tokio-tcp", + "tokio-udp", "futures2", ] @@ -39,15 +41,14 @@ tokio-io = { version = "0.1.6", path = "tokio-io" } tokio-executor = { version = "0.1.0", path = "tokio-executor" } tokio-reactor = { version = "0.1.0", path = "tokio-reactor" } tokio-threadpool = { version = "0.1.0", path = "tokio-threadpool" } -bytes = "0.4" -log = "0.4" +tokio-tcp = { version = "0.1.0", path = "tokio-tcp" } +tokio-udp = { version = "0.1.0", path = "tokio-udp" } mio = "0.6.14" -slab = "0.4" -iovec = "0.1" futures = "0.1.18" futures2 = { version = "0.1", path = "futures2", optional = true } [dev-dependencies] +bytes = "0.4" env_logger = { version = "0.4", default-features = false } flate2 = { version = "1", features = ["tokio"] } futures-cpupool = "0.1" @@ -68,6 +69,8 @@ unstable-futures = [ "futures2", "tokio-reactor/unstable-futures", "tokio-threadpool/unstable-futures", - "tokio-executor/unstable-futures" + "tokio-executor/unstable-futures", + "tokio-tcp/unstable-futures", + "tokio-udp/unstable-futures" ] default = [] @@ -117,10 +117,16 @@ The crates included as part of Tokio are: * [`tokio-threadpool`]: Schedules the execution of futures across a pool of threads. +* [`tokio-tcp`]: TCP bindings for use with `tokio-io` and `tokio-reactor`. + +* [`tokio-udp`]: UDP bindings for use with `tokio-io` and `tokio-reactor`. + [`tokio-executor`]: tokio-executor [`tokio-io`]: tokio-io [`tokio-reactor`]: tokio-reactor [`tokio-threadpool`]: tokio-threadpool +[`tokio-tcp`]: tokio-tcp +[`tokio-udp`]: tokio-udp ## License @@ -65,19 +65,15 @@ #![doc(html_root_url = "https://docs.rs/tokio/0.1.3")] #![deny(missing_docs, warnings, missing_debug_implementations)] -extern crate bytes; #[macro_use] extern crate futures; -extern crate iovec; extern crate mio; -extern crate slab; extern crate tokio_io; extern crate tokio_executor; extern crate tokio_reactor; extern crate tokio_threadpool; - -#[macro_use] -extern crate log; +extern crate tokio_tcp; +extern crate tokio_udp; #[cfg(feature = "unstable-futures")] extern crate futures2; @@ -190,19 +186,3 @@ pub mod prelude { task, }; } - -#[cfg(feature = "unstable-futures")] -fn lift_async<T>(old: futures::Async<T>) -> futures2::Async<T> { - match old { - futures::Async::Ready(x) => futures2::Async::Ready(x), - futures::Async::NotReady => futures2::Async::Pending, - } -} - -#[cfg(feature = "unstable-futures")] -fn lower_async<T>(new: futures2::Async<T>) -> futures::Async<T> { - match new { - futures2::Async::Ready(x) => futures::Async::Ready(x), - futures2::Async::Pending => futures::Async::NotReady, - } -} diff --git a/src/net/mod.rs b/src/net.rs index 077e886a..f3378eea 100644 --- a/src/net/mod.rs +++ b/src/net.rs @@ -36,9 +36,6 @@ //! [`UdpFramed`]: struct.UdpFramed.html //! [`framed`]: struct.UdpSocket.html#method.framed -mod tcp; -mod udp; - -pub use self::tcp::{TcpStream, ConnectFuture}; -pub use self::tcp::{TcpListener, Incoming}; -pub use self::udp::{UdpSocket, UdpFramed, SendDgram, RecvDgram}; +pub use tokio_tcp::{TcpStream, ConnectFuture}; +pub use tokio_tcp::{TcpListener, Incoming}; +pub use tokio_udp::{UdpSocket, UdpFramed, SendDgram, RecvDgram}; diff --git a/src/net/tcp/mod.rs b/src/net/tcp/mod.rs deleted file mode 100644 index 5454510c..00000000 --- a/src/net/tcp/mod.rs +++ /dev/null @@ -1,8 +0,0 @@ -mod incoming; -mod listener; -mod stream; - -pub use self::incoming::Incoming; -pub use self::listener::TcpListener; -pub use self::stream::TcpStream; -pub use self::stream::ConnectFuture; diff --git a/src/net/udp/mod.rs b/src/net/udp/mod.rs deleted file mode 100644 index 0610b4d2..00000000 --- a/src/net/udp/mod.rs +++ /dev/null @@ -1,9 +0,0 @@ -mod frame; -mod socket; -mod send_dgram; -mod recv_dgram; - -pub use self::frame::UdpFramed; -pub use self::socket::UdpSocket; -pub use self::send_dgram::SendDgram; -pub use self::recv_dgram::RecvDgram; diff --git a/tokio-tcp/CHANGELOG.md b/tokio-tcp/CHANGELOG.md new file mode 100644 index 00000000..fb22aa7c --- /dev/null +++ b/tokio-tcp/CHANGELOG.md @@ -0,0 +1,3 @@ +# 0.1.0 (unreleased) + +* Initial release diff --git a/tokio-tcp/Cargo.toml b/tokio-tcp/Cargo.toml new file mode 100644 index 00000000..00a25dfb --- /dev/null +++ b/tokio-tcp/Cargo.toml @@ -0,0 +1,33 @@ +[package] +name = "tokio-tcp" + +# When releasing to crates.io: +# - Update html_root_url. +# - Update CHANGELOG.md. +# - Create "v0.1.x" git tag. +version = "0.1.0" +authors = ["Carl Lerche <me@carllerche.com>"] +license = "MIT" +repository = "https://github.com/tokio-rs/tokio" +homepage = "https://tokio.rs" +documentation = "https://docs.rs/tokio-tcp/0.1" +description = """ +TCP bindings for tokio. +""" +categories = ["asynchronous"] + +[dependencies] +tokio-io = { version = "0.1.6", path = "../tokio-io" } +tokio-reactor = { version = "0.1.0", path = "../tokio-reactor" } +bytes = "0.4" +mio = "0.6.14" +iovec = "0.1" +futures = "0.1.18" +futures2 = { version = "0.1", path = "../futures2", optional = true } + +[dev-dependencies] +env_logger = { version = "0.4", default-features = false } + +[features] +unstable-futures = ["futures2"] +default = [] diff --git a/tokio-tcp/LICENSE b/tokio-tcp/LICENSE new file mode 100644 index 00000000..38c1e27b --- /dev/null +++ b/tokio-tcp/LICENSE @@ -0,0 +1,25 @@ +Copyright (c) 2018 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. diff --git a/tokio-tcp/README.md b/tokio-tcp/README.md new file mode 100644 index 00000000..9cfc177b --- /dev/null +++ b/tokio-tcp/README.md @@ -0,0 +1,15 @@ +# tokio-tcp + +TCP bindings for `tokio`. + +[Documentation](https://tokio-rs.github.io/tokio/tokio_tcp/) + +## 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. diff --git a/src/net/tcp/incoming.rs b/tokio-tcp/src/incoming.rs index 591acc20..6726224b 100644 --- a/src/net/tcp/incoming.rs +++ b/tokio-tcp/src/incoming.rs @@ -1,5 +1,5 @@ -use net::tcp::TcpListener; -use net::tcp::TcpStream; +use super::TcpListener; +use super::TcpStream; use std::io; use futures::stream::Stream; diff --git a/tokio-tcp/src/lib.rs b/tokio-tcp/src/lib.rs new file mode 100644 index 00000000..08d41623 --- /dev/null +++ b/tokio-tcp/src/lib.rs @@ -0,0 +1,59 @@ +//! TCP bindings for `tokio`. +//! +//! This module contains the TCP networking types, similar to the standard +//! library, which can be used to implement networking protocols. +//! +//! Connecting to an address, via TCP, can be done using [`TcpStream`]'s +//! [`connect`] method, which returns [`ConnectFuture`]. `ConnectFuture` +//! implements a future which returns a `TcpStream`. +//! +//! To listen on an address [`TcpListener`] can be used. `TcpListener`'s +//! [`incoming`][incoming_method] method can be used to accept new connections. +//! It return the [`Incoming`] struct, which implements a stream which returns +//! `TcpStream`s. +//! +//! [`TcpStream`]: struct.TcpStream.html +//! [`connect`]: struct.TcpStream.html#method.connect +//! [`ConnectFuture`]: struct.ConnectFuture.html +//! [`TcpListener`]: struct.TcpListener.html +//! [incoming_method]: struct.TcpListener.html#method.incoming +//! [`Incoming`]: struct.Incoming.html + +#![doc(html_root_url = "https://docs.rs/tokio-tcp/0.1.0")] +#![deny(missing_docs, warnings, missing_debug_implementations)] + +extern crate bytes; +#[macro_use] +extern crate futures; +extern crate iovec; +extern crate mio; +extern crate tokio_io; +extern crate tokio_reactor; + +#[cfg(feature = "unstable-futures")] +extern crate futures2; + +mod incoming; +mod listener; +mod stream; + +pub use self::incoming::Incoming; +pub use self::listener::TcpListener; +pub use self::stream::TcpStream; +pub use self::stream::ConnectFuture; + +#[cfg(feature = "unstable-futures")] +fn lift_async<T>(old: futures::Async<T>) -> futures2::Async<T> { + match old { + futures::Async::Ready(x) => futures2::Async::Ready(x), + futures::Async::NotReady => futures2::Async::Pending, + } +} + +#[cfg(feature = "unstable-futures")] +fn lower_async<T>(new: futures2::Async<T>) -> futures::Async<T> { + match new { + futures2::Async::Ready(x) => futures::Async::Ready(x), + futures2::Async::Pending => futures::Async::NotReady, + } +} diff --git a/src/net/tcp/listener.rs b/tokio-tcp/src/listener.rs index bc9a736a..41be8245 100644 --- a/src/net/tcp/listener.rs +++ b/tokio-tcp/src/listener.rs @@ -1,5 +1,5 @@ -use net::tcp::Incoming; -use net::tcp::TcpStream; +use super::Incoming; +use super::TcpStream; use std::fmt; use std::io; @@ -7,8 +7,7 @@ use std::net::{self, SocketAddr}; use futures::{Poll, Async}; use mio; - -use reactor::{Handle, PollEvented2}; +use tokio_reactor::{Handle, PollEvented}; #[cfg(feature = "unstable-futures")] use futures2; @@ -18,7 +17,7 @@ use futures2; /// This object can be converted into a stream of incoming connections for /// various forms of processing. pub struct TcpListener { - io: PollEvented2<mio::net::TcpListener>, + io: PollEvented<mio::net::TcpListener>, } impl TcpListener { @@ -174,12 +173,12 @@ impl TcpListener { -> io::Result<TcpListener> { let io = mio::net::TcpListener::from_std(listener)?; - let io = PollEvented2::new_with_handle(io, handle)?; + let io = PollEvented::new_with_handle(io, handle)?; Ok(TcpListener { io }) } fn new(listener: mio::net::TcpListener) -> TcpListener { - let io = PollEvented2::new(listener); + let io = PollEvented::new(listener); TcpListener { io } } diff --git a/src/net/tcp/stream.rs b/tokio-tcp/src/stream.rs index 602bd4bb..c0ae8765 100644 --- a/src/net/tcp/stream.rs +++ b/tokio-tcp/src/stream.rs @@ -9,8 +9,7 @@ use futures::{Future, Poll, Async}; use iovec::IoVec; use mio; use tokio_io::{AsyncRead, AsyncWrite}; - -use reactor::{Handle, PollEvented2}; +use tokio_reactor::{Handle, PollEvented}; #[cfg(feature = "unstable-futures")] use futures2; @@ -24,7 +23,7 @@ use futures2; /// [accepting]: struct.TcpListener.html#method.accept /// [listener]: struct.TcpListener.html pub struct TcpStream { - io: PollEvented2<mio::net::TcpStream>, + io: PollEvented<mio::net::TcpStream>, } /// Future returned by `TcpStream::connect` which will resolve to a `TcpStream` @@ -62,7 +61,7 @@ impl TcpStream { } pub(crate) fn new(connected: mio::net::TcpStream) -> TcpStream { - let io = PollEvented2::new(connected); + let io = PollEvented::new(connected); TcpStream { io } } @@ -76,7 +75,7 @@ impl TcpStream { -> io::Result<TcpStream> { let io = mio::net::TcpStream::from_stream(stream)?; - let io = PollEvented2::new_with_handle(io, handle)?; + let io = PollEvented::new_with_handle(io, handle)?; Ok(TcpStream { io }) } @@ -107,7 +106,7 @@ impl TcpStream { use self::ConnectFutureState::*; let io = mio::net::TcpStream::connect_stream(stream, addr) - .and_then(|io| PollEvented2::new_with_handle(io, handle)); + .and_then(|io| PollEvented::new_with_handle(io, handle)); let inner = match io { Ok(io) => Waiting(TcpStream { io }), @@ -584,7 +583,7 @@ impl futures2::Future for ConnectFuture { impl ConnectFutureState { fn poll_inner<F>(&mut self, f: F) -> Poll<TcpStream, io::Error> - where F: FnOnce(&mut PollEvented2<mio::net::TcpStream>) -> Poll<mio::Ready, io::Error> + where F: FnOnce(&mut PollEvented<mio::net::TcpStream>) -> Poll<mio::Ready, io::Error> { { let stream = match *self { diff --git a/tests/chain.rs b/tokio-tcp/tests/chain.rs index b9ac4818..c4e37f10 100644 --- a/tests/chain.rs +++ b/tokio-tcp/tests/chain.rs @@ -1,5 +1,5 @@ extern crate futures; -extern crate tokio; +extern crate tokio_tcp; extern crate tokio_io; use std::net::TcpStream; @@ -9,7 +9,7 @@ use std::io::{Write, Read}; use futures::Future; use futures::stream::Stream; use tokio_io::io::read_to_end; -use tokio::net::TcpListener; +use tokio_tcp::TcpListener; macro_rules! t { ($e:expr) => (match $e { diff --git a/tests/echo.rs b/tokio-tcp/tests/echo.rs index d5bdae81..3c020b19 100644 --- a/tests/echo.rs +++ b/tokio-tcp/tests/echo.rs @@ -1,6 +1,6 @@ extern crate env_logger; extern crate futures; -extern crate tokio; +extern crate tokio_tcp; extern crate tokio_io; use std::io::{Read, Write}; @@ -9,7 +9,7 @@ use std::thread; use futures::Future; use futures::stream::Stream; -use tokio::net::TcpListener; +use tokio_tcp::TcpListener; use tokio_io::AsyncRead; use tokio_io::io::copy; diff --git a/tests/limit.rs b/tokio-tcp/tests/limit.rs index 7055ce9b..8714da9a 100644 --- a/tests/limit.rs +++ b/tokio-tcp/tests/limit.rs @@ -1,5 +1,5 @@ extern crate futures; -extern crate tokio; +extern crate tokio_tcp; extern crate tokio_io; use std::net::TcpStream; @@ -9,7 +9,7 @@ use std::io::{Write, Read}; use futures::Future; use futures::stream::Stream; use tokio_io::io::read_to_end; -use tokio::net::TcpListener; +use tokio_tcp::TcpListener; macro_rules! t { ($e:expr) => (match $e { diff --git a/tests/stream-buffered.rs b/tokio-tcp/tests/stream-buffered.rs index 78fe1c37..a6d71298 100644 --- a/tests/stream-buffered.rs +++ b/tokio-tcp/tests/stream-buffered.rs @@ -1,6 +1,6 @@ extern crate env_logger; extern crate futures; -extern crate tokio; +extern crate tokio_tcp; extern crate tokio_io; use std::io::{Read, Write}; @@ -11,7 +11,7 @@ use futures::Future; use futures::stream::Stream; use tokio_io::io::copy; use tokio_io::AsyncRead; -use tokio::net::TcpListener; +use tokio_tcp::TcpListener; macro_rules! t { ($e:expr) => (match $e { diff --git a/tests/tcp.rs b/tokio-tcp/tests/tcp.rs index 5694e8a6..c905711b 100644 --- a/tests/tcp.rs +++ b/tokio-tcp/tests/tcp.rs @@ -1,13 +1,14 @@ extern crate env_logger; -extern crate tokio; +extern crate tokio_io; +extern crate tokio_tcp; extern crate mio; extern crate futures; use std::{net, thread}; use std::sync::mpsc::channel; -use tokio::net::{TcpListener, TcpStream}; -use tokio::prelude::*; +use futures::{Future, Stream}; +use tokio_tcp::{TcpListener, TcpStream}; macro_rules! t { @@ -82,13 +83,14 @@ fn accept2() { #[cfg(unix)] mod unix { - use tokio::net::TcpStream; - use tokio::prelude::*; + use tokio_tcp::TcpStream; use env_logger; - use futures::future; + use futures::{Future, future}; use mio::unix::UnixReady; + use tokio_io::AsyncRead; + use std::io::Write; use std::{net, thread}; use std::time::Duration; diff --git a/tokio-udp/CHANGELOG.md b/tokio-udp/CHANGELOG.md new file mode 100644 index 00000000..fb22aa7c --- /dev/null +++ b/tokio-udp/CHANGELOG.md @@ -0,0 +1,3 @@ +# 0.1.0 (unreleased) + +* Initial release diff --git a/tokio-udp/Cargo.toml b/tokio-udp/Cargo.toml new file mode 100644 index 00000000..c73ef68d --- /dev/null +++ b/tokio-udp/Cargo.toml @@ -0,0 +1,33 @@ +[package] +name = "tokio-udp" + +# When releasing to crates.io: +# - Update html_root_url. +# - Update CHANGELOG.md. +# - Create "v0.1.x" git tag. +version = "0.1.0" +authors = ["Carl Lerche <me@carllerche.com>"] +license = "MIT" +repository = "https://github.com/tokio-rs/tokio" +homepage = "https://tokio.rs" +documentation = "https://docs.rs/tokio-udp/0.1" +description = """ +UDP bindings for tokio. +""" +categories = ["asynchronous"] + +[dependencies] +tokio-io = { version = "0.1.6", path = "../tokio-io" } +tokio-reactor = { version = "0.1.0", path = "../tokio-reactor" } +bytes = "0.4" +mio = "0.6.14" +log = "0.4" +futures = "0.1.18" +futures2 = { version = "0.1", path = "../futures2", optional = true } + +[dev-dependencies] +env_logger = { version = "0.4", default-features = false } + +[features] +unstable-futures = ["futures2"] +default = [] diff --git a/tokio-udp/LICENSE b/tokio-udp/LICENSE new file mode 100644 index 00000000..38c1e27b --- /dev/null +++ b/tokio-udp/LICENSE @@ -0,0 +1,25 @@ +Copyright (c) 2018 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. diff --git a/tokio-udp/README.md b/tokio-udp/README.md new file mode 100644 index 00000000..e677c074 --- /dev/null +++ b/tokio-udp/README.md @@ -0,0 +1,15 @@ +# tokio-udp + +UDP bindings for `tokio`. + +[Documentation](https://tokio-rs.github.io/tokio/tokio_udp/) + +## 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. diff --git a/src/net/udp/frame.rs b/tokio-udp/src/frame.rs index c06b2279..f3d8e0b2 100644 --- a/src/net/udp/frame.rs +++ b/tokio-udp/src/frame.rs @@ -3,7 +3,7 @@ use std::net::{SocketAddr, Ipv4Addr, SocketAddrV4}; use futures::{Async, Poll, Stream, Sink, StartSend, AsyncSink}; -use net::UdpSocket; +use super::UdpSocket; use tokio_io::codec::{Decoder, Encoder}; use bytes::{BytesMut, BufMut}; diff --git a/tokio-udp/src/lib.rs b/tokio-udp/src/lib.rs new file mode 100644 index 00000000..bf7bd28f --- /dev/null +++ b/tokio-udp/src/lib.rs @@ -0,0 +1,42 @@ +//! UDP bindings for `tokio`. +//! +//! This module contains the UDP networking types, similar to the standard +//! library, which can be used to implement networking protocols. +//! +//! The main struct for UDP is the [`UdpSocket`], which represents a UDP socket. +//! Reading and writing to it can be done using futures, which return the +//! [`RecvDgram`] and [`SendDgram`] structs respectively. +//! +//! For convience it's also possible to convert raw datagrams into higher-level +//! frames. +//! +//! [`UdpSocket`]: struct.UdpSocket.html +//! [`RecvDgram`]: struct.RecvDgram.html +//! [`SendDgram`]: struct.SendDgram.html +//! [`UdpFramed`]: struct.UdpFramed.html +//! [`framed`]: struct.UdpSocket.html#method.framed + +#![doc(html_root_url = "https://docs.rs/tokio-tcp/0.1.0")] +#![deny(missing_docs, warnings, missing_debug_implementations)] + +extern crate bytes; +#[macro_use] +extern crate futures; +extern crate mio; +#[macro_use] +extern crate log; +extern crate tokio_io; +extern crate tokio_reactor; + +#[cfg(feature = "unstable-futures")] +extern crate futures2; + +mod frame; +mod socket; +mod send_dgram; +mod recv_dgram; + +pub use self::frame::UdpFramed; +pub use self::socket::UdpSocket; +pub use self::send_dgram::SendDgram; +pub use self::recv_dgram::RecvDgram; diff --git a/src/net/udp/recv_dgram.rs b/tokio-udp/src/recv_dgram.rs index 86ced3d3..2a9e2960 100644 --- a/src/net/udp/recv_dgram.rs +++ b/tokio-udp/src/recv_dgram.rs @@ -1,4 +1,4 @@ -use net::udp::socket::UdpSocket; +use super::socket::UdpSocket; use std::io; use std::net::SocketAddr; diff --git a/src/net/udp/send_dgram.rs b/tokio-udp/src/send_dgram.rs index c17019a8..50d65038 100644 --- a/src/net/udp/send_dgram.rs +++ b/tokio-udp/src/send_dgram.rs @@ -1,4 +1,4 @@ -use net::udp::socket::UdpSocket; +use super::socket::UdpSocket; use std::io; use std::net::SocketAddr; diff --git a/src/net/udp/socket.rs b/tokio-udp/src/socket.rs index 46c3345f..d671d255 100644 --- a/src/net/udp/socket.rs +++ b/tokio-udp/src/socket.rs @@ -1,4 +1,4 @@ -use net::udp::{SendDgram, RecvDgram}; +use super::{SendDgram, RecvDgram}; use std::io; use std::net::{self, SocketAddr, Ipv4Addr, Ipv6Addr}; @@ -7,11 +7,11 @@ use std::fmt; use futures::{Async, Poll}; use mio; -use reactor::{Handle, PollEvented2}; +use tokio_reactor::{Handle, PollEvented}; /// An I/O object representing a UDP socket. pub struct UdpSocket { - io: PollEvented2<mio::net::UdpSocket>, + io: PollEvented<mio::net::UdpSocket>, } impl UdpSocket { @@ -23,7 +23,7 @@ impl UdpSocket { } fn new(socket: mio::net::UdpSocket) -> UdpSocket { - let io = PollEvented2::new(socket); + let io = PollEvented::new(socket); UdpSocket { io: io } } @@ -39,7 +39,7 @@ impl UdpSocket { pub fn from_std(socket: net::UdpSocket, handle: &Handle) -> io::Result<UdpSocket> { let io = mio::net::UdpSocket::from_socket(socket)?; - let io = PollEvented2::new_with_handle(io, handle)?; + let io = PollEvented::new_with_handle(io, handle)?; Ok(UdpSocket { io }) } diff --git a/tests/udp.rs b/tokio-udp/tests/udp.rs index 8faebee6..0eb2f180 100644 --- a/tests/udp.rs +++ b/tokio-udp/tests/udp.rs @@ -1,7 +1,7 @@ #![allow(deprecated)] extern crate futures; -extern crate tokio; +extern crate tokio_udp; #[macro_use] extern crate tokio_io; extern crate bytes; @@ -12,7 +12,7 @@ use std::net::SocketAddr; use futures::{Future, Poll, Stream, Sink}; -use tokio::net::{UdpSocket, UdpFramed}; +use tokio_udp::{UdpSocket, UdpFramed}; use tokio_io::codec::{Encoder, Decoder}; use bytes::{BytesMut, BufMut}; |