190 lines
18 KiB
HTML
190 lines
18 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 `Window` struct in crate `tokio_io`.">
|
|||
|
<meta name="keywords" content="rust, rustlang, rust-lang, Window">
|
|||
|
|
|||
|
<title>tokio_io::io::Window - 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="../../main.css" id="themeStyle">
|
|||
|
<script src="../../storage.js"></script>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
</head>
|
|||
|
<body class="rustdoc struct">
|
|||
|
<!--[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">☰</div>
|
|||
|
|
|||
|
<p class='location'>Struct Window</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#methods">Methods</a><div class="sidebar-links"><a href="#method.new">new</a><a href="#method.get_ref">get_ref</a><a href="#method.get_mut">get_mut</a><a href="#method.into_inner">into_inner</a><a href="#method.start">start</a><a href="#method.end">end</a><a href="#method.set_start">set_start</a><a href="#method.set_end">set_end</a></div><a class="sidebar-title" href="#implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-Debug">Debug</a><a href="#impl-AsRef%3C%5Bu8%5D%3E">AsRef<[u8]></a><a href="#impl-AsMut%3C%5Bu8%5D%3E">AsMut<[u8]></a></div></div><p class='location'><a href='../index.html'>tokio_io</a>::<wbr><a href='index.html'>io</a></p><script>window.sidebarCurrent = {name: 'Window', ty: 'struct', 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'>Struct <a href='../index.html'>tokio_io</a>::<wbr><a href='index.html'>io</a>::<wbr><a class="struct" href=''>Window</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 class='srclink' href='../../src/tokio_io/window.rs.html#21-24' title='goto source code'>[src]</a></span></h1>
|
|||
|
<pre class='rust struct'>pub struct Window<T> { /* fields omitted */ }</pre><div class='docblock'><p>A owned window around an underlying buffer.</p>
|
|||
|
<p>Normally slices work great for considering sub-portions of a buffer, but
|
|||
|
unfortunately a slice is a <em>borrowed</em> type in Rust which has an associated
|
|||
|
lifetime. When working with future and async I/O these lifetimes are not
|
|||
|
always appropriate, and are sometimes difficult to store in tasks. This
|
|||
|
type strives to fill this gap by providing an "owned slice" around an
|
|||
|
underlying buffer of bytes.</p>
|
|||
|
<p>A <code>Window<T></code> wraps an underlying buffer, <code>T</code>, and has configurable
|
|||
|
start/end indexes to alter the behavior of the <code>AsRef<[u8]></code> implementation
|
|||
|
that this type carries.</p>
|
|||
|
<p>This type can be particularly useful when working with the <code>write_all</code>
|
|||
|
combinator in this crate. Data can be sliced via <code>Window</code>, consumed by
|
|||
|
<code>write_all</code>, and then earned back once the write operation finishes through
|
|||
|
the <code>into_inner</code> method on this type.</p>
|
|||
|
</div>
|
|||
|
<h2 id='methods' class='small-section-header'>
|
|||
|
Methods<a href='#methods' class='anchor'></a>
|
|||
|
</h2>
|
|||
|
<h3 id='impl' class='impl'><span class='in-band'><code>impl<T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>>> <a class="struct" href="../../tokio_io/io/struct.Window.html" title="struct tokio_io::io::Window">Window</a><T></code><a href='#impl' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/tokio_io/window.rs.html#26-105' title='goto source code'>[src]</a></span></h3>
|
|||
|
<div class='impl-items'><h4 id='method.new' class="method"><span id='new.v' class='invisible'><code>pub fn <a href='#method.new' class='fnname'>new</a>(t: T) -> <a class="struct" href="../../tokio_io/io/struct.Window.html" title="struct tokio_io::io::Window">Window</a><T></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/tokio_io/window.rs.html#32-37' title='goto source code'>[src]</a></span></h4>
|
|||
|
<div class='docblock'><p>Creates a new window around the buffer <code>t</code> defaulting to the entire
|
|||
|
slice.</p>
|
|||
|
<p>Further methods can be called on the returned <code>Window<T></code> to alter the
|
|||
|
window into the data provided.</p>
|
|||
|
</div><h4 id='method.get_ref' class="method"><span id='get_ref.v' class='invisible'><code>pub fn <a href='#method.get_ref' class='fnname'>get_ref</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>T</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/tokio_io/window.rs.html#41-43' title='goto source code'>[src]</a></span></h4>
|
|||
|
<div class='docblock'><p>Gets a shared reference to the underlying buffer inside of this
|
|||
|
<code>Window</code>.</p>
|
|||
|
</div><h4 id='method.get_mut' class="method"><span id='get_mut.v' class='invisible'><code>pub fn <a href='#method.get_mut' class='fnname'>get_mut</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>T</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/tokio_io/window.rs.html#47-49' title='goto source code'>[src]</a></span></h4>
|
|||
|
<div class='docblock'><p>Gets a mutable reference to the underlying buffer inside of this
|
|||
|
<code>Window</code>.</p>
|
|||
|
</div><h4 id='method.into_inner' class="method"><span id='into_inner.v' class='invisible'><code>pub fn <a href='#method.into_inner' class='fnname'>into_inner</a>(self) -> T</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/tokio_io/window.rs.html#52-54' title='goto source code'>[src]</a></span></h4>
|
|||
|
<div class='docblock'><p>Consumes this <code>Window</code>, returning the underlying buffer.</p>
|
|||
|
</div><h4 id='method.start' class="method"><span id='start.v' class='invisible'><code>pub fn <a href='#method.start' class='fnname'>start</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/tokio_io/window.rs.html#58-60' title='goto source code'>[src]</a></span></h4>
|
|||
|
<div class='docblock'><p>Returns the starting index of this window into the underlying buffer
|
|||
|
<code>T</code>.</p>
|
|||
|
</div><h4 id='method.end' class="method"><span id='end.v' class='invisible'><code>pub fn <a href='#method.end' class='fnname'>end</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/tokio_io/window.rs.html#64-66' title='goto source code'>[src]</a></span></h4>
|
|||
|
<div class='docblock'><p>Returns the end index of this window into the underlying buffer
|
|||
|
<code>T</code>.</p>
|
|||
|
</div><h4 id='method.set_start' class="method"><span id='set_start.v' class='invisible'><code>pub fn <a href='#method.set_start' class='fnname'>set_start</a>(&mut self, start: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -> &mut <a class="struct" href="../../tokio_io/io/struct.Window.html" title="struct tokio_io::io::Window">Window</a><T></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/tokio_io/window.rs.html#76-81' title='goto source code'>[src]</a></span></h4>
|
|||
|
<div class='docblock'><p>Changes the starting index of this window to the index specified.</p>
|
|||
|
<p>Returns the windows back to chain multiple calls to this method.</p>
|
|||
|
<h1 id="panics" class="section-header"><a href="#panics">Panics</a></h1>
|
|||
|
<p>This method will panic if <code>start</code> is out of bounds for the underlying
|
|||
|
slice or if it comes after the <code>end</code> configured in this window.</p>
|
|||
|
</div><h4 id='method.set_end' class="method"><span id='set_end.v' class='invisible'><code>pub fn <a href='#method.set_end' class='fnname'>set_end</a>(&mut self, end: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -> &mut <a class="struct" href="../../tokio_io/io/struct.Window.html" title="struct tokio_io::io::Window">Window</a><T></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/tokio_io/window.rs.html#91-96' title='goto source code'>[src]</a></span></h4>
|
|||
|
<div class='docblock'><p>Changes the end index of this window to the index specified.</p>
|
|||
|
<p>Returns the windows back to chain multiple calls to this method.</p>
|
|||
|
<h1 id="panics-1" class="section-header"><a href="#panics-1">Panics</a></h1>
|
|||
|
<p>This method will panic if <code>end</code> is out of bounds for the underlying
|
|||
|
slice or if it comes before the <code>start</code> configured in this window.</p>
|
|||
|
</div></div>
|
|||
|
<h2 id='implementations' class='small-section-header'>
|
|||
|
Trait Implementations<a href='#implementations' class='anchor'></a>
|
|||
|
</h2>
|
|||
|
<h3 id='impl-Debug' class='impl'><span class='in-band'><code>impl<T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a>> <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="../../tokio_io/io/struct.Window.html" title="struct tokio_io::io::Window">Window</a><T></code><a href='#impl-Debug' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/tokio_io/window.rs.html#20' title='goto source code'>[src]</a></span></h3>
|
|||
|
<div class='impl-items'><h4 id='method.fmt' class="method"><span id='fmt.v' class='invisible'><code>fn <a href='https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt' class='fnname'>fmt</a>(&self, __arg_0: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/tokio_io/window.rs.html#20' title='goto source code'>[src]</a></span></h4>
|
|||
|
<div class='docblock'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></p>
|
|||
|
</div></div><h3 id='impl-AsRef%3C%5Bu8%5D%3E' class='impl'><span class='in-band'><code>impl<T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>>> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>> for <a class="struct" href="../../tokio_io/io/struct.Window.html" title="struct tokio_io::io::Window">Window</a><T></code><a href='#impl-AsRef%3C%5Bu8%5D%3E' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/tokio_io/window.rs.html#107-111' title='goto source code'>[src]</a></span></h3>
|
|||
|
<div class='impl-items'><h4 id='method.as_ref' class="method"><span id='as_ref.v' class='invisible'><code>fn <a href='https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html#tymethod.as_ref' class='fnname'>as_ref</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/tokio_io/window.rs.html#108-110' title='goto source code'>[src]</a></span></h4>
|
|||
|
<div class='docblock'><p>Performs the conversion.</p>
|
|||
|
</div></div><h3 id='impl-AsMut%3C%5Bu8%5D%3E' class='impl'><span class='in-band'><code>impl<T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsMut.html" title="trait core::convert::AsMut">AsMut</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>>> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsMut.html" title="trait core::convert::AsMut">AsMut</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>> for <a class="struct" href="../../tokio_io/io/struct.Window.html" title="struct tokio_io::io::Window">Window</a><T></code><a href='#impl-AsMut%3C%5Bu8%5D%3E' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/tokio_io/window.rs.html#113-117' title='goto source code'>[src]</a></span></h3>
|
|||
|
<div class='impl-items'><h4 id='method.as_mut' class="method"><span id='as_mut.v' class='invisible'><code>fn <a href='https://doc.rust-lang.org/nightly/core/convert/trait.AsMut.html#tymethod.as_mut' class='fnname'>as_mut</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/tokio_io/window.rs.html#114-116' title='goto source code'>[src]</a></span></h4>
|
|||
|
<div class='docblock'><p>Performs the conversion.</p>
|
|||
|
</div></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><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>⏎</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_io";
|
|||
|
</script>
|
|||
|
<script src="../../main.js"></script>
|
|||
|
<script defer src="../../search-index.js"></script>
|
|||
|
</body>
|
|||
|
</html>
|