168 lines
No EOL
13 KiB
HTML
168 lines
No EOL
13 KiB
HTML
<!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 `Stdin` struct in crate `bitflags`.">
|
||
<meta name="keywords" content="rust, rustlang, rust-lang, Stdin">
|
||
|
||
<title>bitflags::__core::io::Stdin - Rust</title>
|
||
|
||
<link rel="stylesheet" type="text/css" href="../../../rustdoc.css">
|
||
<link rel="stylesheet" type="text/css" href="../../../main.css">
|
||
|
||
|
||
|
||
|
||
</head>
|
||
<body class="rustdoc">
|
||
<!--[if lte IE 8]>
|
||
<div class="warning">
|
||
This old browser is unsupported and will most likely display funky
|
||
things.
|
||
</div>
|
||
<![endif]-->
|
||
|
||
|
||
|
||
<nav class="sidebar">
|
||
|
||
<p class='location'><a href='../../index.html'>bitflags</a>::<wbr><a href='../index.html'>__core</a>::<wbr><a href='index.html'>io</a></p><script>window.sidebarCurrent = {name: 'Stdin', ty: 'struct', relpath: ''};</script><script defer src="sidebar-items.js"></script>
|
||
</nav>
|
||
|
||
<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 struct">
|
||
<h1 class='fqn'><span class='in-band'>Struct <a href='../../index.html'>bitflags</a>::<wbr><a href='../index.html'>__core</a>::<wbr><a href='index.html'>io</a>::<wbr><a class='struct' href=''>Stdin</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'>−</span>]
|
||
</a>
|
||
</span><a id='src-4664' class='srclink' href='https://doc.rust-lang.org/nightly/std/io/stdio/struct.Stdin.html?gotosrc=4664' title='goto source code'>[src]</a></span></h1>
|
||
<pre class='rust struct'>pub struct Stdin {
|
||
// some fields omitted
|
||
}</pre><span class="since">1.0.0</span><div class='docblock'><p>A handle to the standard input stream of a process.</p>
|
||
|
||
<p>Each handle is a shared reference to a global buffer of input data to this
|
||
process. A handle can be <code>lock</code>'d to gain full access to <a href="trait.BufRead.html"><code>BufRead</code></a> methods
|
||
(e.g. <code>.lines()</code>). Reads to this handle are otherwise locked with respect
|
||
to other reads.</p>
|
||
|
||
<p>This handle implements the <code>Read</code> trait, but beware that concurrent reads
|
||
of <code>Stdin</code> must be executed with care.</p>
|
||
|
||
<p>Created by the <a href="fn.stdin.html"><code>io::stdin</code></a> method.</p>
|
||
</div><h2 id='methods'>Methods</h2><h3 class='impl'><code>impl <a class='struct' href='../../../bitflags/__core/io/struct.Stdin.html' title='bitflags::__core::io::Stdin'>Stdin</a></code></h3><div class='impl-items'><h4 id='method.lock' class='method'><code>fn <a href='#method.lock' class='fnname'>lock</a>(&self) -> <a class='struct' href='../../../bitflags/__core/io/struct.StdinLock.html' title='bitflags::__core::io::StdinLock'>StdinLock</a></code></h4>
|
||
<div class='docblock'><p>Locks this handle to the standard input stream, returning a readable
|
||
guard.</p>
|
||
|
||
<p>The lock is released when the returned lock goes out of scope. The
|
||
returned guard also implements the <a href="trait.Read.html"><code>Read</code></a> and <a href="trait.BufRead.html"><code>BufRead</code></a> traits for
|
||
accessing the underlying data.</p>
|
||
</div><h4 id='method.read_line' class='method'><code>fn <a href='#method.read_line' class='fnname'>read_line</a>(&self, buf: &mut <a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a>) -> <a class='enum' href='../../../bitflags/__core/result/enum.Result.html' title='bitflags::__core::result::Result'>Result</a><<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.usize.html'>usize</a>, <a class='struct' href='../../../bitflags/__core/io/struct.Error.html' title='bitflags::__core::io::Error'>Error</a>></code></h4>
|
||
<div class='docblock'><p>Locks this handle and reads a line of input into the specified buffer.</p>
|
||
|
||
<p>For detailed semantics of this method, see the documentation on
|
||
<a href="trait.BufRead.html#method.read_line"><code>BufRead::read_line</code></a>.</p>
|
||
|
||
<h1 id='examples' class='section-header'><a href='#examples'>Examples</a></h1>
|
||
<pre class='rust rust-example-rendered'>
|
||
<span class='kw'>use</span> <span class='ident'>std</span>::<span class='ident'>io</span>;
|
||
|
||
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>input</span> <span class='op'>=</span> <span class='ident'>String</span>::<span class='ident'>new</span>();
|
||
<span class='kw'>match</span> <span class='ident'>io</span>::<span class='ident'>stdin</span>().<span class='ident'>read_line</span>(<span class='kw-2'>&</span><span class='kw-2'>mut</span> <span class='ident'>input</span>) {
|
||
<span class='prelude-val'>Ok</span>(<span class='ident'>n</span>) <span class='op'>=></span> {
|
||
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>"{} bytes read"</span>, <span class='ident'>n</span>);
|
||
<span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>"{}"</span>, <span class='ident'>input</span>);
|
||
}
|
||
<span class='prelude-val'>Err</span>(<span class='ident'>error</span>) <span class='op'>=></span> <span class='macro'>println</span><span class='macro'>!</span>(<span class='string'>"error: {}"</span>, <span class='ident'>error</span>),
|
||
}</pre>
|
||
|
||
<p>You can run the example one of two ways:</p>
|
||
|
||
<ul>
|
||
<li>Pipe some text to it, e.g. <code>printf foo | path/to/executable</code></li>
|
||
<li>Give it text interactively by running the executable directly,
|
||
in which case it will wait for the Enter key to be pressed before
|
||
continuing</li>
|
||
</ul>
|
||
</div></div><h2 id='implementations'>Trait Implementations</h2><h3 class='impl'><code>impl <a class='trait' href='../../../bitflags/__core/io/trait.Read.html' title='bitflags::__core::io::Read'>Read</a> for <a class='struct' href='../../../bitflags/__core/io/struct.Stdin.html' title='bitflags::__core::io::Stdin'>Stdin</a></code></h3><div class='impl-items'><h4 id='method.read' class='method'><code>fn <a href='../../../bitflags/__core/io/trait.Read.html#tymethod.read' class='fnname'>read</a>(&mut self, buf: <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.slice.html'>&mut [</a><a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.u8.html'>u8</a><a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.slice.html'>]</a>) -> <a class='enum' href='../../../bitflags/__core/result/enum.Result.html' title='bitflags::__core::result::Result'>Result</a><<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.usize.html'>usize</a>, <a class='struct' href='../../../bitflags/__core/io/struct.Error.html' title='bitflags::__core::io::Error'>Error</a>></code></h4>
|
||
<h4 id='method.read_to_end' class='method'><code>fn <a href='../../../bitflags/__core/io/trait.Read.html#method.read_to_end' class='fnname'>read_to_end</a>(&mut self, buf: &mut <a class='struct' href='../../../bitflags/__core/vec/struct.Vec.html' title='bitflags::__core::vec::Vec'>Vec</a><<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.u8.html'>u8</a>>) -> <a class='enum' href='../../../bitflags/__core/result/enum.Result.html' title='bitflags::__core::result::Result'>Result</a><<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.usize.html'>usize</a>, <a class='struct' href='../../../bitflags/__core/io/struct.Error.html' title='bitflags::__core::io::Error'>Error</a>></code></h4>
|
||
<h4 id='method.read_to_string' class='method'><code>fn <a href='../../../bitflags/__core/io/trait.Read.html#method.read_to_string' class='fnname'>read_to_string</a>(&mut self, buf: &mut <a class='struct' href='../../../bitflags/__core/string/struct.String.html' title='bitflags::__core::string::String'>String</a>) -> <a class='enum' href='../../../bitflags/__core/result/enum.Result.html' title='bitflags::__core::result::Result'>Result</a><<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.usize.html'>usize</a>, <a class='struct' href='../../../bitflags/__core/io/struct.Error.html' title='bitflags::__core::io::Error'>Error</a>></code></h4>
|
||
<h4 id='method.read_exact' class='method'><code>fn <a href='../../../bitflags/__core/io/trait.Read.html#method.read_exact' class='fnname'>read_exact</a>(&mut self, buf: <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.slice.html'>&mut [</a><a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.u8.html'>u8</a><a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.slice.html'>]</a>) -> <a class='enum' href='../../../bitflags/__core/result/enum.Result.html' title='bitflags::__core::result::Result'>Result</a><<a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.tuple.html'>()</a>, <a class='struct' href='../../../bitflags/__core/io/struct.Error.html' title='bitflags::__core::io::Error'>Error</a>></code></h4>
|
||
<h4 id='method.by_ref' class='method'><code>fn <a href='../../../bitflags/__core/io/trait.Read.html#method.by_ref' class='fnname'>by_ref</a>(&mut self) -> &mut Self</code></h4>
|
||
<h4 id='method.bytes' class='method'><code>fn <a href='../../../bitflags/__core/io/trait.Read.html#method.bytes' class='fnname'>bytes</a>(self) -> <a class='struct' href='../../../bitflags/__core/io/struct.Bytes.html' title='bitflags::__core::io::Bytes'>Bytes</a><Self></code></h4>
|
||
<h4 id='method.chars' class='method'><code>fn <a href='../../../bitflags/__core/io/trait.Read.html#method.chars' class='fnname'>chars</a>(self) -> <a class='struct' href='../../../bitflags/__core/io/struct.Chars.html' title='bitflags::__core::io::Chars'>Chars</a><Self></code></h4>
|
||
<h4 id='method.chain' class='method'><code>fn <a href='../../../bitflags/__core/io/trait.Read.html#method.chain' class='fnname'>chain</a><R>(self, next: R) -> <a class='struct' href='../../../bitflags/__core/io/struct.Chain.html' title='bitflags::__core::io::Chain'>Chain</a><Self, R> <span class='where'>where R: <a class='trait' href='../../../bitflags/__core/io/trait.Read.html' title='bitflags::__core::io::Read'>Read</a></span></code></h4>
|
||
<h4 id='method.take' class='method'><code>fn <a href='../../../bitflags/__core/io/trait.Read.html#method.take' class='fnname'>take</a>(self, limit: <a class='primitive' href='https://doc.rust-lang.org/nightly/bitflags/primitive.u64.html'>u64</a>) -> <a class='struct' href='../../../bitflags/__core/io/struct.Take.html' title='bitflags::__core::io::Take'>Take</a><Self></code></h4>
|
||
</div></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>?</dt>
|
||
<dd>Show this help dialog</dd>
|
||
<dt>S</dt>
|
||
<dd>Focus the search field</dd>
|
||
<dt>⇤</dt>
|
||
<dd>Move up in search results</dd>
|
||
<dt>⇥</dt>
|
||
<dd>Move down in search results</dd>
|
||
<dt>⏎</dt>
|
||
<dd>Go to active search result</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 = "bitflags";
|
||
window.playgroundUrl = "";
|
||
</script>
|
||
<script src="../../../jquery.js"></script>
|
||
<script src="../../../main.js"></script>
|
||
|
||
<script defer src="../../../search-index.js"></script>
|
||
</body>
|
||
</html> |