blob: 7d15d7afc1979d2e0c3104621f40dc564532d3f9 [file] [log] [blame]
<!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="Asynchronous I/O."><meta name="keywords" content="rust, rustlang, rust-lang, io"><title>futures::io - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Semibold.ttf.woff2"><link rel="stylesheet" href="../../normalize.css"><link rel="stylesheet" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" href="../../ayu.css" disabled><link rel="stylesheet" href="../../dark.css" disabled><link rel="stylesheet" href="../../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../../storage.js"></script><script defer src="../../main.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="alternate icon" type="image/png" href="../../favicon-16x16.png"><link rel="alternate icon" type="image/png" href="../../favicon-32x32.png"><link rel="icon" type="image/svg+xml" href="../../favicon.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">&#9776;</button><a class="sidebar-logo" href="../../futures/index.html"><div class="logo-container"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></div></a><h2></h2></nav><nav class="sidebar"><a class="sidebar-logo" href="../../futures/index.html"><div class="logo-container"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></div></a><h2 class="location"><a href="#">Module io</a></h2><div class="sidebar-elems"><section><ul class="block"><li><a href="#structs">Structs</a></li><li><a href="#enums">Enums</a></li><li><a href="#traits">Traits</a></li><li><a href="#functions">Functions</a></li><li><a href="#types">Type Definitions</a></li></ul></section></div></nav><main><div class="width-limiter"><nav class="sub"><form class="search-form"><div class="search-container"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../wheel.svg"></a></div></div></form></nav><section id="main-content" class="content"><div class="main-heading"><h1 class="fqn">Module <a href="../index.html">futures</a>::<wbr><a class="mod" href="#">io</a><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../../clipboard.svg" width="19" height="18" alt="Copy item path"></button></h1><span class="out-of-band"><a class="srclink" href="../../src/futures_util/lib.rs.html#320">source</a> · <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">&#x2212;</span>]</a></span></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Asynchronous I/O.</p>
<p>This module is the asynchronous version of <code>std::io</code>. It defines four
traits, <a href="trait.AsyncRead.html" title="AsyncRead"><code>AsyncRead</code></a>, <a href="trait.AsyncWrite.html" title="AsyncWrite"><code>AsyncWrite</code></a>, <a href="trait.AsyncSeek.html" title="AsyncSeek"><code>AsyncSeek</code></a>, and <a href="trait.AsyncBufRead.html" title="AsyncBufRead"><code>AsyncBufRead</code></a>,
which mirror the <code>Read</code>, <code>Write</code>, <code>Seek</code>, and <code>BufRead</code> traits of the
standard library. However, these traits integrate with the asynchronous
task system, so that if an I/O object isn’t ready for reading (or writing),
the thread is not blocked, and instead the current task is queued to be
woken when I/O is ready.</p>
<p>In addition, the <a href="trait.AsyncReadExt.html" title="AsyncReadExt"><code>AsyncReadExt</code></a>, <a href="trait.AsyncWriteExt.html" title="AsyncWriteExt"><code>AsyncWriteExt</code></a>, <a href="trait.AsyncSeekExt.html" title="AsyncSeekExt"><code>AsyncSeekExt</code></a>, and
<a href="trait.AsyncBufReadExt.html" title="AsyncBufReadExt"><code>AsyncBufReadExt</code></a> extension traits offer a variety of useful combinators
for operating with asynchronous I/O objects, including ways to work with
them using futures, streams and sinks.</p>
<p>This module is only available when the <code>std</code> feature of this
library is activated, and it is activated by default.</p>
</div></details><h2 id="structs" class="small-section-header"><a href="#structs">Structs</a></h2><div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.AllowStdIo.html" title="futures::io::AllowStdIo struct">AllowStdIo</a></div><div class="item-right docblock-short">A simple wrapper type which allows types which implement only
implement <code>std::io::Read</code> or <code>std::io::Write</code>
to be used in contexts which expect an <code>AsyncRead</code> or <code>AsyncWrite</code>.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.BufReader.html" title="futures::io::BufReader struct">BufReader</a></div><div class="item-right docblock-short">The <code>BufReader</code> struct adds buffering to any reader.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.BufWriter.html" title="futures::io::BufWriter struct">BufWriter</a></div><div class="item-right docblock-short">Wraps a writer and buffers its output.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.Chain.html" title="futures::io::Chain struct">Chain</a></div><div class="item-right docblock-short">Reader for the <a href="trait.AsyncReadExt.html#method.chain"><code>chain</code></a> method.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.Close.html" title="futures::io::Close struct">Close</a></div><div class="item-right docblock-short">Future for the <a href="trait.AsyncWriteExt.html#method.close"><code>close</code></a> method.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.Copy.html" title="futures::io::Copy struct">Copy</a></div><div class="item-right docblock-short">Future for the <a href="fn.copy.html" title="copy()"><code>copy()</code></a> function.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.CopyBuf.html" title="futures::io::CopyBuf struct">CopyBuf</a></div><div class="item-right docblock-short">Future for the <a href="fn.copy_buf.html" title="copy_buf()"><code>copy_buf()</code></a> function.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.CopyBufAbortable.html" title="futures::io::CopyBufAbortable struct">CopyBufAbortable</a></div><div class="item-right docblock-short">Future for the [<code>copy_buf()</code>] function.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.Cursor.html" title="futures::io::Cursor struct">Cursor</a></div><div class="item-right docblock-short">A <code>Cursor</code> wraps an in-memory buffer and provides it with a
<a href="trait.AsyncSeek.html"><code>AsyncSeek</code></a> implementation.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.Empty.html" title="futures::io::Empty struct">Empty</a></div><div class="item-right docblock-short">Reader for the <a href="fn.empty.html" title="empty()"><code>empty()</code></a> function.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.Error.html" title="futures::io::Error struct">Error</a></div><div class="item-right docblock-short">The error type for I/O operations of the <a href="crate::io::Read"><code>Read</code></a>, <a href="crate::io::Write"><code>Write</code></a>, <a href="crate::io::Seek"><code>Seek</code></a>, and
associated traits.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.FillBuf.html" title="futures::io::FillBuf struct">FillBuf</a></div><div class="item-right docblock-short">Future for the <a href="trait.AsyncBufReadExt.html#method.fill_buf"><code>fill_buf</code></a> method.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.Flush.html" title="futures::io::Flush struct">Flush</a></div><div class="item-right docblock-short">Future for the <a href="trait.AsyncWriteExt.html#method.flush"><code>flush</code></a> method.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.IntoSink.html" title="futures::io::IntoSink struct">IntoSink</a></div><div class="item-right docblock-short">Sink for the <a href="trait.AsyncWriteExt.html#method.into_sink"><code>into_sink</code></a> method.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.IoSlice.html" title="futures::io::IoSlice struct">IoSlice</a></div><div class="item-right docblock-short">A buffer type used with <code>Write::write_vectored</code>.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.IoSliceMut.html" title="futures::io::IoSliceMut struct">IoSliceMut</a></div><div class="item-right docblock-short">A buffer type used with <code>Read::read_vectored</code>.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.LineWriter.html" title="futures::io::LineWriter struct">LineWriter</a></div><div class="item-right docblock-short">Wrap a writer, like <a href="struct.BufWriter.html" title="BufWriter"><code>BufWriter</code></a> does, but prioritizes buffering lines</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.Lines.html" title="futures::io::Lines struct">Lines</a></div><div class="item-right docblock-short">Stream for the <a href="trait.AsyncBufReadExt.html#method.lines"><code>lines</code></a> method.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.Read.html" title="futures::io::Read struct">Read</a></div><div class="item-right docblock-short">Future for the <a href="trait.AsyncReadExt.html#method.read"><code>read</code></a> method.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.ReadExact.html" title="futures::io::ReadExact struct">ReadExact</a></div><div class="item-right docblock-short">Future for the <a href="trait.AsyncReadExt.html#method.read_exact"><code>read_exact</code></a> method.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.ReadHalf.html" title="futures::io::ReadHalf struct">ReadHalf</a></div><div class="item-right docblock-short">The readable half of an object returned from <code>AsyncRead::split</code>.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.ReadLine.html" title="futures::io::ReadLine struct">ReadLine</a></div><div class="item-right docblock-short">Future for the <a href="trait.AsyncBufReadExt.html#method.read_line"><code>read_line</code></a> method.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.ReadToEnd.html" title="futures::io::ReadToEnd struct">ReadToEnd</a></div><div class="item-right docblock-short">Future for the <a href="trait.AsyncReadExt.html#method.read_to_end"><code>read_to_end</code></a> method.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.ReadToString.html" title="futures::io::ReadToString struct">ReadToString</a></div><div class="item-right docblock-short">Future for the <a href="trait.AsyncReadExt.html#method.read_to_string"><code>read_to_string</code></a> method.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.ReadUntil.html" title="futures::io::ReadUntil struct">ReadUntil</a></div><div class="item-right docblock-short">Future for the <a href="trait.AsyncBufReadExt.html#method.read_until"><code>read_until</code></a> method.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.ReadVectored.html" title="futures::io::ReadVectored struct">ReadVectored</a></div><div class="item-right docblock-short">Future for the <a href="trait.AsyncReadExt.html#method.read_vectored"><code>read_vectored</code></a> method.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.Repeat.html" title="futures::io::Repeat struct">Repeat</a></div><div class="item-right docblock-short">Reader for the <a href="fn.repeat.html" title="repeat()"><code>repeat()</code></a> function.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.ReuniteError.html" title="futures::io::ReuniteError struct">ReuniteError</a></div><div class="item-right docblock-short">Error indicating a <code>ReadHalf&lt;T&gt;</code> and <code>WriteHalf&lt;T&gt;</code> were not two halves
of a <code>AsyncRead + AsyncWrite</code>, and thus could not be <code>reunite</code>d.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.SeeKRelative.html" title="futures::io::SeeKRelative struct">SeeKRelative</a></div><div class="item-right docblock-short">Future for the <a href="struct.BufReader.html#method.seek_relative"><code>BufReader::seek_relative</code></a> method.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.Seek.html" title="futures::io::Seek struct">Seek</a></div><div class="item-right docblock-short">Future for the <a href="trait.AsyncSeekExt.html#method.seek"><code>seek</code></a> method.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.Sink.html" title="futures::io::Sink struct">Sink</a></div><div class="item-right docblock-short">Writer for the <a href="fn.sink.html" title="sink()"><code>sink()</code></a> function.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.Take.html" title="futures::io::Take struct">Take</a></div><div class="item-right docblock-short">Reader for the <a href="trait.AsyncReadExt.html#method.take"><code>take</code></a> method.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.Window.html" title="futures::io::Window struct">Window</a></div><div class="item-right docblock-short">A owned window around an underlying buffer.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.Write.html" title="futures::io::Write struct">Write</a></div><div class="item-right docblock-short">Future for the <a href="trait.AsyncWriteExt.html#method.write"><code>write</code></a> method.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.WriteAll.html" title="futures::io::WriteAll struct">WriteAll</a></div><div class="item-right docblock-short">Future for the <a href="trait.AsyncWriteExt.html#method.write_all"><code>write_all</code></a> method.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.WriteHalf.html" title="futures::io::WriteHalf struct">WriteHalf</a></div><div class="item-right docblock-short">The writable half of an object returned from <code>AsyncRead::split</code>.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.WriteVectored.html" title="futures::io::WriteVectored struct">WriteVectored</a></div><div class="item-right docblock-short">Future for the <a href="trait.AsyncWriteExt.html#method.write_vectored"><code>write_vectored</code></a> method.</div></div></div><h2 id="enums" class="small-section-header"><a href="#enums">Enums</a></h2><div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="enum" href="enum.ErrorKind.html" title="futures::io::ErrorKind enum">ErrorKind</a></div><div class="item-right docblock-short">A list specifying general categories of I/O error.</div></div><div class="item-row"><div class="item-left module-item"><a class="enum" href="enum.SeekFrom.html" title="futures::io::SeekFrom enum">SeekFrom</a></div><div class="item-right docblock-short">Enumeration of possible methods to seek within an I/O object.</div></div></div><h2 id="traits" class="small-section-header"><a href="#traits">Traits</a></h2><div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="trait" href="trait.AsyncBufRead.html" title="futures::io::AsyncBufRead trait">AsyncBufRead</a></div><div class="item-right docblock-short">Read bytes asynchronously.</div></div><div class="item-row"><div class="item-left module-item"><a class="trait" href="trait.AsyncBufReadExt.html" title="futures::io::AsyncBufReadExt trait">AsyncBufReadExt</a></div><div class="item-right docblock-short">An extension trait which adds utility methods to <code>AsyncBufRead</code> types.</div></div><div class="item-row"><div class="item-left module-item"><a class="trait" href="trait.AsyncRead.html" title="futures::io::AsyncRead trait">AsyncRead</a></div><div class="item-right docblock-short">Read bytes asynchronously.</div></div><div class="item-row"><div class="item-left module-item"><a class="trait" href="trait.AsyncReadExt.html" title="futures::io::AsyncReadExt trait">AsyncReadExt</a></div><div class="item-right docblock-short">An extension trait which adds utility methods to <code>AsyncRead</code> types.</div></div><div class="item-row"><div class="item-left module-item"><a class="trait" href="trait.AsyncSeek.html" title="futures::io::AsyncSeek trait">AsyncSeek</a></div><div class="item-right docblock-short">Seek bytes asynchronously.</div></div><div class="item-row"><div class="item-left module-item"><a class="trait" href="trait.AsyncSeekExt.html" title="futures::io::AsyncSeekExt trait">AsyncSeekExt</a></div><div class="item-right docblock-short">An extension trait which adds utility methods to <code>AsyncSeek</code> types.</div></div><div class="item-row"><div class="item-left module-item"><a class="trait" href="trait.AsyncWrite.html" title="futures::io::AsyncWrite trait">AsyncWrite</a></div><div class="item-right docblock-short">Write bytes asynchronously.</div></div><div class="item-row"><div class="item-left module-item"><a class="trait" href="trait.AsyncWriteExt.html" title="futures::io::AsyncWriteExt trait">AsyncWriteExt</a></div><div class="item-right docblock-short">An extension trait which adds utility methods to <code>AsyncWrite</code> types.</div></div></div><h2 id="functions" class="small-section-header"><a href="#functions">Functions</a></h2><div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="fn" href="fn.copy.html" title="futures::io::copy fn">copy</a></div><div class="item-right docblock-short">Creates a future which copies all the bytes from one object to another.</div></div><div class="item-row"><div class="item-left module-item"><a class="fn" href="fn.copy_buf.html" title="futures::io::copy_buf fn">copy_buf</a></div><div class="item-right docblock-short">Creates a future which copies all the bytes from one object to another.</div></div><div class="item-row"><div class="item-left module-item"><a class="fn" href="fn.copy_buf_abortable.html" title="futures::io::copy_buf_abortable fn">copy_buf_abortable</a></div><div class="item-right docblock-short">Creates a future which copies all the bytes from one object to another, with its <code>AbortHandle</code>.</div></div><div class="item-row"><div class="item-left module-item"><a class="fn" href="fn.empty.html" title="futures::io::empty fn">empty</a></div><div class="item-right docblock-short">Constructs a new handle to an empty reader.</div></div><div class="item-row"><div class="item-left module-item"><a class="fn" href="fn.repeat.html" title="futures::io::repeat fn">repeat</a></div><div class="item-right docblock-short">Creates an instance of a reader that infinitely repeats one byte.</div></div><div class="item-row"><div class="item-left module-item"><a class="fn" href="fn.sink.html" title="futures::io::sink fn">sink</a></div><div class="item-right docblock-short">Creates an instance of a writer which will successfully consume all data.</div></div></div><h2 id="types" class="small-section-header"><a href="#types">Type Definitions</a></h2><div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="type" href="type.Result.html" title="futures::io::Result type">Result</a></div><div class="item-right docblock-short">A specialized <a href="crate::result::Result"><code>Result</code></a> type for I/O operations.</div></div></div></section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="futures" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.66.0-nightly (5c8bff74b 2022-10-21)" ></div></body></html>