Update Tokio to Rust 2018 (#1082)

This commit is contained in:
Carl Lerche
2019-05-14 10:27:36 -07:00
committed by GitHub
parent 79d8820050
commit cb4aea394e
343 changed files with 1725 additions and 2813 deletions
+4 -7
View File
@@ -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)
}
}
+4 -6
View File
@@ -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
+2 -4
View File
@@ -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
+11 -22
View File
@@ -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;
+4 -7
View File
@@ -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)
}
}
+2 -4
View File
@@ -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;
+2 -4
View File
@@ -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;
+4 -7
View File
@@ -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)
}
}
+5 -4
View File
@@ -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(