summaryrefslogtreecommitdiffstats
path: root/tokio-util/src/codec
diff options
context:
space:
mode:
authorArtem Vorotnikov <artem@vorotnikov.me>2019-12-18 22:57:22 +0300
committerCarl Lerche <me@carllerche.com>2019-12-18 11:57:22 -0800
commit4c645866ef4ea5b0ef8c7852281a09b2f96d969b (patch)
treefe10e6fffea1033c595b920935dc723be3cc3ac4 /tokio-util/src/codec
parentb0836ece7aa5219e9e40355d0eb784baffc7b6c6 (diff)
stream: add `next` and `map` utility fn (#1962)
Introduces `StreamExt` trait. This trait will be used to add utility functions to make working with streams easier. This patch includes two functions: * `next`: a future returning the item in the stream. * `map`: transform each item in the stream.
Diffstat (limited to 'tokio-util/src/codec')
-rw-r--r--tokio-util/src/codec/framed.rs3
-rw-r--r--tokio-util/src/codec/framed_read.rs3
-rw-r--r--tokio-util/src/codec/framed_write.rs4
-rw-r--r--tokio-util/src/codec/mod.rs2
4 files changed, 5 insertions, 7 deletions
diff --git a/tokio-util/src/codec/framed.rs b/tokio-util/src/codec/framed.rs
index 0c5ef9f6..a3715c24 100644
--- a/tokio-util/src/codec/framed.rs
+++ b/tokio-util/src/codec/framed.rs
@@ -3,10 +3,9 @@ use crate::codec::encoder::Encoder;
use crate::codec::framed_read::{framed_read2, framed_read2_with_buffer, FramedRead2};
use crate::codec::framed_write::{framed_write2, framed_write2_with_buffer, FramedWrite2};
-use tokio::io::{AsyncBufRead, AsyncRead, AsyncWrite};
+use tokio::{io::{AsyncBufRead, AsyncRead, AsyncWrite}, stream::Stream};
use bytes::BytesMut;
-use futures_core::Stream;
use futures_sink::Sink;
use pin_project_lite::pin_project;
use std::fmt;
diff --git a/tokio-util/src/codec/framed_read.rs b/tokio-util/src/codec/framed_read.rs
index bd1f625b..ca9464b5 100644
--- a/tokio-util/src/codec/framed_read.rs
+++ b/tokio-util/src/codec/framed_read.rs
@@ -1,10 +1,9 @@
use crate::codec::framed::{Fuse, ProjectFuse};
use crate::codec::Decoder;
-use tokio::io::AsyncRead;
+use tokio::{io::AsyncRead, stream::Stream};
use bytes::BytesMut;
-use futures_core::Stream;
use futures_sink::Sink;
use log::trace;
use pin_project_lite::pin_project;
diff --git a/tokio-util/src/codec/framed_write.rs b/tokio-util/src/codec/framed_write.rs
index 9aed7ea3..2ef91c7c 100644
--- a/tokio-util/src/codec/framed_write.rs
+++ b/tokio-util/src/codec/framed_write.rs
@@ -2,10 +2,10 @@ use crate::codec::decoder::Decoder;
use crate::codec::encoder::Encoder;
use crate::codec::framed::{Fuse, ProjectFuse};
-use tokio::io::{AsyncBufRead, AsyncRead, AsyncWrite};
+use tokio::{io::{AsyncBufRead, AsyncRead, AsyncWrite}, stream::Stream};
use bytes::BytesMut;
-use futures_core::{ready, Stream};
+use futures_core::ready;
use futures_sink::Sink;
use log::trace;
use pin_project_lite::pin_project;
diff --git a/tokio-util/src/codec/mod.rs b/tokio-util/src/codec/mod.rs
index b162dd3a..4b1b86fb 100644
--- a/tokio-util/src/codec/mod.rs
+++ b/tokio-util/src/codec/mod.rs
@@ -6,8 +6,8 @@
//!
//! [`AsyncRead`]: https://docs.rs/tokio/*/tokio/io/trait.AsyncRead.html
//! [`AsyncWrite`]: https://docs.rs/tokio/*/tokio/io/trait.AsyncWrite.html
+//! [`Stream`]: https://docs.rs/tokio/*/tokio/stream/trait.Stream.html
//! [`Sink`]: https://docs.rs/futures-sink/*/futures_sink/trait.Sink.html
-//! [`Stream`]: https://docs.rs/futures-core/*/futures_core/stream/trait.Stream.html
mod bytes_codec;
pub use self::bytes_codec::BytesCodec;