mpvrc/tokio/io/index.html

128 lines
No EOL
29 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Traits, helpers, and type definitions for asynchronous I/O functionality."><title>tokio::io - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="tokio" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="../sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc mod"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../tokio/index.html">tokio</a><span class="version">1.42.0</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Module io</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#asyncread-and-asyncwrite" title="`AsyncRead` and `AsyncWrite`"><code>AsyncRead</code> and <code>AsyncWrite</code></a><ul><li><a href="#buffered-readers-and-writers" title="Buffered Readers and Writers">Buffered Readers and Writers</a></li><li><a href="#implementing-asyncread-and-asyncwrite" title="Implementing `AsyncRead` and `AsyncWrite`">Implementing <code>AsyncRead</code> and <code>AsyncWrite</code></a></li><li><a href="#conversion-to-and-from-streamsink" title="Conversion to and from Stream/Sink">Conversion to and from Stream/Sink</a></li></ul></li><li><a href="#standard-input-and-output" title="Standard input and output">Standard input and output</a></li><li><a href="#std-re-exports" title="`std` re-exports"><code>std</code> re-exports</a></li></ul><h3><a href="#reexports">Module Items</a></h3><ul class="block"><li><a href="#reexports" title="Re-exports">Re-exports</a></li><li><a href="#modules" title="Modules">Modules</a></li><li><a href="#structs" title="Structs">Structs</a></li><li><a href="#traits" title="Traits">Traits</a></li><li><a href="#functions" title="Functions">Functions</a></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="../index.html">In crate tokio</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">tokio</a></span><h1>Module <span>io</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/tokio/io/mod.rs.html#1-295">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Traits, helpers, and type definitions for asynchronous I/O functionality.</p>
<p>This module is the asynchronous version of <code>std::io</code>. Primarily, it
defines two traits, <a href="trait.AsyncRead.html" title="trait tokio::io::AsyncRead"><code>AsyncRead</code></a> and <a href="trait.AsyncWrite.html" title="trait tokio::io::AsyncWrite"><code>AsyncWrite</code></a>, which are asynchronous
versions of the <a href="https://doc.rust-lang.org/1.84.1/std/io/trait.Read.html" title="trait std::io::Read"><code>Read</code></a> and <a href="https://doc.rust-lang.org/1.84.1/std/io/trait.Write.html" title="trait std::io::Write"><code>Write</code></a> traits in the standard library.</p>
<h2 id="asyncread-and-asyncwrite"><a class="doc-anchor" href="#asyncread-and-asyncwrite">§</a><code>AsyncRead</code> and <code>AsyncWrite</code></h2>
<p>Like the standard librarys <a href="https://doc.rust-lang.org/1.84.1/std/io/trait.Read.html" title="trait std::io::Read"><code>Read</code></a> and <a href="https://doc.rust-lang.org/1.84.1/std/io/trait.Write.html" title="trait std::io::Write"><code>Write</code></a> traits, <a href="trait.AsyncRead.html" title="trait tokio::io::AsyncRead"><code>AsyncRead</code></a> and
<a href="trait.AsyncWrite.html" title="trait tokio::io::AsyncWrite"><code>AsyncWrite</code></a> provide the most general interface for reading and writing
input and output. Unlike the standard librarys traits, however, they are
<em>asynchronous</em> — meaning that reading from or writing to a <code>tokio::io</code>
type will <em>yield</em> to the Tokio scheduler when IO is not ready, rather than
blocking. This allows other tasks to run while waiting on IO.</p>
<p>Another difference is that <code>AsyncRead</code> and <code>AsyncWrite</code> only contain
core methods needed to provide asynchronous reading and writing
functionality. Instead, utility methods are defined in the <a href="trait.AsyncReadExt.html" title="trait tokio::io::AsyncReadExt"><code>AsyncReadExt</code></a>
and <a href="trait.AsyncWriteExt.html" title="trait tokio::io::AsyncWriteExt"><code>AsyncWriteExt</code></a> extension traits. These traits are automatically
implemented for all values that implement <code>AsyncRead</code> and <code>AsyncWrite</code>
respectively.</p>
<p>End users will rarely interact directly with <code>AsyncRead</code> and
<code>AsyncWrite</code>. Instead, they will use the async functions defined in the
extension traits. Library authors are expected to implement <code>AsyncRead</code>
and <code>AsyncWrite</code> in order to provide types that behave like byte streams.</p>
<p>Even with these differences, Tokios <code>AsyncRead</code> and <code>AsyncWrite</code> traits
can be used in almost exactly the same manner as the standard librarys
<code>Read</code> and <code>Write</code>. Most types in the standard library that implement <code>Read</code>
and <code>Write</code> have asynchronous equivalents in <code>tokio</code> that implement
<code>AsyncRead</code> and <code>AsyncWrite</code>, such as <a href="../fs/struct.File.html" title="struct tokio::fs::File"><code>File</code></a> and <a href="../net/struct.TcpStream.html" title="struct tokio::net::TcpStream"><code>TcpStream</code></a>.</p>
<p>For example, the standard library documentation introduces <code>Read</code> by
<a href="https://doc.rust-lang.org/1.84.1/std/io/index.html#read-and-write" title="mod std::io">demonstrating</a> reading some bytes from a <a href="https://doc.rust-lang.org/1.84.1/std/fs/struct.File.html" title="struct std::fs::File"><code>std::fs::File</code></a>. We
can do the same with <a href="../fs/struct.File.html" title="struct tokio::fs::File"><code>tokio::fs::File</code></a>:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio::io::{<span class="self">self</span>, AsyncReadExt};
<span class="kw">use </span>tokio::fs::File;
<span class="attr">#[tokio::main]
</span><span class="kw">async fn </span>main() -&gt; io::Result&lt;()&gt; {
<span class="kw">let </span><span class="kw-2">mut </span>f = File::open(<span class="string">"foo.txt"</span>).<span class="kw">await</span><span class="question-mark">?</span>;
<span class="kw">let </span><span class="kw-2">mut </span>buffer = [<span class="number">0</span>; <span class="number">10</span>];
<span class="comment">// read up to 10 bytes
</span><span class="kw">let </span>n = f.read(<span class="kw-2">&amp;mut </span>buffer).<span class="kw">await</span><span class="question-mark">?</span>;
<span class="macro">println!</span>(<span class="string">"The bytes: {:?}"</span>, <span class="kw-2">&amp;</span>buffer[..n]);
<span class="prelude-val">Ok</span>(())
}</code></pre></div>
<h3 id="buffered-readers-and-writers"><a class="doc-anchor" href="#buffered-readers-and-writers">§</a>Buffered Readers and Writers</h3>
<p>Byte-based interfaces are unwieldy and can be inefficient, as wed need to be
making near-constant calls to the operating system. To help with this,
<code>std::io</code> comes with <a href="https://doc.rust-lang.org/1.84.1/std/io/index.html#bufreader-and-bufwriter" title="mod std::io">support for <em>buffered</em> readers and writers</a>,
and therefore, <code>tokio::io</code> does as well.</p>
<p>Tokio provides an async version of the <a href="https://doc.rust-lang.org/1.84.1/std/io/trait.BufRead.html" title="trait std::io::BufRead"><code>std::io::BufRead</code></a> trait,
<a href="trait.AsyncBufRead.html" title="trait tokio::io::AsyncBufRead"><code>AsyncBufRead</code></a>; and async <a href="struct.BufReader.html" title="struct tokio::io::BufReader"><code>BufReader</code></a> and <a href="struct.BufWriter.html" title="struct tokio::io::BufWriter"><code>BufWriter</code></a> structs, which
wrap readers and writers. These wrappers use a buffer, reducing the number
of calls and providing nicer methods for accessing exactly what you want.</p>
<p>For example, <a href="struct.BufReader.html" title="struct tokio::io::BufReader"><code>BufReader</code></a> works with the <a href="trait.AsyncBufRead.html" title="trait tokio::io::AsyncBufRead"><code>AsyncBufRead</code></a> trait to add
extra methods to any async reader:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio::io::{<span class="self">self</span>, BufReader, AsyncBufReadExt};
<span class="kw">use </span>tokio::fs::File;
<span class="attr">#[tokio::main]
</span><span class="kw">async fn </span>main() -&gt; io::Result&lt;()&gt; {
<span class="kw">let </span>f = File::open(<span class="string">"foo.txt"</span>).<span class="kw">await</span><span class="question-mark">?</span>;
<span class="kw">let </span><span class="kw-2">mut </span>reader = BufReader::new(f);
<span class="kw">let </span><span class="kw-2">mut </span>buffer = String::new();
<span class="comment">// read a line into buffer
</span>reader.read_line(<span class="kw-2">&amp;mut </span>buffer).<span class="kw">await</span><span class="question-mark">?</span>;
<span class="macro">println!</span>(<span class="string">"{}"</span>, buffer);
<span class="prelude-val">Ok</span>(())
}</code></pre></div>
<p><a href="struct.BufWriter.html" title="struct tokio::io::BufWriter"><code>BufWriter</code></a> doesnt add any new ways of writing; it just buffers every call
to <a href="trait.AsyncWriteExt.html#method.write" title="method tokio::io::AsyncWriteExt::write"><code>write</code></a>. However, you <strong>must</strong> flush
<a href="struct.BufWriter.html" title="struct tokio::io::BufWriter"><code>BufWriter</code></a> to ensure that any buffered data is written.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio::io::{<span class="self">self</span>, BufWriter, AsyncWriteExt};
<span class="kw">use </span>tokio::fs::File;
<span class="attr">#[tokio::main]
</span><span class="kw">async fn </span>main() -&gt; io::Result&lt;()&gt; {
<span class="kw">let </span>f = File::create(<span class="string">"foo.txt"</span>).<span class="kw">await</span><span class="question-mark">?</span>;
{
<span class="kw">let </span><span class="kw-2">mut </span>writer = BufWriter::new(f);
<span class="comment">// Write a byte to the buffer.
</span>writer.write(<span class="kw-2">&amp;</span>[<span class="number">42u8</span>]).<span class="kw">await</span><span class="question-mark">?</span>;
<span class="comment">// Flush the buffer before it goes out of scope.
</span>writer.flush().<span class="kw">await</span><span class="question-mark">?</span>;
} <span class="comment">// Unless flushed or shut down, the contents of the buffer is discarded on drop.
</span><span class="prelude-val">Ok</span>(())
}</code></pre></div>
<h3 id="implementing-asyncread-and-asyncwrite"><a class="doc-anchor" href="#implementing-asyncread-and-asyncwrite">§</a>Implementing <code>AsyncRead</code> and <code>AsyncWrite</code></h3>
<p>Because they are traits, we can implement <a href="trait.AsyncRead.html" title="trait tokio::io::AsyncRead"><code>AsyncRead</code></a> and <a href="trait.AsyncWrite.html" title="trait tokio::io::AsyncWrite"><code>AsyncWrite</code></a> for
our own types, as well. Note that these traits must only be implemented for
non-blocking I/O types that integrate with the futures type system. In
other words, these types must never block the thread, and instead the
current task is notified when the I/O resource is ready.</p>
<h3 id="conversion-to-and-from-streamsink"><a class="doc-anchor" href="#conversion-to-and-from-streamsink">§</a>Conversion to and from Stream/Sink</h3>
<p>It is often convenient to encapsulate the reading and writing of bytes in a
<a href="https://docs.rs/futures/0.3/futures/stream/trait.Stream.html"><code>Stream</code></a> or <a href="https://docs.rs/futures/0.3/futures/sink/trait.Sink.html"><code>Sink</code></a> of data.</p>
<p>Tokio provides simple wrappers for converting <a href="trait.AsyncRead.html" title="trait tokio::io::AsyncRead"><code>AsyncRead</code></a> to <a href="https://docs.rs/futures/0.3/futures/stream/trait.Stream.html"><code>Stream</code></a>
and vice-versa in the <a href="https://docs.rs/tokio-util">tokio-util</a> crate, see <a href="https://docs.rs/tokio-util/latest/tokio_util/io/struct.ReaderStream.html"><code>ReaderStream</code></a> and
<a href="https://docs.rs/tokio-util/latest/tokio_util/io/struct.StreamReader.html"><code>StreamReader</code></a>.</p>
<p>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
<a href="trait.AsyncRead.html" title="trait tokio::io::AsyncRead"><code>AsyncRead</code></a>/<a href="trait.AsyncWrite.html" title="trait tokio::io::AsyncWrite"><code>AsyncWrite</code></a> into a <a href="https://docs.rs/futures/0.3/futures/stream/trait.Stream.html"><code>Stream</code></a>/<a href="https://docs.rs/futures/0.3/futures/sink/trait.Sink.html"><code>Sink</code></a>, see <a href="https://docs.rs/tokio-util/latest/tokio_util/codec/trait.Decoder.html"><code>Decoder</code></a> and
<a href="https://docs.rs/tokio-util/latest/tokio_util/codec/trait.Encoder.html"><code>Encoder</code></a> in the <a href="https://docs.rs/tokio-util/latest/tokio_util/codec/index.html">tokio-util::codec</a> module.</p>
<h2 id="standard-input-and-output"><a class="doc-anchor" href="#standard-input-and-output">§</a>Standard input and output</h2>
<p>Tokio provides asynchronous APIs to standard <a href="fn.stdin.html" title="fn tokio::io::stdin">input</a>, <a href="fn.stdout.html" title="fn tokio::io::stdout">output</a>, and <a href="fn.stderr.html" title="fn tokio::io::stderr">error</a>.
These APIs are very similar to the ones provided by <code>std</code>, but they also
implement <a href="trait.AsyncRead.html" title="trait tokio::io::AsyncRead"><code>AsyncRead</code></a> and <a href="trait.AsyncWrite.html" title="trait tokio::io::AsyncWrite"><code>AsyncWrite</code></a>.</p>
<p>Note that the standard input / output APIs <strong>must</strong> be used from the
context of the Tokio runtime, as they require Tokio-specific features to
function. Calling these functions outside of a Tokio runtime will panic.</p>
<h2 id="std-re-exports"><a class="doc-anchor" href="#std-re-exports">§</a><code>std</code> re-exports</h2>
<p>Additionally, <a href="https://doc.rust-lang.org/1.84.1/std/io/error/struct.Error.html" title="struct std::io::error::Error"><code>Error</code></a>, <a href="https://doc.rust-lang.org/1.84.1/std/io/error/enum.ErrorKind.html" title="enum std::io::error::ErrorKind"><code>ErrorKind</code></a>, <a href="https://doc.rust-lang.org/1.84.1/std/io/error/type.Result.html" title="type std::io::error::Result"><code>Result</code></a>, and <a href="https://doc.rust-lang.org/1.84.1/std/io/enum.SeekFrom.html" title="enum std::io::SeekFrom"><code>SeekFrom</code></a> are
re-exported from <code>std::io</code> for ease of use.</p>
</div></details><h2 id="reexports" class="section-header">Re-exports<a href="#reexports" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name" id="reexport.Error"><code>pub use std::io::<a class="struct" href="https://doc.rust-lang.org/1.84.1/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a>;</code></div></li><li><div class="item-name" id="reexport.ErrorKind"><code>pub use std::io::<a class="enum" href="https://doc.rust-lang.org/1.84.1/std/io/error/enum.ErrorKind.html" title="enum std::io::error::ErrorKind">ErrorKind</a>;</code></div></li><li><div class="item-name" id="reexport.Result"><code>pub use std::io::<a class="type" href="https://doc.rust-lang.org/1.84.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>;</code></div></li><li><div class="item-name" id="reexport.SeekFrom"><code>pub use std::io::<a class="enum" href="https://doc.rust-lang.org/1.84.1/std/io/enum.SeekFrom.html" title="enum std::io::SeekFrom">SeekFrom</a>;</code></div></li></ul><h2 id="modules" class="section-header">Modules<a href="#modules" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="mod" href="unix/index.html" title="mod tokio::io::unix">unix</a></div><div class="desc docblock-short">Asynchronous IO structures specific to Unix-like operating systems.</div></li></ul><h2 id="structs" class="section-header">Structs<a href="#structs" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="struct" href="struct.BufReader.html" title="struct tokio::io::BufReader">BufReader</a></div><div class="desc docblock-short">The <code>BufReader</code> struct adds buffering to any reader.</div></li><li><div class="item-name"><a class="struct" href="struct.BufStream.html" title="struct tokio::io::BufStream">BufStream</a></div><div class="desc docblock-short">Wraps a type that is <a href="trait.AsyncWrite.html" title="trait tokio::io::AsyncWrite"><code>AsyncWrite</code></a> and <a href="trait.AsyncRead.html" title="trait tokio::io::AsyncRead"><code>AsyncRead</code></a>, and buffers its input and output.</div></li><li><div class="item-name"><a class="struct" href="struct.BufWriter.html" title="struct tokio::io::BufWriter">BufWriter</a></div><div class="desc docblock-short">Wraps a writer and buffers its output.</div></li><li><div class="item-name"><a class="struct" href="struct.DuplexStream.html" title="struct tokio::io::DuplexStream">Duplex<wbr>Stream</a></div><div class="desc docblock-short">A bidirectional pipe to read and write bytes in memory.</div></li><li><div class="item-name"><a class="struct" href="struct.Empty.html" title="struct tokio::io::Empty">Empty</a></div><div class="desc docblock-short"><code>Empty</code> ignores any data written via <a href="trait.AsyncWrite.html" title="trait tokio::io::AsyncWrite"><code>AsyncWrite</code></a>, and will always be empty
(returning zero bytes) when read via <a href="trait.AsyncRead.html" title="trait tokio::io::AsyncRead"><code>AsyncRead</code></a>.</div></li><li><div class="item-name"><a class="struct" href="struct.Interest.html" title="struct tokio::io::Interest">Interest</a></div><div class="desc docblock-short">Readiness event interest.</div></li><li><div class="item-name"><a class="struct" href="struct.Join.html" title="struct tokio::io::Join">Join</a></div><div class="desc docblock-short">Joins two values implementing <code>AsyncRead</code> and <code>AsyncWrite</code> into a
single handle.</div></li><li><div class="item-name"><a class="struct" href="struct.Lines.html" title="struct tokio::io::Lines">Lines</a></div><div class="desc docblock-short">Reads lines from an <a href="trait.AsyncBufRead.html" title="trait tokio::io::AsyncBufRead"><code>AsyncBufRead</code></a>.</div></li><li><div class="item-name"><a class="struct" href="struct.ReadBuf.html" title="struct tokio::io::ReadBuf">ReadBuf</a></div><div class="desc docblock-short">A wrapper around a byte buffer that is incrementally filled and initialized.</div></li><li><div class="item-name"><a class="struct" href="struct.ReadHalf.html" title="struct tokio::io::ReadHalf">Read<wbr>Half</a></div><div class="desc docblock-short">The readable half of a value returned from <a href="fn.split.html" title="fn tokio::io::split"><code>split</code></a>.</div></li><li><div class="item-name"><a class="struct" href="struct.Ready.html" title="struct tokio::io::Ready">Ready</a></div><div class="desc docblock-short">Describes the readiness state of an I/O resources.</div></li><li><div class="item-name"><a class="struct" href="struct.Repeat.html" title="struct tokio::io::Repeat">Repeat</a></div><div class="desc docblock-short">An async reader which yields one byte over and over and over and over and
over and…</div></li><li><div class="item-name"><a class="struct" href="struct.SimplexStream.html" title="struct tokio::io::SimplexStream">Simplex<wbr>Stream</a></div><div class="desc docblock-short">A unidirectional pipe to read and write bytes in memory.</div></li><li><div class="item-name"><a class="struct" href="struct.Sink.html" title="struct tokio::io::Sink">Sink</a></div><div class="desc docblock-short">An async writer which will move data into the void.</div></li><li><div class="item-name"><a class="struct" href="struct.Split.html" title="struct tokio::io::Split">Split</a></div><div class="desc docblock-short">Splitter for the <a href="trait.AsyncBufReadExt.html#method.split" title="method tokio::io::AsyncBufReadExt::split"><code>split</code></a> method.</div></li><li><div class="item-name"><a class="struct" href="struct.Stderr.html" title="struct tokio::io::Stderr">Stderr</a></div><div class="desc docblock-short">A handle to the standard error stream of a process.</div></li><li><div class="item-name"><a class="struct" href="struct.Stdin.html" title="struct tokio::io::Stdin">Stdin</a></div><div class="desc docblock-short">A handle to the standard input stream of a process.</div></li><li><div class="item-name"><a class="struct" href="struct.Stdout.html" title="struct tokio::io::Stdout">Stdout</a></div><div class="desc docblock-short">A handle to the standard output stream of a process.</div></li><li><div class="item-name"><a class="struct" href="struct.Take.html" title="struct tokio::io::Take">Take</a></div><div class="desc docblock-short">Stream for the <a href="trait.AsyncReadExt.html#method.take" title="method tokio::io::AsyncReadExt::take"><code>take</code></a> method.</div></li><li><div class="item-name"><a class="struct" href="struct.WriteHalf.html" title="struct tokio::io::WriteHalf">Write<wbr>Half</a></div><div class="desc docblock-short">The writable half of a value returned from <a href="fn.split.html" title="fn tokio::io::split"><code>split</code></a>.</div></li></ul><h2 id="traits" class="section-header">Traits<a href="#traits" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="trait" href="trait.AsyncBufRead.html" title="trait tokio::io::AsyncBufRead">Async<wbr>BufRead</a></div><div class="desc docblock-short">Reads bytes asynchronously.</div></li><li><div class="item-name"><a class="trait" href="trait.AsyncBufReadExt.html" title="trait tokio::io::AsyncBufReadExt">Async<wbr>BufRead<wbr>Ext</a></div><div class="desc docblock-short">An extension trait which adds utility methods to <a href="trait.AsyncBufRead.html" title="trait tokio::io::AsyncBufRead"><code>AsyncBufRead</code></a> types.</div></li><li><div class="item-name"><a class="trait" href="trait.AsyncRead.html" title="trait tokio::io::AsyncRead">Async<wbr>Read</a></div><div class="desc docblock-short">Reads bytes from a source.</div></li><li><div class="item-name"><a class="trait" href="trait.AsyncReadExt.html" title="trait tokio::io::AsyncReadExt">Async<wbr>Read<wbr>Ext</a></div><div class="desc docblock-short">Reads bytes from a source.</div></li><li><div class="item-name"><a class="trait" href="trait.AsyncSeek.html" title="trait tokio::io::AsyncSeek">Async<wbr>Seek</a></div><div class="desc docblock-short">Seek bytes asynchronously.</div></li><li><div class="item-name"><a class="trait" href="trait.AsyncSeekExt.html" title="trait tokio::io::AsyncSeekExt">Async<wbr>Seek<wbr>Ext</a></div><div class="desc docblock-short">An extension trait that adds utility methods to <a href="trait.AsyncSeek.html" title="trait tokio::io::AsyncSeek"><code>AsyncSeek</code></a> types.</div></li><li><div class="item-name"><a class="trait" href="trait.AsyncWrite.html" title="trait tokio::io::AsyncWrite">Async<wbr>Write</a></div><div class="desc docblock-short">Writes bytes asynchronously.</div></li><li><div class="item-name"><a class="trait" href="trait.AsyncWriteExt.html" title="trait tokio::io::AsyncWriteExt">Async<wbr>Write<wbr>Ext</a></div><div class="desc docblock-short">Writes bytes to a sink.</div></li></ul><h2 id="functions" class="section-header">Functions<a href="#functions" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="fn" href="fn.copy.html" title="fn tokio::io::copy">copy</a></div><div class="desc docblock-short">Asynchronously copies the entire contents of a reader into a writer.</div></li><li><div class="item-name"><a class="fn" href="fn.copy_bidirectional.html" title="fn tokio::io::copy_bidirectional">copy_<wbr>bidirectional</a></div><div class="desc docblock-short">Copies data in both directions between <code>a</code> and <code>b</code>.</div></li><li><div class="item-name"><a class="fn" href="fn.copy_bidirectional_with_sizes.html" title="fn tokio::io::copy_bidirectional_with_sizes">copy_<wbr>bidirectional_<wbr>with_<wbr>sizes</a></div><div class="desc docblock-short">Copies data in both directions between <code>a</code> and <code>b</code> using buffers of the specified size.</div></li><li><div class="item-name"><a class="fn" href="fn.copy_buf.html" title="fn tokio::io::copy_buf">copy_<wbr>buf</a></div><div class="desc docblock-short">Asynchronously copies the entire contents of a reader into a writer.</div></li><li><div class="item-name"><a class="fn" href="fn.duplex.html" title="fn tokio::io::duplex">duplex</a></div><div class="desc docblock-short">Create a new pair of <code>DuplexStream</code>s that act like a pair of connected sockets.</div></li><li><div class="item-name"><a class="fn" href="fn.empty.html" title="fn tokio::io::empty">empty</a></div><div class="desc docblock-short">Creates a value that is always at EOF for reads, and ignores all data written.</div></li><li><div class="item-name"><a class="fn" href="fn.join.html" title="fn tokio::io::join">join</a></div><div class="desc docblock-short">Join two values implementing <code>AsyncRead</code> and <code>AsyncWrite</code> into a
single handle.</div></li><li><div class="item-name"><a class="fn" href="fn.repeat.html" title="fn tokio::io::repeat">repeat</a></div><div class="desc docblock-short">Creates an instance of an async reader that infinitely repeats one byte.</div></li><li><div class="item-name"><a class="fn" href="fn.simplex.html" title="fn tokio::io::simplex">simplex</a></div><div class="desc docblock-short">Creates unidirectional buffer that acts like in memory pipe.</div></li><li><div class="item-name"><a class="fn" href="fn.sink.html" title="fn tokio::io::sink">sink</a></div><div class="desc docblock-short">Creates an instance of an async writer which will successfully consume all
data.</div></li><li><div class="item-name"><a class="fn" href="fn.split.html" title="fn tokio::io::split">split</a></div><div class="desc docblock-short">Splits a single value implementing <code>AsyncRead + AsyncWrite</code> into separate
<code>AsyncRead</code> and <code>AsyncWrite</code> handles.</div></li><li><div class="item-name"><a class="fn" href="fn.stderr.html" title="fn tokio::io::stderr">stderr</a></div><div class="desc docblock-short">Constructs a new handle to the standard error of the current process.</div></li><li><div class="item-name"><a class="fn" href="fn.stdin.html" title="fn tokio::io::stdin">stdin</a></div><div class="desc docblock-short">Constructs a new handle to the standard input of the current process.</div></li><li><div class="item-name"><a class="fn" href="fn.stdout.html" title="fn tokio::io::stdout">stdout</a></div><div class="desc docblock-short">Constructs a new handle to the standard output of the current process.</div></li></ul></section></div></main></body></html>