diff options
author | Carl Lerche <me@carllerche.com> | 2019-05-14 10:27:36 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-14 10:27:36 -0700 |
commit | cb4aea394e6851ae8cc45a68beeaf2c93cc9a0c0 (patch) | |
tree | 2158eab230c8717d3b35717e50f14fda6ca0edf1 /tokio-uds | |
parent | 79d88200500f6e6c9970e1ad26469276c1a2f71f (diff) |
Update Tokio to Rust 2018 (#1082)
Diffstat (limited to 'tokio-uds')
-rw-r--r-- | tokio-uds/Cargo.toml | 14 | ||||
-rw-r--r-- | tokio-uds/src/datagram.rs | 11 | ||||
-rw-r--r-- | tokio-uds/src/frame.rs | 10 | ||||
-rw-r--r-- | tokio-uds/src/incoming.rs | 6 | ||||
-rw-r--r-- | tokio-uds/src/lib.rs | 33 | ||||
-rw-r--r-- | tokio-uds/src/listener.rs | 11 | ||||
-rw-r--r-- | tokio-uds/src/recv_dgram.rs | 6 | ||||
-rw-r--r-- | tokio-uds/src/send_dgram.rs | 6 | ||||
-rw-r--r-- | tokio-uds/src/stream.rs | 11 | ||||
-rw-r--r-- | tokio-uds/src/ucred.rs | 9 | ||||
-rw-r--r-- | tokio-uds/tests/datagram.rs | 20 | ||||
-rw-r--r-- | tokio-uds/tests/stream.rs | 15 |
12 files changed, 55 insertions, 97 deletions
diff --git a/tokio-uds/Cargo.toml b/tokio-uds/Cargo.toml index a884f1bc..4241e954 100644 --- a/tokio-uds/Cargo.toml +++ b/tokio-uds/Cargo.toml @@ -7,8 +7,9 @@ name = "tokio-uds" # - Cargo.toml # - README.md # - Update CHANGELOG.md. -# - Create "v0.2.x" git tag. -version = "0.2.5" +# - Create "v0.3.x" git tag. +version = "0.3.0" +edition = "2018" authors = ["Carl Lerche <me@carllerche.com>"] license = "MIT" repository = "https://github.com/tokio-rs/tokio" @@ -18,6 +19,7 @@ description = """ Unix Domain sockets for Tokio """ categories = ["asynchronous"] +publish = false [dependencies] bytes = "0.4.8" @@ -27,10 +29,10 @@ libc = "0.2.42" log = "0.4.2" mio = "0.6.14" mio-uds = "0.6.5" -tokio-codec = "0.1.0" -tokio-reactor = "0.1.1" -tokio-io = "0.1.6" +tokio-codec = { version = "0.2.0", path = "../tokio-codec" } +tokio-reactor = { version = "0.2.0", path = "../tokio-reactor" } +tokio-io = { version = "0.2.0", path = "../tokio-io" } [dev-dependencies] -tokio = "0.1.6" +tokio = { version = "0.2.0", path = "../tokio" } tempfile = "3" diff --git a/tokio-uds/src/datagram.rs b/tokio-uds/src/datagram.rs index da3f751a..040f9c64 100644 --- a/tokio-uds/src/datagram.rs +++ b/tokio-uds/src/datagram.rs @@ -1,17 +1,14 @@ -use {RecvDgram, SendDgram}; - -use tokio_reactor::{Handle, PollEvented}; - -use futures::{Async, Poll}; +use crate::{RecvDgram, SendDgram}; +use futures::{try_ready, Async, Poll}; use mio::Ready; use mio_uds; - use std::fmt; use std::io; use std::net::Shutdown; use std::os::unix::io::{AsRawFd, RawFd}; use std::os::unix::net::{self, SocketAddr}; use std::path::Path; +use tokio_reactor::{Handle, PollEvented}; /// An I/O object representing a Unix datagram socket. pub struct UnixDatagram { @@ -197,7 +194,7 @@ impl UnixDatagram { } impl fmt::Debug for UnixDatagram { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.io.get_ref().fmt(f) } } diff --git a/tokio-uds/src/frame.rs b/tokio-uds/src/frame.rs index 6a417407..66b4fff2 100644 --- a/tokio-uds/src/frame.rs +++ b/tokio-uds/src/frame.rs @@ -1,12 +1,10 @@ +use super::UnixDatagram; +use bytes::{BufMut, BytesMut}; +use futures::{try_ready, Async, AsyncSink, Poll, Sink, StartSend, Stream}; +use log::trace; use std::io; use std::os::unix::net::SocketAddr; use std::path::Path; - -use futures::{Async, AsyncSink, Poll, Sink, StartSend, Stream}; - -use super::UnixDatagram; - -use bytes::{BufMut, BytesMut}; use tokio_codec::{Decoder, Encoder}; /// A unified `Stream` and `Sink` interface to an underlying `UnixDatagram`, using diff --git a/tokio-uds/src/incoming.rs b/tokio-uds/src/incoming.rs index 472fcf9b..c904a926 100644 --- a/tokio-uds/src/incoming.rs +++ b/tokio-uds/src/incoming.rs @@ -1,7 +1,5 @@ -use {UnixListener, UnixStream}; - -use futures::{Poll, Stream}; - +use crate::{UnixListener, UnixStream}; +use futures::{try_ready, Poll, Stream}; use std::io; /// Stream of listeners diff --git a/tokio-uds/src/lib.rs b/tokio-uds/src/lib.rs index feacf2f9..55a35e69 100644 --- a/tokio-uds/src/lib.rs +++ b/tokio-uds/src/lib.rs @@ -1,24 +1,13 @@ #![cfg(unix)] #![doc(html_root_url = "https://docs.rs/tokio-uds/0.2.5")] -#![deny(missing_docs, warnings, missing_debug_implementations)] +#![deny(missing_docs, missing_debug_implementations, rust_2018_idioms)] +#![cfg_attr(test, deny(warnings))] +#![doc(test(no_crate_inject, attr(deny(rust_2018_idioms))))] //! Unix Domain Sockets for Tokio. //! //! This crate provides APIs for using Unix Domain Sockets with Tokio. -extern crate bytes; -#[macro_use] -extern crate futures; -extern crate iovec; -extern crate libc; -#[macro_use] -extern crate log; -extern crate mio; -extern crate mio_uds; -extern crate tokio_codec; -extern crate tokio_io; -extern crate tokio_reactor; - mod datagram; mod frame; mod incoming; @@ -28,11 +17,11 @@ mod send_dgram; mod stream; mod ucred; -pub use datagram::UnixDatagram; -pub use frame::UnixDatagramFramed; -pub use incoming::Incoming; -pub use listener::UnixListener; -pub use recv_dgram::RecvDgram; -pub use send_dgram::SendDgram; -pub use stream::{ConnectFuture, UnixStream}; -pub use ucred::UCred; +pub use crate::datagram::UnixDatagram; +pub use crate::frame::UnixDatagramFramed; +pub use crate::incoming::Incoming; +pub use crate::listener::UnixListener; +pub use crate::recv_dgram::RecvDgram; +pub use crate::send_dgram::SendDgram; +pub use crate::stream::{ConnectFuture, UnixStream}; +pub use crate::ucred::UCred; diff --git a/tokio-uds/src/listener.rs b/tokio-uds/src/listener.rs index c63b4a84..865197ec 100644 --- a/tokio-uds/src/listener.rs +++ b/tokio-uds/src/listener.rs @@ -1,16 +1,13 @@ -use {Incoming, UnixStream}; - -use tokio_reactor::{Handle, PollEvented}; - -use futures::{Async, Poll}; +use crate::{Incoming, UnixStream}; +use futures::{try_ready, Async, Poll}; use mio::Ready; use mio_uds; - use std::fmt; use std::io; use std::os::unix::io::{AsRawFd, RawFd}; use std::os::unix::net::{self, SocketAddr}; use std::path::Path; +use tokio_reactor::{Handle, PollEvented}; /// A Unix socket which can accept connections from other Unix sockets. pub struct UnixListener { @@ -134,7 +131,7 @@ impl UnixListener { } impl fmt::Debug for UnixListener { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.io.get_ref().fmt(f) } } diff --git a/tokio-uds/src/recv_dgram.rs b/tokio-uds/src/recv_dgram.rs index 8bb61680..0e03f26a 100644 --- a/tokio-uds/src/recv_dgram.rs +++ b/tokio-uds/src/recv_dgram.rs @@ -1,7 +1,5 @@ -use UnixDatagram; - -use futures::{Async, Future, Poll}; - +use crate::UnixDatagram; +use futures::{try_ready, Async, Future, Poll}; use std::io; use std::mem; diff --git a/tokio-uds/src/send_dgram.rs b/tokio-uds/src/send_dgram.rs index d598646a..69004cf5 100644 --- a/tokio-uds/src/send_dgram.rs +++ b/tokio-uds/src/send_dgram.rs @@ -1,7 +1,5 @@ -use UnixDatagram; - -use futures::{Async, Future, Poll}; - +use crate::UnixDatagram; +use futures::{try_ready, Async, Future, Poll}; use std::io; use std::mem; use std::path::Path; diff --git a/tokio-uds/src/stream.rs b/tokio-uds/src/stream.rs index dfb0724d..b14b0e07 100644 --- a/tokio-uds/src/stream.rs +++ b/tokio-uds/src/stream.rs @@ -1,21 +1,18 @@ -use ucred::{self, UCred}; - -use tokio_io::{AsyncRead, AsyncWrite}; -use tokio_reactor::{Handle, PollEvented}; - +use crate::ucred::{self, UCred}; use bytes::{Buf, BufMut}; use futures::{Async, Future, Poll}; use iovec::{self, IoVec}; use libc; use mio::Ready; use mio_uds; - use std::fmt; use std::io::{self, Read, Write}; use std::net::Shutdown; use std::os::unix::io::{AsRawFd, RawFd}; use std::os::unix::net::{self, SocketAddr}; use std::path::Path; +use tokio_io::{AsyncRead, AsyncWrite}; +use tokio_reactor::{Handle, PollEvented}; /// A structure representing a connected Unix socket. /// @@ -238,7 +235,7 @@ impl<'a> AsyncWrite for &'a UnixStream { } impl fmt::Debug for UnixStream { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.io.get_ref().fmt(f) } } diff --git a/tokio-uds/src/ucred.rs b/tokio-uds/src/ucred.rs index 92843e89..0e74f837 100644 --- a/tokio-uds/src/ucred.rs +++ b/tokio-uds/src/ucred.rs @@ -27,14 +27,15 @@ pub use self::impl_solaris::get_peer_cred; #[cfg(any(target_os = "linux", target_os = "android"))] pub mod impl_linux { + use crate::UnixStream; use libc::{c_void, getsockopt, socklen_t, SOL_SOCKET, SO_PEERCRED}; - use std::os::unix::io::AsRawFd; use std::{io, mem}; - use UnixStream; use libc::ucred; pub fn get_peer_cred(sock: &UnixStream) -> io::Result<super::UCred> { + use std::os::unix::io::AsRawFd; + unsafe { let raw_fd = sock.as_raw_fd(); @@ -80,10 +81,10 @@ pub mod impl_linux { target_os = "openbsd" ))] pub mod impl_macos { + use crate::UnixStream; use libc::getpeereid; use std::os::unix::io::AsRawFd; use std::{io, mem}; - use UnixStream; pub fn get_peer_cred(sock: &UnixStream) -> io::Result<super::UCred> { unsafe { @@ -149,9 +150,9 @@ pub mod impl_solaris { #[cfg(not(target_os = "dragonfly"))] #[cfg(test)] mod test { + use crate::UnixStream; use libc::getegid; use libc::geteuid; - use UnixStream; #[test] #[cfg_attr( diff --git a/tokio-uds/tests/datagram.rs b/tokio-uds/tests/datagram.rs index d7d6b587..9ae46510 100644 --- a/tokio-uds/tests/datagram.rs +++ b/tokio-uds/tests/datagram.rs @@ -1,24 +1,14 @@ #![cfg(unix)] - -extern crate bytes; -extern crate futures; -extern crate tempfile; -extern crate tokio; -extern crate tokio_codec; -extern crate tokio_uds; - -use tokio_uds::*; - -use std::str; +#![deny(warnings, rust_2018_idioms)] use bytes::BytesMut; - +use futures::{Future, Sink, Stream}; +use std::str; +use tempfile; use tokio::io; use tokio::runtime::current_thread::Runtime; - use tokio_codec::{Decoder, Encoder}; - -use futures::{Future, Sink, Stream}; +use tokio_uds::*; struct StringDatagramCodec; diff --git a/tokio-uds/tests/stream.rs b/tokio-uds/tests/stream.rs index c9de684f..216ae80a 100644 --- a/tokio-uds/tests/stream.rs +++ b/tokio-uds/tests/stream.rs @@ -1,19 +1,12 @@ #![cfg(unix)] - -extern crate futures; -extern crate tokio; -extern crate tokio_uds; - -extern crate tempfile; - -use tokio_uds::*; - -use tokio::io; -use tokio::runtime::current_thread::Runtime; +#![deny(warnings, rust_2018_idioms)] use futures::sync::oneshot; use futures::{Future, Stream}; use tempfile::Builder; +use tokio::io; +use tokio::runtime::current_thread::Runtime; +use tokio_uds::*; macro_rules! t { ($e:expr) => { |