mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-09-06 00:00:10 +02:00
Update Tokio to Rust 2018 (#1082)
This commit is contained in:
@@ -1,3 +1,3 @@
|
||||
// For now, we need to keep the implementation of Encoder in tokio_io.
|
||||
|
||||
pub use codec::Decoder;
|
||||
pub use crate::codec::Decoder;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
// For now, we need to keep the implementation of Encoder in tokio_io.
|
||||
|
||||
pub use codec::Encoder;
|
||||
pub use crate::codec::Encoder;
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
#![allow(deprecated)]
|
||||
|
||||
use std::fmt;
|
||||
use std::io::{self, Read, Write};
|
||||
|
||||
use super::framed_read::{framed_read2, framed_read2_with_buffer, FramedRead2};
|
||||
use super::framed_write::{framed_write2, framed_write2_with_buffer, FramedWrite2};
|
||||
use codec::{Decoder, Encoder};
|
||||
use {AsyncRead, AsyncWrite};
|
||||
|
||||
use crate::codec::{Decoder, Encoder};
|
||||
use crate::{AsyncRead, AsyncWrite};
|
||||
use bytes::BytesMut;
|
||||
use futures::{Poll, Sink, StartSend, Stream};
|
||||
use std::fmt;
|
||||
use std::io::{self, Read, Write};
|
||||
|
||||
/// A unified `Stream` and `Sink` interface to an underlying I/O object, using
|
||||
/// the `Encoder` and `Decoder` traits to encode and decode frames.
|
||||
@@ -187,7 +185,7 @@ where
|
||||
T: fmt::Debug,
|
||||
U: fmt::Debug,
|
||||
{
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.debug_struct("Framed")
|
||||
.field("io", &self.inner.get_ref().get_ref().0)
|
||||
.field("codec", &self.inner.get_ref().get_ref().1)
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
#![allow(deprecated)]
|
||||
|
||||
use std::fmt;
|
||||
|
||||
use super::framed::Fuse;
|
||||
use codec::Decoder;
|
||||
use AsyncRead;
|
||||
|
||||
use crate::codec::Decoder;
|
||||
use crate::AsyncRead;
|
||||
use bytes::BytesMut;
|
||||
use futures::{Async, Poll, Sink, StartSend, Stream};
|
||||
use futures::{try_ready, Async, Poll, Sink, StartSend, Stream};
|
||||
use log::trace;
|
||||
use std::fmt;
|
||||
|
||||
/// A `Stream` of messages decoded from an `AsyncRead`.
|
||||
pub struct FramedRead<T, D> {
|
||||
@@ -117,7 +116,7 @@ where
|
||||
T: fmt::Debug,
|
||||
D: fmt::Debug,
|
||||
{
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.debug_struct("FramedRead")
|
||||
.field("inner", &self.inner.inner.0)
|
||||
.field("decoder", &self.inner.inner.1)
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
#![allow(deprecated)]
|
||||
|
||||
use super::framed::Fuse;
|
||||
use crate::codec::{Decoder, Encoder};
|
||||
use crate::{AsyncRead, AsyncWrite};
|
||||
use bytes::BytesMut;
|
||||
use futures::{try_ready, Async, AsyncSink, Poll, Sink, StartSend, Stream};
|
||||
use log::trace;
|
||||
use std::fmt;
|
||||
use std::io::{self, Read};
|
||||
|
||||
use super::framed::Fuse;
|
||||
use codec::{Decoder, Encoder};
|
||||
use {AsyncRead, AsyncWrite};
|
||||
|
||||
use bytes::BytesMut;
|
||||
use futures::{Async, AsyncSink, Poll, Sink, StartSend, Stream};
|
||||
|
||||
/// A `Sink` of frames encoded to an `AsyncWrite`.
|
||||
pub struct FramedWrite<T, E> {
|
||||
inner: FramedWrite2<Fuse<T, E>>,
|
||||
@@ -115,7 +114,7 @@ where
|
||||
T: fmt::Debug,
|
||||
U: fmt::Debug,
|
||||
{
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.debug_struct("FramedWrite")
|
||||
.field("inner", &self.inner.get_ref().0)
|
||||
.field("encoder", &self.inner.get_ref().1)
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
//! [`Stream`]: #
|
||||
//! [transports]: #
|
||||
|
||||
#![deny(missing_docs, missing_debug_implementations, warnings)]
|
||||
#![doc(hidden, html_root_url = "https://docs.rs/tokio-codec/0.1.0")]
|
||||
|
||||
// _tokio_codec are the items that belong in the `tokio_codec` crate. However, because we need to
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use crate::{AsyncRead, AsyncWrite};
|
||||
use futures::{Async, Poll};
|
||||
use std::{fmt, io};
|
||||
use {AsyncRead, AsyncWrite};
|
||||
|
||||
/// A simple wrapper type which allows types that only implement
|
||||
/// `std::io::Read` or `std::io::Write` to be used in contexts which expect
|
||||
@@ -50,7 +50,7 @@ where
|
||||
fn write_all(&mut self, buf: &[u8]) -> io::Result<()> {
|
||||
self.0.write_all(buf)
|
||||
}
|
||||
fn write_fmt(&mut self, fmt: fmt::Arguments) -> io::Result<()> {
|
||||
fn write_fmt(&mut self, fmt: fmt::Arguments<'_>) -> io::Result<()> {
|
||||
self.0.write_fmt(fmt)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
use bytes::BufMut;
|
||||
use futures::{Async, Poll};
|
||||
use std::io as std_io;
|
||||
|
||||
#[allow(deprecated)]
|
||||
use codec::{Decoder, Encoder, Framed};
|
||||
use split::{ReadHalf, WriteHalf};
|
||||
use {framed, split, AsyncWrite};
|
||||
use crate::codec::{Decoder, Encoder, Framed};
|
||||
use crate::split::{ReadHalf, WriteHalf};
|
||||
use crate::{framed, split, AsyncWrite};
|
||||
use bytes::BufMut;
|
||||
use futures::{try_ready, Async, Poll};
|
||||
use std::io as std_io;
|
||||
|
||||
/// Read bytes asynchronously.
|
||||
///
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
use crate::AsyncRead;
|
||||
use bytes::Buf;
|
||||
use futures::{Async, Poll};
|
||||
use futures::{try_ready, Async, Poll};
|
||||
use std::io as std_io;
|
||||
|
||||
use AsyncRead;
|
||||
|
||||
/// Writes bytes asynchronously.
|
||||
///
|
||||
/// The trait inherits from `std::io::Write` and indicates that an I/O object is
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#![allow(deprecated)]
|
||||
|
||||
use crate::codec::{Decoder, Encoder};
|
||||
use bytes::{BufMut, Bytes, BytesMut};
|
||||
use codec::{Decoder, Encoder};
|
||||
use std::io;
|
||||
|
||||
/// A simple `Codec` implementation that just ships bytes around.
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
use super::encoder::Encoder;
|
||||
use crate::_tokio_codec::Framed;
|
||||
use crate::{AsyncRead, AsyncWrite};
|
||||
use bytes::BytesMut;
|
||||
use std::io;
|
||||
|
||||
use super::encoder::Encoder;
|
||||
use {AsyncRead, AsyncWrite};
|
||||
|
||||
use _tokio_codec::Framed;
|
||||
|
||||
/// Decoding of frames via buffers.
|
||||
///
|
||||
/// This trait is used when constructing an instance of `Framed` or
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#![allow(deprecated)]
|
||||
|
||||
use crate::codec::{Decoder, Encoder};
|
||||
use bytes::{BufMut, BytesMut};
|
||||
use codec::{Decoder, Encoder};
|
||||
use std::{io, str};
|
||||
|
||||
/// A simple `Codec` implementation that splits up data into lines.
|
||||
|
||||
+26
-29
@@ -27,10 +27,9 @@ pub use self::bytes_codec::BytesCodec;
|
||||
pub use self::decoder::Decoder;
|
||||
pub use self::encoder::Encoder;
|
||||
pub use self::lines_codec::LinesCodec;
|
||||
|
||||
pub use framed::{Framed, FramedParts};
|
||||
pub use framed_read::FramedRead;
|
||||
pub use framed_write::FramedWrite;
|
||||
pub use crate::framed::{Framed, FramedParts};
|
||||
pub use crate::framed_read::FramedRead;
|
||||
pub use crate::framed_write::FramedWrite;
|
||||
|
||||
#[deprecated(since = "0.1.8", note = "Moved to tokio-codec")]
|
||||
#[doc(hidden)]
|
||||
@@ -74,10 +73,6 @@ pub mod length_delimited {
|
||||
//! Specifically, given the following:
|
||||
//!
|
||||
//! ```
|
||||
//! # extern crate tokio_io;
|
||||
//! # extern crate bytes;
|
||||
//! # extern crate futures;
|
||||
//! #
|
||||
//! use tokio_io::{AsyncRead, AsyncWrite};
|
||||
//! use tokio_io::codec::length_delimited;
|
||||
//! use bytes::BytesMut;
|
||||
@@ -89,8 +84,6 @@ pub mod length_delimited {
|
||||
//!
|
||||
//! transport.send(frame).wait().unwrap();
|
||||
//! }
|
||||
//! #
|
||||
//! # pub fn main() {}
|
||||
//! ```
|
||||
//!
|
||||
//! The encoded frame will look like this:
|
||||
@@ -115,8 +108,9 @@ pub mod length_delimited {
|
||||
//! frame head in the yielded `BytesMut`.
|
||||
//!
|
||||
//! ```
|
||||
//! # use tokio_io::AsyncRead;
|
||||
//! # use tokio_io::codec::length_delimited;
|
||||
//! use tokio_io::AsyncRead;
|
||||
//! use tokio_io::codec::length_delimited;
|
||||
//!
|
||||
//! # fn bind_read<T: AsyncRead>(io: T) {
|
||||
//! length_delimited::Builder::new()
|
||||
//! .length_field_offset(0) // default value
|
||||
@@ -148,8 +142,9 @@ pub mod length_delimited {
|
||||
//! frame head in the yielded `BytesMut`.
|
||||
//!
|
||||
//! ```
|
||||
//! # use tokio_io::AsyncRead;
|
||||
//! # use tokio_io::codec::length_delimited;
|
||||
//! use tokio_io::AsyncRead;
|
||||
//! use tokio_io::codec::length_delimited;
|
||||
//!
|
||||
//! # fn bind_read<T: AsyncRead>(io: T) {
|
||||
//! length_delimited::Builder::new()
|
||||
//! .length_field_offset(0) // default value
|
||||
@@ -179,8 +174,9 @@ pub mod length_delimited {
|
||||
//! **includes** the frame head length.
|
||||
//!
|
||||
//! ```
|
||||
//! # use tokio_io::AsyncRead;
|
||||
//! # use tokio_io::codec::length_delimited;
|
||||
//! use tokio_io::AsyncRead;
|
||||
//! use tokio_io::codec::length_delimited;
|
||||
//!
|
||||
//! # fn bind_read<T: AsyncRead>(io: T) {
|
||||
//! length_delimited::Builder::new()
|
||||
//! .length_field_offset(0) // default value
|
||||
@@ -212,8 +208,9 @@ pub mod length_delimited {
|
||||
//! frame head, including the frame head in the yielded `BytesMut`.
|
||||
//!
|
||||
//! ```
|
||||
//! # use tokio_io::AsyncRead;
|
||||
//! # use tokio_io::codec::length_delimited;
|
||||
//! use tokio_io::AsyncRead;
|
||||
//! use tokio_io::codec::length_delimited;
|
||||
//!
|
||||
//! # fn bind_read<T: AsyncRead>(io: T) {
|
||||
//! length_delimited::Builder::new()
|
||||
//! .length_field_offset(0) // default value
|
||||
@@ -255,8 +252,9 @@ pub mod length_delimited {
|
||||
//! included.
|
||||
//!
|
||||
//! ```
|
||||
//! # use tokio_io::AsyncRead;
|
||||
//! # use tokio_io::codec::length_delimited;
|
||||
//! use tokio_io::AsyncRead;
|
||||
//! use tokio_io::codec::length_delimited;
|
||||
//!
|
||||
//! # fn bind_read<T: AsyncRead>(io: T) {
|
||||
//! length_delimited::Builder::new()
|
||||
//! .length_field_offset(1) // length of hdr1
|
||||
@@ -300,8 +298,9 @@ pub mod length_delimited {
|
||||
//! length.
|
||||
//!
|
||||
//! ```
|
||||
//! # use tokio_io::AsyncRead;
|
||||
//! # use tokio_io::codec::length_delimited;
|
||||
//! use tokio_io::AsyncRead;
|
||||
//! use tokio_io::codec::length_delimited;
|
||||
//!
|
||||
//! # fn bind_read<T: AsyncRead>(io: T) {
|
||||
//! length_delimited::Builder::new()
|
||||
//! .length_field_offset(1) // length of hdr1
|
||||
@@ -345,18 +344,16 @@ pub mod length_delimited {
|
||||
//! configuration:
|
||||
//!
|
||||
//! ```
|
||||
//! # extern crate tokio_io;
|
||||
//! # extern crate bytes;
|
||||
//! # use tokio_io::AsyncWrite;
|
||||
//! # use tokio_io::codec::length_delimited;
|
||||
//! # use bytes::BytesMut;
|
||||
//! use tokio_io::AsyncWrite;
|
||||
//! use tokio_io::codec::length_delimited;
|
||||
//! use bytes::BytesMut;
|
||||
//!
|
||||
//! # fn write_frame<T: AsyncWrite>(io: T) {
|
||||
//! # let _: length_delimited::FramedWrite<T, BytesMut> =
|
||||
//! length_delimited::Builder::new()
|
||||
//! .length_field_length(2)
|
||||
//! .new_write(io);
|
||||
//! # }
|
||||
//! # pub fn main() {}
|
||||
//! ```
|
||||
//!
|
||||
//! A payload of `hello world` will be encoded as:
|
||||
@@ -374,5 +371,5 @@ pub mod length_delimited {
|
||||
//! [`Encoder`]: ../trait.Encoder.html
|
||||
//! [`BytesMut`]: https://docs.rs/bytes/0.4/bytes/struct.BytesMut.html
|
||||
|
||||
pub use length_delimited::*;
|
||||
pub use crate::length_delimited::*;
|
||||
}
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
#![allow(deprecated)]
|
||||
|
||||
use std::fmt;
|
||||
use std::io::{self, Read, Write};
|
||||
|
||||
use codec::{Decoder, Encoder};
|
||||
use framed_read::{framed_read2, framed_read2_with_buffer, FramedRead2};
|
||||
use framed_write::{framed_write2, framed_write2_with_buffer, FramedWrite2};
|
||||
use {AsyncRead, AsyncWrite};
|
||||
|
||||
use crate::codec::{Decoder, Encoder};
|
||||
use crate::framed_read::{framed_read2, framed_read2_with_buffer, FramedRead2};
|
||||
use crate::framed_write::{framed_write2, framed_write2_with_buffer, FramedWrite2};
|
||||
use crate::{AsyncRead, AsyncWrite};
|
||||
use bytes::BytesMut;
|
||||
use futures::{Poll, Sink, StartSend, Stream};
|
||||
use std::fmt;
|
||||
use std::io::{self, Read, Write};
|
||||
|
||||
/// A unified `Stream` and `Sink` interface to an underlying I/O object, using
|
||||
/// the `Encoder` and `Decoder` traits to encode and decode frames.
|
||||
@@ -174,7 +172,7 @@ where
|
||||
T: fmt::Debug,
|
||||
U: fmt::Debug,
|
||||
{
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.debug_struct("Framed")
|
||||
.field("io", &self.inner.get_ref().get_ref().0)
|
||||
.field("codec", &self.inner.get_ref().get_ref().1)
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
#![allow(deprecated)]
|
||||
|
||||
use std::fmt;
|
||||
|
||||
use codec::Decoder;
|
||||
use framed::Fuse;
|
||||
use AsyncRead;
|
||||
|
||||
use crate::codec::Decoder;
|
||||
use crate::framed::Fuse;
|
||||
use crate::AsyncRead;
|
||||
use bytes::BytesMut;
|
||||
use futures::{Async, Poll, Sink, StartSend, Stream};
|
||||
use futures::{try_ready, Async, Poll, Sink, StartSend, Stream};
|
||||
use log::trace;
|
||||
use std::fmt;
|
||||
|
||||
/// A `Stream` of messages decoded from an `AsyncRead`.
|
||||
#[deprecated(since = "0.1.7", note = "Moved to tokio-codec")]
|
||||
@@ -121,7 +120,7 @@ where
|
||||
T: fmt::Debug,
|
||||
D: fmt::Debug,
|
||||
{
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.debug_struct("FramedRead")
|
||||
.field("inner", &self.inner.inner.0)
|
||||
.field("decoder", &self.inner.inner.1)
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
#![allow(deprecated)]
|
||||
|
||||
use crate::codec::{Decoder, Encoder};
|
||||
use crate::framed::Fuse;
|
||||
use crate::{AsyncRead, AsyncWrite};
|
||||
use bytes::BytesMut;
|
||||
use futures::{try_ready, Async, AsyncSink, Poll, Sink, StartSend, Stream};
|
||||
use log::trace;
|
||||
use std::fmt;
|
||||
use std::io::{self, Read};
|
||||
|
||||
use codec::{Decoder, Encoder};
|
||||
use framed::Fuse;
|
||||
use {AsyncRead, AsyncWrite};
|
||||
|
||||
use bytes::BytesMut;
|
||||
use futures::{Async, AsyncSink, Poll, Sink, StartSend, Stream};
|
||||
|
||||
/// A `Sink` of frames encoded to an `AsyncWrite`.
|
||||
#[deprecated(since = "0.1.7", note = "Moved to tokio-codec")]
|
||||
#[doc(hidden)]
|
||||
@@ -119,7 +118,7 @@ where
|
||||
T: fmt::Debug,
|
||||
U: fmt::Debug,
|
||||
{
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.debug_struct("FramedWrite")
|
||||
.field("inner", &self.inner.get_ref().0)
|
||||
.field("encoder", &self.inner.get_ref().1)
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
use crate::{AsyncRead, AsyncWrite};
|
||||
use futures::{try_ready, Future, Poll};
|
||||
use std::io;
|
||||
|
||||
use futures::{Future, Poll};
|
||||
|
||||
use {AsyncRead, AsyncWrite};
|
||||
|
||||
/// A future which will copy all data from a reader into a writer.
|
||||
///
|
||||
/// Created by the [`copy`] function, this future will resolve to the number of
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
use crate::AsyncWrite;
|
||||
use futures::{try_ready, Async, Future, Poll};
|
||||
use std::io;
|
||||
|
||||
use futures::{Async, Future, Poll};
|
||||
|
||||
use AsyncWrite;
|
||||
|
||||
/// A future used to fully flush an I/O object.
|
||||
///
|
||||
/// Resolves to the underlying I/O object once the flush operation is complete.
|
||||
|
||||
@@ -26,7 +26,7 @@ pub use self::read_to_end::{read_to_end, ReadToEnd};
|
||||
pub use self::read_until::{read_until, ReadUntil};
|
||||
pub use self::shutdown::{shutdown, Shutdown};
|
||||
pub use self::write_all::{write_all, WriteAll};
|
||||
pub use allow_std::AllowStdIo;
|
||||
pub use lines::{lines, Lines};
|
||||
pub use split::{ReadHalf, WriteHalf};
|
||||
pub use window::Window;
|
||||
pub use crate::allow_std::AllowStdIo;
|
||||
pub use crate::lines::{lines, Lines};
|
||||
pub use crate::split::{ReadHalf, WriteHalf};
|
||||
pub use crate::window::Window;
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
use crate::AsyncRead;
|
||||
use futures::{try_ready, Future, Poll};
|
||||
use std::io;
|
||||
use std::mem;
|
||||
|
||||
use futures::{Future, Poll};
|
||||
|
||||
use AsyncRead;
|
||||
|
||||
#[derive(Debug)]
|
||||
enum State<R, T> {
|
||||
Pending { rd: R, buf: T },
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
use crate::AsyncRead;
|
||||
use futures::{try_ready, Future, Poll};
|
||||
use std::io;
|
||||
use std::mem;
|
||||
|
||||
use futures::{Future, Poll};
|
||||
|
||||
use AsyncRead;
|
||||
|
||||
/// A future which can be used to easily read exactly enough bytes to fill
|
||||
/// a buffer.
|
||||
///
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
use crate::AsyncRead;
|
||||
use futures::{Future, Poll};
|
||||
use std::io;
|
||||
use std::mem;
|
||||
|
||||
use futures::{Future, Poll};
|
||||
|
||||
use AsyncRead;
|
||||
|
||||
/// A future which can be used to easily read the entire contents of a stream
|
||||
/// into a vector.
|
||||
///
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
use crate::AsyncRead;
|
||||
use futures::{Future, Poll};
|
||||
use std::io::{self, BufRead};
|
||||
use std::mem;
|
||||
|
||||
use futures::{Future, Poll};
|
||||
|
||||
use AsyncRead;
|
||||
|
||||
/// A future which can be used to easily read the contents of a stream into a
|
||||
/// vector until the delimiter is reached.
|
||||
///
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
use crate::AsyncWrite;
|
||||
use futures::{try_ready, Async, Future, Poll};
|
||||
use std::io;
|
||||
|
||||
use futures::{Async, Future, Poll};
|
||||
|
||||
use AsyncWrite;
|
||||
|
||||
/// A future used to fully shutdown an I/O object.
|
||||
///
|
||||
/// Resolves to the underlying I/O object once the shutdown operation is
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
use crate::AsyncWrite;
|
||||
use futures::{try_ready, Future, Poll};
|
||||
use std::io;
|
||||
use std::mem;
|
||||
|
||||
use futures::{Future, Poll};
|
||||
|
||||
use AsyncWrite;
|
||||
|
||||
/// A future used to write the entire contents of some data to a stream.
|
||||
///
|
||||
/// This is created by the [`write_all`] top-level method.
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
#![allow(deprecated)]
|
||||
|
||||
use {codec, AsyncRead, AsyncWrite};
|
||||
|
||||
use crate::{codec, AsyncRead, AsyncWrite};
|
||||
use bytes::buf::Chain;
|
||||
use bytes::{Buf, BufMut, BytesMut, IntoBuf};
|
||||
|
||||
use futures::{Async, AsyncSink, Poll, Sink, StartSend, Stream};
|
||||
|
||||
use futures::{try_ready, Async, AsyncSink, Poll, Sink, StartSend, Stream};
|
||||
use std::error::Error as StdError;
|
||||
use std::io::{self, Cursor};
|
||||
use std::{cmp, fmt};
|
||||
@@ -174,7 +171,7 @@ where
|
||||
T: fmt::Debug,
|
||||
B::Buf: fmt::Debug,
|
||||
{
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.debug_struct("Framed")
|
||||
.field("inner", &self.inner)
|
||||
.finish()
|
||||
@@ -580,7 +577,7 @@ where
|
||||
T: fmt::Debug,
|
||||
B::Buf: fmt::Debug,
|
||||
{
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.debug_struct("FramedWrite")
|
||||
.field("inner", &self.inner)
|
||||
.field("builder", &self.builder)
|
||||
@@ -859,18 +856,16 @@ impl Builder {
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// # extern crate tokio_io;
|
||||
/// # extern crate bytes;
|
||||
/// # use tokio_io::AsyncWrite;
|
||||
/// # use tokio_io::codec::length_delimited;
|
||||
/// # use bytes::BytesMut;
|
||||
/// use tokio_io::AsyncWrite;
|
||||
/// use tokio_io::codec::length_delimited;
|
||||
/// use bytes::BytesMut;
|
||||
///
|
||||
/// # fn write_frame<T: AsyncWrite>(io: T) {
|
||||
/// # let _: length_delimited::FramedWrite<T, BytesMut> =
|
||||
/// length_delimited::Builder::new()
|
||||
/// .length_field_length(2)
|
||||
/// .new_write(io);
|
||||
/// # }
|
||||
/// # pub fn main() {}
|
||||
/// ```
|
||||
pub fn new_write<T, B>(&self, inner: T) -> FramedWrite<T, B>
|
||||
where
|
||||
@@ -889,18 +884,16 @@ impl Builder {
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// # extern crate tokio_io;
|
||||
/// # extern crate bytes;
|
||||
/// # use tokio_io::{AsyncRead, AsyncWrite};
|
||||
/// # use tokio_io::codec::length_delimited;
|
||||
/// # use bytes::BytesMut;
|
||||
/// use tokio_io::{AsyncRead, AsyncWrite};
|
||||
/// use tokio_io::codec::length_delimited;
|
||||
/// use bytes::BytesMut;
|
||||
///
|
||||
/// # fn write_frame<T: AsyncRead + AsyncWrite>(io: T) {
|
||||
/// # let _: length_delimited::Framed<T, BytesMut> =
|
||||
/// length_delimited::Builder::new()
|
||||
/// .length_field_length(2)
|
||||
/// .new_framed(io);
|
||||
/// # }
|
||||
/// # pub fn main() {}
|
||||
/// ```
|
||||
pub fn new_framed<T, B>(&self, inner: T) -> Framed<T, B>
|
||||
where
|
||||
@@ -925,13 +918,13 @@ impl Builder {
|
||||
// ===== impl FrameTooBig =====
|
||||
|
||||
impl fmt::Debug for FrameTooBig {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.debug_struct("FrameTooBig").finish()
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for FrameTooBig {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.write_str(self.description())
|
||||
}
|
||||
}
|
||||
|
||||
+8
-14
@@ -1,5 +1,7 @@
|
||||
#![deny(missing_docs, missing_debug_implementations, warnings)]
|
||||
#![doc(html_root_url = "https://docs.rs/tokio-io/0.1.12")]
|
||||
#![deny(missing_debug_implementations, missing_docs, rust_2018_idioms)]
|
||||
#![cfg_attr(test, deny(warnings))]
|
||||
#![doc(test(no_crate_inject, attr(deny(rust_2018_idioms))))]
|
||||
|
||||
//! Core I/O traits and combinators when working with Tokio.
|
||||
//!
|
||||
@@ -9,22 +11,14 @@
|
||||
//! [found online]: https://tokio.rs/docs/getting-started/core/
|
||||
//! [low level details]: https://tokio.rs/docs/going-deeper-tokio/core-low-level/
|
||||
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
|
||||
#[macro_use]
|
||||
extern crate futures;
|
||||
extern crate bytes;
|
||||
|
||||
use futures::{Future, Stream};
|
||||
use std::io as std_io;
|
||||
|
||||
use futures::{Future, Stream};
|
||||
|
||||
/// A convenience typedef around a `Future` whose error component is `io::Error`
|
||||
pub type IoFuture<T> = Box<Future<Item = T, Error = std_io::Error> + Send>;
|
||||
pub type IoFuture<T> = Box<dyn Future<Item = T, Error = std_io::Error> + Send>;
|
||||
|
||||
/// A convenience typedef around a `Stream` whose error component is `io::Error`
|
||||
pub type IoStream<T> = Box<Stream<Item = T, Error = std_io::Error> + Send>;
|
||||
pub type IoStream<T> = Box<dyn Stream<Item = T, Error = std_io::Error> + Send>;
|
||||
|
||||
/// A convenience macro for working with `io::Result<T>` from the `Read` and
|
||||
/// `Write` traits.
|
||||
@@ -65,6 +59,6 @@ pub use self::async_write::AsyncWrite;
|
||||
|
||||
fn _assert_objects() {
|
||||
fn _assert<T>() {}
|
||||
_assert::<Box<AsyncRead>>();
|
||||
_assert::<Box<AsyncWrite>>();
|
||||
_assert::<Box<dyn AsyncRead>>();
|
||||
_assert::<Box<dyn AsyncWrite>>();
|
||||
}
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
use crate::AsyncRead;
|
||||
use futures::{Poll, Stream};
|
||||
use std::io::{self, BufRead};
|
||||
use std::mem;
|
||||
|
||||
use futures::{Poll, Stream};
|
||||
|
||||
use AsyncRead;
|
||||
|
||||
/// Combinator created by the top-level `lines` method which is a stream over
|
||||
/// the lines of text on an I/O object.
|
||||
#[derive(Debug)]
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
use std::io::{self, Read, Write};
|
||||
|
||||
use crate::{AsyncRead, AsyncWrite};
|
||||
use bytes::{Buf, BufMut};
|
||||
use futures::sync::BiLock;
|
||||
use futures::{Async, Poll};
|
||||
|
||||
use {AsyncRead, AsyncWrite};
|
||||
use futures::{try_ready, Async, Poll};
|
||||
use std::io::{self, Read, Write};
|
||||
|
||||
/// The readable half of an object returned from `AsyncRead::split`.
|
||||
#[derive(Debug)]
|
||||
@@ -112,14 +110,12 @@ fn wrap_as_io<T>(t: Async<T>) -> Result<Async<T>, io::Error> {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
extern crate tokio_current_thread;
|
||||
|
||||
use super::{AsyncRead, AsyncWrite, ReadHalf, WriteHalf};
|
||||
use bytes::{BytesMut, IntoBuf};
|
||||
use futures::sync::BiLock;
|
||||
use futures::{future::lazy, future::ok, Async, Poll};
|
||||
|
||||
use std::io::{self, Read, Write};
|
||||
use tokio_current_thread;
|
||||
|
||||
struct RW;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user