mentat/docs/apis/rust/tokio/io/index.html

417 lines
21 KiB
HTML
Raw Normal View History

2018-06-21 14:44:35 +00:00
<!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="API documentation for the Rust `io` mod in crate `tokio`.">
<meta name="keywords" content="rust, rustlang, rust-lang, io">
<title>tokio::io - Rust</title>
<link rel="stylesheet" type="text/css" href="../../normalize.css">
<link rel="stylesheet" type="text/css" href="../../rustdoc.css"
id="mainThemeStyle">
<link rel="stylesheet" type="text/css" href="../../dark.css">
<link rel="stylesheet" type="text/css" href="../../light.css" id="themeStyle">
<script src="../../storage.js"></script>
</head>
<body class="rustdoc mod">
<!--[if lte IE 8]>
<div class="warning">
This old browser is unsupported and will most likely display funky
things.
</div>
<![endif]-->
<nav class="sidebar">
<div class="sidebar-menu">&#9776;</div>
<p class='location'>Module io</p><div class="sidebar-elems"><div class="block items"><ul><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></div><p class='location'><a href='../index.html'>tokio</a></p><script>window.sidebarCurrent = {name: 'io', ty: 'mod', relpath: '../'};</script><script defer src="../sidebar-items.js"></script></div>
</nav>
<div class="theme-picker">
<button id="theme-picker" aria-label="Pick another theme!">
<img src="../../brush.svg" width="18" alt="Pick another theme!">
</button>
<div id="theme-choices"></div>
</div>
<script src="../../theme.js"></script>
<nav class="sub">
<form class="search-form js-only">
<div class="search-container">
<input class="search-input" name="search"
autocomplete="off"
placeholder="Click or press S to search, ? for more options…"
type="search">
</div>
</form>
</nav>
<section id='main' class="content"><h1 class='fqn'><span class='in-band'>Module <a href='../index.html'>tokio</a>::<wbr><a class="mod" href=''>io</a></span><span class='out-of-band'><span id='render-detail'>
<a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">
[<span class='inner'>&#x2212;</span>]
</a>
</span><a class='srclink' href='../../src/tokio/lib.rs.html#100-194' title='goto source code'>[src]</a></span></h1><div class='docblock'><p>Asynchronous I/O.</p>
<p>This module is the asynchronous version of <code>std::io</code>. Primarily, it
defines two traits, <a href="trait.AsyncRead.html"><code>AsyncRead</code></a> and <a href="trait.AsyncWrite.html"><code>AsyncWrite</code></a>, which extend the
<code>Read</code> and <code>Write</code> traits of the standard library.</p>
<h1 id="asyncread-and-asyncwrite" class="section-header"><a href="#asyncread-and-asyncwrite">AsyncRead and AsyncWrite</a></h1>
<p><a href="trait.AsyncRead.html"><code>AsyncRead</code></a> and <a href="trait.AsyncWrite.html"><code>AsyncWrite</code></a> 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>
<h1 id="standard-input-and-output" class="section-header"><a href="#standard-input-and-output">Standard input and output</a></h1>
<p>Tokio provides asynchronous APIs to standard <a href="fn.stdin.html">input</a>, <a href="fn.stdout.html">output</a>, and <a href="fn.stderr.html">error</a>.
These APIs are very similar to the ones provided by <code>std</code>, but they also
implement <a href="trait.AsyncRead.html"><code>AsyncRead</code></a> and <a href="trait.AsyncWrite.html"><code>AsyncWrite</code></a>.</p>
<p>Unlike <em>most</em> other Tokio APIs, 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.</p>
<h1 id="utility-functions" class="section-header"><a href="#utility-functions">Utility functions</a></h1>
<p>Utilities functions are provided for working with <a href="trait.AsyncRead.html"><code>AsyncRead</code></a> /
<a href="trait.AsyncWrite.html"><code>AsyncWrite</code></a> types. For example, <a href="fn.copy.html"><code>copy</code></a> asynchronously copies all
data from a source to a destination.</p>
<h1 id="std-re-exports" class="section-header"><a href="#std-re-exports"><code>std</code> re-exports</a></h1>
<p>Additionally, <a href="trait.Read.html"><code>Read</code></a>, <a href="trait.Write.html"><code>Write</code></a>, <a href="struct.Error.html"><code>Error</code></a>, <a href="enum.ErrorKind.html"><code>ErrorKind</code></a>, and
<a href="type.Result.html"><code>Result</code></a> are re-exported from <code>std::io</code> for ease of use.</p>
</div><h2 id='structs' class='section-header'><a href="#structs">Structs</a></h2>
<table>
<tr class=' module-item'>
<td><a class="struct" href="struct.Copy.html"
title='struct tokio::io::Copy'>Copy</a></td>
<td class='docblock-short'>
<p>A future which will copy all data from a reader into a writer.</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class="struct" href="struct.Error.html"
title='struct tokio::io::Error'>Error</a></td>
<td class='docblock-short'>
<p>The error type for I/O operations of the <a href="../io/trait.Read.html"><code>Read</code></a>, <a href="../io/trait.Write.html"><code>Write</code></a>, <a href="../io/trait.Seek.html"><code>Seek</code></a>, and
associated traits.</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class="struct" href="struct.Flush.html"
title='struct tokio::io::Flush'>Flush</a></td>
<td class='docblock-short'>
<p>A future used to fully flush an I/O object.</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class="struct" href="struct.Lines.html"
title='struct tokio::io::Lines'>Lines</a></td>
<td class='docblock-short'>
<p>Combinator created by the top-level <code>lines</code> method which is a stream over
the lines of text on an I/O object.</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class="struct" href="struct.ReadExact.html"
title='struct tokio::io::ReadExact'>ReadExact</a></td>
<td class='docblock-short'>
<p>A future which can be used to easily read exactly enough bytes to fill
a buffer.</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class="struct" href="struct.ReadHalf.html"
title='struct tokio::io::ReadHalf'>ReadHalf</a></td>
<td class='docblock-short'>
<p>The readable half of an object returned from <code>AsyncRead::split</code>.</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class="struct" href="struct.ReadToEnd.html"
title='struct tokio::io::ReadToEnd'>ReadToEnd</a></td>
<td class='docblock-short'>
<p>A future which can be used to easily read the entire contents of a stream
into a vector.</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class="struct" href="struct.ReadUntil.html"
title='struct tokio::io::ReadUntil'>ReadUntil</a></td>
<td class='docblock-short'>
<p>A future which can be used to easily read the contents of a stream into a
vector until the delimiter is reached.</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class="struct" href="struct.Shutdown.html"
title='struct tokio::io::Shutdown'>Shutdown</a></td>
<td class='docblock-short'>
<p>A future used to fully shutdown an I/O object.</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class="struct" href="struct.Stderr.html"
title='struct tokio::io::Stderr'>Stderr</a></td>
<td class='docblock-short'>
<p>A handle to the standard error stream of a process.</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class="struct" href="struct.Stdin.html"
title='struct tokio::io::Stdin'>Stdin</a></td>
<td class='docblock-short'>
<p>A handle to the standard input stream of a process.</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class="struct" href="struct.Stdout.html"
title='struct tokio::io::Stdout'>Stdout</a></td>
<td class='docblock-short'>
<p>A handle to the standard output stream of a process.</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class="struct" href="struct.WriteAll.html"
title='struct tokio::io::WriteAll'>WriteAll</a></td>
<td class='docblock-short'>
<p>A future used to write the entire contents of some data to a stream.</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class="struct" href="struct.WriteHalf.html"
title='struct tokio::io::WriteHalf'>WriteHalf</a></td>
<td class='docblock-short'>
<p>The writable half of an object returned from <code>AsyncRead::split</code>.</p>
</td>
</tr></table><h2 id='enums' class='section-header'><a href="#enums">Enums</a></h2>
<table>
<tr class=' module-item'>
<td><a class="enum" href="enum.ErrorKind.html"
title='enum tokio::io::ErrorKind'>ErrorKind</a></td>
<td class='docblock-short'>
<p>A list specifying general categories of I/O error.</p>
</td>
</tr></table><h2 id='traits' class='section-header'><a href="#traits">Traits</a></h2>
<table>
<tr class=' module-item'>
<td><a class="trait" href="trait.AsyncRead.html"
title='trait tokio::io::AsyncRead'>AsyncRead</a></td>
<td class='docblock-short'>
<p>Read bytes asynchronously.</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class="trait" href="trait.AsyncWrite.html"
title='trait tokio::io::AsyncWrite'>AsyncWrite</a></td>
<td class='docblock-short'>
<p>Writes bytes asynchronously.</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class="trait" href="trait.Read.html"
title='trait tokio::io::Read'>Read</a></td>
<td class='docblock-short'>
<p>The <code>Read</code> trait allows for reading bytes from a source.</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class="trait" href="trait.Write.html"
title='trait tokio::io::Write'>Write</a></td>
<td class='docblock-short'>
<p>A trait for objects which are byte-oriented sinks.</p>
</td>
</tr></table><h2 id='functions' class='section-header'><a href="#functions">Functions</a></h2>
<table>
<tr class=' module-item'>
<td><a class="fn" href="fn.copy.html"
title='fn tokio::io::copy'>copy</a></td>
<td class='docblock-short'>
<p>Creates a future which represents copying all the bytes from one object to
another.</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class="fn" href="fn.flush.html"
title='fn tokio::io::flush'>flush</a></td>
<td class='docblock-short'>
<p>Creates a future which will entirely flush an I/O object and then yield the
object itself.</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class="fn" href="fn.lines.html"
title='fn tokio::io::lines'>lines</a></td>
<td class='docblock-short'>
<p>Creates a new stream from the I/O object given representing the lines of
input that are found on <code>A</code>.</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class="fn" href="fn.read_exact.html"
title='fn tokio::io::read_exact'>read_exact</a></td>
<td class='docblock-short'>
<p>Creates a future which will read exactly enough bytes to fill <code>buf</code>,
returning an error if EOF is hit sooner.</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class="fn" href="fn.read_to_end.html"
title='fn tokio::io::read_to_end'>read_to_end</a></td>
<td class='docblock-short'>
<p>Creates a future which will read all the bytes associated with the I/O
object <code>A</code> into the buffer provided.</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class="fn" href="fn.read_until.html"
title='fn tokio::io::read_until'>read_until</a></td>
<td class='docblock-short'>
<p>Creates a future which will read all the bytes associated with the I/O
object <code>A</code> into the buffer provided until the delimiter <code>byte</code> is reached.
This method is the async equivalent to <a href="https://doc.rust-lang.org/std/io/trait.BufRead.html#method.read_until"><code>BufRead::read_until</code></a>.</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class="fn" href="fn.shutdown.html"
title='fn tokio::io::shutdown'>shutdown</a></td>
<td class='docblock-short'>
<p>Creates a future which will entirely shutdown an I/O object and then yield
the object itself.</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class="fn" href="fn.stderr.html"
title='fn tokio::io::stderr'>stderr</a></td>
<td class='docblock-short'>
<p>Constructs a new handle to the standard error of the current process.</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class="fn" href="fn.stdin.html"
title='fn tokio::io::stdin'>stdin</a></td>
<td class='docblock-short'>
<p>Constructs a new handle to the standard input of the current process.</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class="fn" href="fn.stdout.html"
title='fn tokio::io::stdout'>stdout</a></td>
<td class='docblock-short'>
<p>Constructs a new handle to the standard output of the current process.</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class="fn" href="fn.write_all.html"
title='fn tokio::io::write_all'>write_all</a></td>
<td class='docblock-short'>
<p>Creates a future that will write the entire contents of the buffer <code>buf</code> to
the stream <code>a</code> provided.</p>
</td>
</tr></table><h2 id='types' class='section-header'><a href="#types">Type Definitions</a></h2>
<table>
<tr class=' module-item'>
<td><a class="type" href="type.Result.html"
title='type tokio::io::Result'>Result</a></td>
<td class='docblock-short'>
<p>A specialized <a href="../result/enum.Result.html"><code>Result</code></a> type for I/O
operations.</p>
</td>
</tr></table></section>
<section id='search' class="content hidden"></section>
<section class="footer"></section>
<aside id="help" class="hidden">
<div>
<h1 class="hidden">Help</h1>
<div class="shortcuts">
<h2>Keyboard Shortcuts</h2>
<dl>
<dt><kbd>?</kbd></dt>
<dd>Show this help dialog</dd>
<dt><kbd>S</kbd></dt>
<dd>Focus the search field</dd>
<dt><kbd></kbd></dt>
<dd>Move up in search results</dd>
<dt><kbd></kbd></dt>
<dd>Move down in search results</dd>
<dt><kbd></kbd></dt>
<dd>Switch tab</dd>
<dt><kbd>&#9166;</kbd></dt>
<dd>Go to active search result</dd>
<dt><kbd>+</kbd></dt>
<dd>Expand all sections</dd>
<dt><kbd>-</kbd></dt>
<dd>Collapse all sections</dd>
</dl>
</div>
<div class="infos">
<h2>Search Tricks</h2>
<p>
Prefix searches with a type followed by a colon (e.g.
<code>fn:</code>) to restrict the search to a given type.
</p>
<p>
Accepted types are: <code>fn</code>, <code>mod</code>,
<code>struct</code>, <code>enum</code>,
<code>trait</code>, <code>type</code>, <code>macro</code>,
and <code>const</code>.
</p>
<p>
Search functions by type signature (e.g.
<code>vec -> usize</code> or <code>* -> vec</code>)
</p>
</div>
</div>
</aside>
<script>
window.rootPath = "../../";
window.currentCrate = "tokio";
</script>
<script src="../../main.js"></script>
<script defer src="../../search-index.js"></script>
</body>
</html>