mcquery-rs/doc/tokio/io/trait.AsyncSeek.html

31 lines
22 KiB
HTML
Raw Normal View History

2021-01-08 20:01:01 +01: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 `AsyncSeek` trait in crate `tokio`."><meta name="keywords" content="rust, rustlang, rust-lang, AsyncSeek"><title>tokio::io::AsyncSeek - 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="../../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../../ayu.css" disabled ><script id="default-settings"></script><script src="../../storage.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="icon" type="image/svg+xml" href="../../favicon.svg">
<link rel="alternate icon" type="image/png" href="../../favicon-16x16.png">
<link rel="alternate icon" type="image/png" href="../../favicon-32x32.png"><style type="text/css">#crate-search{background-image:url("../../down-arrow.svg");}</style></head><body class="rustdoc trait"><!--[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><a href='../../tokio/index.html'><div class='logo-container rust-logo'><img src='../../rust-logo.png' alt='logo'></div></a><p class="location">Trait AsyncSeek</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#required-methods">Required Methods</a><div class="sidebar-links"><a href="#tymethod.poll_complete">poll_complete</a><a href="#tymethod.start_seek">start_seek</a></div><a class="sidebar-title" href="#foreign-impls">Implementations on Foreign Types</a><div class="sidebar-links"><a href="#impl-AsyncSeek-for-%26%27_%20mut%20T">&amp;&#39;_ mut T</a><a href="#impl-AsyncSeek-for-Box%3CT%3E">Box&lt;T&gt;</a><a href="#impl-AsyncSeek-for-Cursor%3CT%3E">Cursor&lt;T&gt;</a><a href="#impl-AsyncSeek-for-Pin%3CP%3E">Pin&lt;P&gt;</a></div><a class="sidebar-title" href="#implementors">Implementors</a></div><p class="location"><a href="../index.html">tokio</a>::<wbr><a href="index.html">io</a></p><script>window.sidebarCurrent = {name: "AsyncSeek", ty: "trait", relpath: ""};</script><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><script src="../../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"></div><span class="help-button">?</span>
<a id="settings-menu" href="../../settings.html"><img src="../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><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/io/async_seek.rs.html#18-47" title="goto source code">[src]</a></span><span class="in-band">Trait <a href="../index.html">tokio</a>::<wbr><a href="index.html">io</a>::<wbr><a class="trait" href="">AsyncSeek</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust trait">pub trait AsyncSeek {
fn <a href="#tymethod.start_seek" class="fnname">start_seek</a>(self: <a class="struct" href="https://doc.rust-lang.org/nightly/core/pin/struct.Pin.html" title="struct core::pin::Pin">Pin</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut </a>Self&gt;, position: <a class="enum" href="https://doc.rust-lang.org/nightly/std/io/enum.SeekFrom.html" title="enum std::io::SeekFrom">SeekFrom</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>&gt;;
<div class="item-spacer"></div> fn <a href="#tymethod.poll_complete" class="fnname">poll_complete</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;self: <a class="struct" href="https://doc.rust-lang.org/nightly/core/pin/struct.Pin.html" title="struct core::pin::Pin">Pin</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut </a>Self&gt;, <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cx: &amp;mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/task/wake/struct.Context.html" title="struct core::task::wake::Context">Context</a>&lt;'_&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/task/poll/enum.Poll.html" title="enum core::task::poll::Poll">Poll</a>&lt;<a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a>&gt;&gt;;
}</pre></div><div class="docblock"><p>Seek bytes asynchronously.</p>
<p>This trait is analogous to the <a href="https://doc.rust-lang.org/nightly/std/io/trait.Seek.html"><code>std::io::Seek</code></a> trait, but integrates
with the asynchronous task system. In particular, the <code>start_seek</code>
method, unlike <a href="https://doc.rust-lang.org/nightly/std/io/trait.Seek.html#tymethod.seek"><code>Seek::seek</code></a>, will not block the calling thread.</p>
<p>Utilities for working with <code>AsyncSeek</code> values are provided by
<a href="crate::io::AsyncSeekExt"><code>AsyncSeekExt</code></a>.</p>
</div><h2 id="required-methods" class="small-section-header">Required methods<a href="#required-methods" class="anchor"></a></h2><div class="methods"><h3 id="tymethod.start_seek" class="method"><code>fn <a href="#tymethod.start_seek" class="fnname">start_seek</a>(self: <a class="struct" href="https://doc.rust-lang.org/nightly/core/pin/struct.Pin.html" title="struct core::pin::Pin">Pin</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut </a>Self&gt;, position: <a class="enum" href="https://doc.rust-lang.org/nightly/std/io/enum.SeekFrom.html" title="enum std::io::SeekFrom">SeekFrom</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>&gt;</code></h3><div class="docblock"><p>Attempts to seek to an offset, in bytes, in a stream.</p>
<p>A seek beyond the end of a stream is allowed, but behavior is defined
by the implementation.</p>
<p>If this function returns successfully, then the job has been submitted.
To find out when it completes, call <code>poll_complete</code>.</p>
<h1 id="errors" class="section-header"><a href="#errors">Errors</a></h1>
<p>This function can return <a href="https://doc.rust-lang.org/nightly/std/io/error/enum.ErrorKind.html#variant.Other" title="io::ErrorKind::Other"><code>io::ErrorKind::Other</code></a> in case there is
another seek in progress. To avoid this, it is advisable that any call
to <code>start_seek</code> is preceded by a call to <code>poll_complete</code> to ensure all
pending seeks have completed.</p>
</div><h3 id="tymethod.poll_complete" class="method"><code>fn <a href="#tymethod.poll_complete" class="fnname">poll_complete</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;self: <a class="struct" href="https://doc.rust-lang.org/nightly/core/pin/struct.Pin.html" title="struct core::pin::Pin">Pin</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut </a>Self&gt;, <br>&nbsp;&nbsp;&nbsp;&nbsp;cx: &amp;mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/task/wake/struct.Context.html" title="struct core::task::wake::Context">Context</a>&lt;'_&gt;<br>) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/task/poll/enum.Poll.html" title="enum core::task::poll::Poll">Poll</a>&lt;<a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a>&gt;&gt;</code></h3><div class="docblock"><p>Waits for a seek operation to complete.</p>
<p>If the seek operation completed successfully,
this method returns the new position from the start of the stream.
That position can be used later with <a href="https://doc.rust-lang.org/nightly/std/io/enum.SeekFrom.html#variant.Start" title="SeekFrom::Start"><code>SeekFrom::Start</code></a>. Repeatedly
calling this function without calling <code>start_seek</code> might return the
same result.</p>
<h1 id="errors-1" class="section-header"><a href="#errors-1">Errors</a></h1>
<p>Seeking to a negative offset is considered an error.</p>
</div></div><span class="loading-content">Loading content...</span><h2 id="foreign-impls" class="small-section-header">Implementations on Foreign Types<a href="#foreign-impls" class="anchor"></a></h2><h3 id="impl-AsyncSeek-for-Box%3CT%3E" class="impl"><code class="in-band">impl&lt;T:&nbsp;?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="../../tokio/io/trait.AsyncSeek.html" title="trait tokio::io::AsyncSeek">AsyncSeek</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>&gt; <a class="trait" href="../../tokio/io/trait.AsyncSeek.html" title="trait tokio::io::AsyncSeek">AsyncSeek</a> for <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/boxed/struct.Box.html" title="struct alloc::boxed::Box">Box</a>&lt;T&gt;</code><a href="#impl-AsyncSeek-for-Box%3CT%3E" class="anchor"></a><a class="srclink" href="../../src/tokio/io/async_seek.rs.html#61-63" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.start_seek" class="method hidden"><code>fn <a href="#method.start_seek" class="fnname">start_seek</a>(self: <a class="struct" href="https://doc.rust-lang.org/nightly/core/pin/struct.Pin.html" title="struct core::pin::Pin">Pin</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut </a>Self&gt;, pos: <a class="enum" href="https://doc.rust-lang.org/nightly/std/io/enum.SeekFrom.html" title="enum std::io::SeekFrom">SeekFrom</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>&gt;</code><a class="srclink" href="../../src/tokio/io/async_seek.rs.html#62" title="goto source code">[src]</a></h4><h4 id="method.poll_complete" class="method hidden"><code>fn <a href="#method.poll_complete" class="fnname">poll_complete</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;self: <a class="struct" href="https://doc.rust-lang.org/nightly/core/pin/struct.Pin.html" title="struct core::pin::Pin">Pin</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut </a>Self&gt;, <br>&nbsp;&nbsp;&nbsp;&nbsp;cx: &amp;mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/task/wake/struct.Context.html" title="struct core::task::wake::Context">Context</a>&lt;'_&gt;<br>) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/task/poll/enum.Poll.html" title="enum core::task::poll::Poll">Poll</a>&lt;<a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a>&gt;&gt;</code><a class="srclink" href="../../src/tokio/io/async_seek.rs.html#62" title="goto source code">[src]</a></h4></div><h3 id="impl-AsyncSeek-for-%26%27_%20mut%20T" class="impl"><code class="in-band">impl&lt;T:&nbsp;?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="../../tokio/io/trait.AsyncSeek.html" title="trait tokio::io::AsyncSeek">AsyncSeek</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>, '_&gt; <a class="trait" href="../../tokio/io/trait.AsyncSeek.html" title="trait tokio::io::AsyncSeek">AsyncSeek</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;'_ mut </a>T</code><a href="#impl-AsyncSeek-for-%26%27_%20mut%20T" class="anchor"></a><a class="srclink" href="../../src/tokio/io/async_seek.rs.html#65-67" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.start_seek-1" class="method hidden"><code>fn <a href="#method.start_seek" class="fnname">start_seek</a>(se