From e145af616a56ae41116a2eeb702b269db0c4a77d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20M=2E=20Bezerra?= Date: Wed, 22 Mar 2023 19:30:04 -0300 Subject: [PATCH 1/2] cite `ReaderStream` and `StreamReader` in `tokio::io` docs `ReaderStream` and `StreamReader` from the crate `tokio_util` are a convenient and simpler way of creating adaptors for `Stream`, from and to `AsyncRead` --- tokio/src/io/mod.rs | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/tokio/src/io/mod.rs b/tokio/src/io/mod.rs index f48035ad934..3a87b3f9d09 100644 --- a/tokio/src/io/mod.rs +++ b/tokio/src/io/mod.rs @@ -130,19 +130,23 @@ //! other words, these types must never block the thread, and instead the //! current task is notified when the I/O resource is ready. //! -//! ## Conversion to and from Sink/Stream +//! ## Conversion to and from Stream/Sink //! -//! It is often convenient to encapsulate the reading and writing of -//! bytes and instead work with a [`Sink`] or [`Stream`] of some data -//! type that is encoded as bytes and/or decoded from bytes. Tokio -//! provides some utility traits in the [tokio-util] crate that -//! abstract the asynchronous buffering that is required and allows -//! you to write [`Encoder`] and [`Decoder`] functions working with a -//! buffer of bytes, and then use that ["codec"] to transform anything -//! that implements [`AsyncRead`] and [`AsyncWrite`] into a `Sink`/`Stream` of -//! your structured data. +//! It is often convenient to encapsulate the reading and writing of bytes in a +//! [`Stream`] or [`Sink`] of data. //! -//! [tokio-util]: https://docs.rs/tokio-util/0.6/tokio_util/codec/index.html +//! Tokio provides simple wrappers for converting [`AsyncRead`] to [`Stream`] +//! and vice-versa in the [tokio-util] crate, see [`ReaderStream`] and +//! [`StreamReader`]. +//! +//! There are also utility traits that abstract the asynchronous buffering +//! necessary to write your own adaptors for encoding and decoding bytes to/from +//! your structured data, allowing to transform something that implements +//! [`AsyncRead`]/[`AsyncWrite`] into a [`Stream`]/[`Sink`], see [`Decoder`] and +//! [`Encoder`] in the [tokio-util::codec] module. +//! +//! [tokio-util]: https://docs.rs/tokio-util/0.6 +//! [tokio-util::codec]: https://docs.rs/tokio-util/0.6/tokio_util/codec/index.html //! //! # Standard input and output //! @@ -170,6 +174,8 @@ //! ["codec"]: https://docs.rs/tokio-util/0.6/tokio_util/codec/index.html //! [`Encoder`]: https://docs.rs/tokio-util/0.6/tokio_util/codec/trait.Encoder.html //! [`Decoder`]: https://docs.rs/tokio-util/0.6/tokio_util/codec/trait.Decoder.html +//! [`ReaderStream`]: https://docs.rs/tokio-util/0.6/tokio_util/io/struct.ReaderStream.html +//! [`StreamReader`]: https://docs.rs/tokio-util/0.6/tokio_util/io/struct.StreamReader.html //! [`Error`]: struct@Error //! [`ErrorKind`]: enum@ErrorKind //! [`Result`]: type@Result From 1198689f7e4335333acfc2b22419f1485d698aa4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20M=2E=20Bezerra?= Date: Thu, 23 Mar 2023 11:57:28 -0300 Subject: [PATCH 2/2] update version of docs links to tokio_util --- tokio/src/io/mod.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tokio/src/io/mod.rs b/tokio/src/io/mod.rs index 3a87b3f9d09..666d69cb438 100644 --- a/tokio/src/io/mod.rs +++ b/tokio/src/io/mod.rs @@ -145,8 +145,8 @@ //! [`AsyncRead`]/[`AsyncWrite`] into a [`Stream`]/[`Sink`], see [`Decoder`] and //! [`Encoder`] in the [tokio-util::codec] module. //! -//! [tokio-util]: https://docs.rs/tokio-util/0.6 -//! [tokio-util::codec]: https://docs.rs/tokio-util/0.6/tokio_util/codec/index.html +//! [tokio-util]: https://docs.rs/tokio-util +//! [tokio-util::codec]: https://docs.rs/tokio-util/latest/tokio_util/codec/index.html //! //! # Standard input and output //! @@ -171,11 +171,11 @@ //! [`AsyncWrite`]: trait@AsyncWrite //! [`AsyncReadExt`]: trait@AsyncReadExt //! [`AsyncWriteExt`]: trait@AsyncWriteExt -//! ["codec"]: https://docs.rs/tokio-util/0.6/tokio_util/codec/index.html -//! [`Encoder`]: https://docs.rs/tokio-util/0.6/tokio_util/codec/trait.Encoder.html -//! [`Decoder`]: https://docs.rs/tokio-util/0.6/tokio_util/codec/trait.Decoder.html -//! [`ReaderStream`]: https://docs.rs/tokio-util/0.6/tokio_util/io/struct.ReaderStream.html -//! [`StreamReader`]: https://docs.rs/tokio-util/0.6/tokio_util/io/struct.StreamReader.html +//! ["codec"]: https://docs.rs/tokio-util/latest/tokio_util/codec/index.html +//! [`Encoder`]: https://docs.rs/tokio-util/latest/tokio_util/codec/trait.Encoder.html +//! [`Decoder`]: https://docs.rs/tokio-util/latest/tokio_util/codec/trait.Decoder.html +//! [`ReaderStream`]: https://docs.rs/tokio-util/latest/tokio_util/io/struct.ReaderStream.html +//! [`StreamReader`]: https://docs.rs/tokio-util/latest/tokio_util/io/struct.StreamReader.html //! [`Error`]: struct@Error //! [`ErrorKind`]: enum@ErrorKind //! [`Result`]: type@Result