Files
rapr-rs/docs/tokio/fs/struct.File.html
T
2021-03-26 19:20:48 +00:00

204 lines
63 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!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 `File` struct in crate `tokio`."><meta name="keywords" content="rust, rustlang, rust-lang, File"><title>tokio::fs::File - 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 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">&#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">Struct File</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#implementations">Methods</a><div class="sidebar-links"><a href="#method.create">create</a><a href="#method.from_std">from_std</a><a href="#method.into_std">into_std</a><a href="#method.metadata">metadata</a><a href="#method.open">open</a><a href="#method.set_len">set_len</a><a href="#method.set_permissions">set_permissions</a><a href="#method.sync_all">sync_all</a><a href="#method.sync_data">sync_data</a><a href="#method.try_clone">try_clone</a><a href="#method.try_into_std">try_into_std</a></div><a class="sidebar-title" href="#trait-implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-AsRawFd">AsRawFd</a><a href="#impl-AsyncRead">AsyncRead</a><a href="#impl-AsyncSeek">AsyncSeek</a><a href="#impl-AsyncWrite">AsyncWrite</a><a href="#impl-Debug">Debug</a><a href="#impl-From%3CFile%3E">From&lt;File&gt;</a><a href="#impl-FromRawFd">FromRawFd</a></div><a class="sidebar-title" href="#synthetic-implementations">Auto Trait Implementations</a><div class="sidebar-links"><a href="#impl-RefUnwindSafe">!RefUnwindSafe</a><a href="#impl-Send">Send</a><a href="#impl-Sync">Sync</a><a href="#impl-Unpin">Unpin</a><a href="#impl-UnwindSafe">!UnwindSafe</a></div><a class="sidebar-title" href="#blanket-implementations">Blanket Implementations</a><div class="sidebar-links"><a href="#impl-Any">Any</a><a href="#impl-Borrow%3CT%3E">Borrow&lt;T&gt;</a><a href="#impl-BorrowMut%3CT%3E">BorrowMut&lt;T&gt;</a><a href="#impl-From%3CT%3E">From&lt;T&gt;</a><a href="#impl-Into%3CU%3E">Into&lt;U&gt;</a><a href="#impl-TryFrom%3CU%3E">TryFrom&lt;U&gt;</a><a href="#impl-TryInto%3CU%3E">TryInto&lt;U&gt;</a></div></div><p class="location"><a href="../index.html">tokio</a>::<wbr><a href="index.html">fs</a></p><div id="sidebar-vars" data-name="File" data-ty="struct" data-relpath=""></div><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><button type="button" class="help-button">?</button>
<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="in-band">Struct <a href="../index.html">tokio</a>::<wbr><a href="index.html">fs</a>::<wbr><a class="struct" href="">File</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/fs/file.rs.html#80-83" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust struct">pub struct File { /* fields omitted */ }</pre></div><div class="docblock"><p>A reference to an open file on the filesystem.</p>
<p>This is a specialized version of <a href="https://doc.rust-lang.org/nightly/std/fs/struct.File.html"><code>std::fs::File</code></a> for usage from the
Tokio runtime.</p>
<p>An instance of a <code>File</code> can be read and/or written depending on what options
it was opened with. Files also implement <a href="../../tokio/io/trait.AsyncSeek.html"><code>AsyncSeek</code></a> to alter the logical
cursor that the file contains internally.</p>
<p>A file will not be closed immediately when it goes out of scope if there
are any IO operations that have not yet completed. To ensure that a file is
closed immediately when it is dropped, you should call <a href="../../tokio/io/trait.AsyncWriteExt.html#method.flush"><code>flush</code></a> before
dropping it. Note that this does not ensure that the file has been fully
written to disk; the operating system might keep the changes around in an
in-memory buffer. See the <a href="../../tokio/fs/struct.File.html#method.sync_all"><code>sync_all</code></a> method for telling the OS to write
the data to disk.</p>
<p>Reading and writing to a <code>File</code> is usually done using the convenience
methods found on the <a href="../../tokio/io/trait.AsyncReadExt.html"><code>AsyncReadExt</code></a> and <a href="../../tokio/io/trait.AsyncWriteExt.html"><code>AsyncWriteExt</code></a> traits.</p>
<h1 id="examples" class="section-header"><a href="#examples">Examples</a></h1>
<p>Create a new file and asynchronously write bytes to it:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">fs</span>::<span class="ident">File</span>;
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">io</span>::<span class="ident">AsyncWriteExt</span>; <span class="comment">// for write_all()</span>
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">file</span> <span class="op">=</span> <span class="ident">File</span>::<span class="ident">create</span>(<span class="string">&quot;foo.txt&quot;</span>).<span class="kw">await</span><span class="question-mark">?</span>;
<span class="ident">file</span>.<span class="ident">write_all</span>(<span class="string">b&quot;hello, world!&quot;</span>).<span class="kw">await</span><span class="question-mark">?</span>;</pre></div>
<p>Read the contents of a file into a buffer</p>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">fs</span>::<span class="ident">File</span>;
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">io</span>::<span class="ident">AsyncReadExt</span>; <span class="comment">// for read_to_end()</span>
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">file</span> <span class="op">=</span> <span class="ident">File</span>::<span class="ident">open</span>(<span class="string">&quot;foo.txt&quot;</span>).<span class="kw">await</span><span class="question-mark">?</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">contents</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[];
<span class="ident">file</span>.<span class="ident">read_to_end</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">contents</span>).<span class="kw">await</span><span class="question-mark">?</span>;
<span class="macro">println</span><span class="macro">!</span>(<span class="string">&quot;len = {}&quot;</span>, <span class="ident">contents</span>.<span class="ident">len</span>());</pre></div>
</div><h2 id="implementations" class="small-section-header">Implementations<a href="#implementations" class="anchor"></a></h2><h3 id="impl" class="impl"><code class="in-band">impl <a class="struct" href="../../tokio/fs/struct.File.html" title="struct tokio::fs::File">File</a></code><a href="#impl" class="anchor"></a><a class="srclink" href="../../src/tokio/fs/file.rs.html#109-480" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.open" class="method"><code>pub async fn <a href="#method.open" class="fnname">open</a>(path: impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a>&lt;<a class="struct" href="https://doc.rust-lang.org/nightly/std/path/struct.Path.html" title="struct std::path::Path">Path</a>&gt;) -&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="struct" href="../../tokio/fs/struct.File.html" title="struct tokio::fs::File">File</a>&gt;</code><a class="srclink" href="../../src/tokio/fs/file.rs.html#143-148" title="goto source code">[src]</a></h4><div class="docblock"><p>Attempts to open a file in read-only mode.</p>
<p>See <a href="../../tokio/fs/struct.OpenOptions.html"><code>OpenOptions</code></a> for more details.</p>
<h1 id="errors" class="section-header"><a href="#errors">Errors</a></h1>
<p>This function will return an error if called from outside of the Tokio
runtime or if path does not already exist. Other errors may also be
returned according to OpenOptions::open.</p>
<h1 id="examples-1" class="section-header"><a href="#examples-1">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">fs</span>::<span class="ident">File</span>;
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">io</span>::<span class="ident">AsyncReadExt</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">file</span> <span class="op">=</span> <span class="ident">File</span>::<span class="ident">open</span>(<span class="string">&quot;foo.txt&quot;</span>).<span class="kw">await</span><span class="question-mark">?</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">contents</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[];
<span class="ident">file</span>.<span class="ident">read_to_end</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">contents</span>).<span class="kw">await</span><span class="question-mark">?</span>;
<span class="macro">println</span><span class="macro">!</span>(<span class="string">&quot;len = {}&quot;</span>, <span class="ident">contents</span>.<span class="ident">len</span>());</pre></div>
<p>The <a href="../../tokio/io/trait.AsyncReadExt.html#method.read_to_end"><code>read_to_end</code></a> method is defined on the <a href="../../tokio/io/trait.AsyncReadExt.html"><code>AsyncReadExt</code></a> trait.</p>
</div><h4 id="method.create" class="method"><code>pub async fn <a href="#method.create" class="fnname">create</a>(path: impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a>&lt;<a class="struct" href="https://doc.rust-lang.org/nightly/std/path/struct.Path.html" title="struct std::path::Path">Path</a>&gt;) -&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="struct" href="../../tokio/fs/struct.File.html" title="struct tokio::fs::File">File</a>&gt;</code><a class="srclink" href="../../src/tokio/fs/file.rs.html#183-187" title="goto source code">[src]</a></h4><div class="docblock"><p>Opens a file in write-only mode.</p>
<p>This function will create a file if it does not exist, and will truncate
it if it does.</p>
<p>See <a href="../../tokio/fs/struct.OpenOptions.html"><code>OpenOptions</code></a> for more details.</p>
<h1 id="errors-1" class="section-header"><a href="#errors-1">Errors</a></h1>
<p>Results in an error if called from outside of the Tokio runtime or if
the underlying <a href="https://doc.rust-lang.org/nightly/std/fs/struct.File.html#method.create"><code>create</code></a> call results in an error.</p>
<h1 id="examples-2" class="section-header"><a href="#examples-2">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">fs</span>::<span class="ident">File</span>;
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">io</span>::<span class="ident">AsyncWriteExt</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">file</span> <span class="op">=</span> <span class="ident">File</span>::<span class="ident">create</span>(<span class="string">&quot;foo.txt&quot;</span>).<span class="kw">await</span><span class="question-mark">?</span>;
<span class="ident">file</span>.<span class="ident">write_all</span>(<span class="string">b&quot;hello, world!&quot;</span>).<span class="kw">await</span><span class="question-mark">?</span>;</pre></div>
<p>The <a href="../../tokio/io/trait.AsyncWriteExt.html#method.write_all"><code>write_all</code></a> method is defined on the <a href="../../tokio/io/trait.AsyncWriteExt.html"><code>AsyncWriteExt</code></a> trait.</p>
</div><h4 id="method.from_std" class="method"><code>pub fn <a href="#method.from_std" class="fnname">from_std</a>(std: <a class="struct" href="https://doc.rust-lang.org/nightly/std/fs/struct.File.html" title="struct std::fs::File">File</a>) -&gt; <a class="struct" href="../../tokio/fs/struct.File.html" title="struct tokio::fs::File">File</a></code><a class="srclink" href="../../src/tokio/fs/file.rs.html#202-211" title="goto source code">[src]</a></h4><div class="docblock"><p>Converts a <a href="https://doc.rust-lang.org/nightly/std/fs/struct.File.html"><code>std::fs::File</code></a> to a <a href="../../tokio/fs/struct.File.html"><code>tokio::fs::File</code></a>.</p>
<h1 id="examples-3" class="section-header"><a href="#examples-3">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="comment">// This line could block. It is not recommended to do this on the Tokio</span>
<span class="comment">// runtime.</span>
<span class="kw">let</span> <span class="ident">std_file</span> <span class="op">=</span> <span class="ident">std</span>::<span class="ident">fs</span>::<span class="ident">File</span>::<span class="ident">open</span>(<span class="string">&quot;foo.txt&quot;</span>).<span class="ident">unwrap</span>();
<span class="kw">let</span> <span class="ident">file</span> <span class="op">=</span> <span class="ident">tokio</span>::<span class="ident">fs</span>::<span class="ident">File</span>::<span class="ident">from_std</span>(<span class="ident">std_file</span>);</pre></div>
</div><h4 id="method.sync_all" class="method"><code>pub async fn <a href="#method.sync_all" class="fnname">sync_all</a>(&amp;self) -&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/fs/file.rs.html#236-242" title="goto source code">[src]</a></h4><div class="docblock"><p>Attempts to sync all OS-internal metadata to disk.</p>
<p>This function will attempt to ensure that all in-core data reaches the
filesystem before returning.</p>
<h1 id="examples-4" class="section-header"><a href="#examples-4">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">fs</span>::<span class="ident">File</span>;
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">io</span>::<span class="ident">AsyncWriteExt</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">file</span> <span class="op">=</span> <span class="ident">File</span>::<span class="ident">create</span>(<span class="string">&quot;foo.txt&quot;</span>).<span class="kw">await</span><span class="question-mark">?</span>;
<span class="ident">file</span>.<span class="ident">write_all</span>(<span class="string">b&quot;hello, world!&quot;</span>).<span class="kw">await</span><span class="question-mark">?</span>;
<span class="ident">file</span>.<span class="ident">sync_all</span>().<span class="kw">await</span><span class="question-mark">?</span>;</pre></div>
<p>The <a href="../../tokio/io/trait.AsyncWriteExt.html#method.write_all"><code>write_all</code></a> method is defined on the <a href="../../tokio/io/trait.AsyncWriteExt.html"><code>AsyncWriteExt</code></a> trait.</p>
</div><h4 id="method.sync_data" class="method"><code>pub async fn <a href="#method.sync_data" class="fnname">sync_data</a>(&amp;self) -&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/fs/file.rs.html#271-277" title="goto source code">[src]</a></h4><div class="docblock"><p>This function is similar to <code>sync_all</code>, except that it may not
synchronize file metadata to the filesystem.</p>
<p>This is intended for use cases that must synchronize content, but don't
need the metadata on disk. The goal of this method is to reduce disk
operations.</p>
<p>Note that some platforms may simply implement this in terms of <code>sync_all</code>.</p>
<h1 id="examples-5" class="section-header"><a href="#examples-5">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">fs</span>::<span class="ident">File</span>;
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">io</span>::<span class="ident">AsyncWriteExt</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">file</span> <span class="op">=</span> <span class="ident">File</span>::<span class="ident">create</span>(<span class="string">&quot;foo.txt&quot;</span>).<span class="kw">await</span><span class="question-mark">?</span>;
<span class="ident">file</span>.<span class="ident">write_all</span>(<span class="string">b&quot;hello, world!&quot;</span>).<span class="kw">await</span><span class="question-mark">?</span>;
<span class="ident">file</span>.<span class="ident">sync_data</span>().<span class="kw">await</span><span class="question-mark">?</span>;</pre></div>
<p>The <a href="../../tokio/io/trait.AsyncWriteExt.html#method.write_all"><code>write_all</code></a> method is defined on the <a href="../../tokio/io/trait.AsyncWriteExt.html"><code>AsyncWriteExt</code></a> trait.</p>
</div><h4 id="method.set_len" class="method"><code>pub async fn <a href="#method.set_len" class="fnname">set_len</a>(&amp;self, size: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</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/fs/file.rs.html#309-351" title="goto source code">[src]</a></h4><div class="docblock"><p>Truncates or extends the underlying file, updating the size of this file to become size.</p>
<p>If the size is less than the current file's size, then the file will be
shrunk. If it is greater than the current file's size, then the file
will be extended to size and have all of the intermediate data filled in
with 0s.</p>
<h1 id="errors-2" class="section-header"><a href="#errors-2">Errors</a></h1>
<p>This function will return an error if the file is not opened for
writing.</p>
<h1 id="examples-6" class="section-header"><a href="#examples-6">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">fs</span>::<span class="ident">File</span>;
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">io</span>::<span class="ident">AsyncWriteExt</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">file</span> <span class="op">=</span> <span class="ident">File</span>::<span class="ident">create</span>(<span class="string">&quot;foo.txt&quot;</span>).<span class="kw">await</span><span class="question-mark">?</span>;
<span class="ident">file</span>.<span class="ident">write_all</span>(<span class="string">b&quot;hello, world!&quot;</span>).<span class="kw">await</span><span class="question-mark">?</span>;
<span class="ident">file</span>.<span class="ident">set_len</span>(<span class="number">10</span>).<span class="kw">await</span><span class="question-mark">?</span>;</pre></div>
<p>The <a href="../../tokio/io/trait.AsyncWriteExt.html#method.write_all"><code>write_all</code></a> method is defined on the <a href="../../tokio/io/trait.AsyncWriteExt.html"><code>AsyncWriteExt</code></a> trait.</p>
</div><h4 id="method.metadata" class="method"><code>pub async fn <a href="#method.metadata" class="fnname">metadata</a>(&amp;self) -&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="struct" href="https://doc.rust-lang.org/nightly/std/fs/struct.Metadata.html" title="struct std::fs::Metadata">Metadata</a>&gt;</code><a class="srclink" href="../../src/tokio/fs/file.rs.html#368-371" title="goto source code">[src]</a></h4><div class="docblock"><p>Queries metadata about the underlying file.</p>
<h1 id="examples-7" class="section-header"><a href="#examples-7">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">fs</span>::<span class="ident">File</span>;
<span class="kw">let</span> <span class="ident">file</span> <span class="op">=</span> <span class="ident">File</span>::<span class="ident">open</span>(<span class="string">&quot;foo.txt&quot;</span>).<span class="kw">await</span><span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">metadata</span> <span class="op">=</span> <span class="ident">file</span>.<span class="ident">metadata</span>().<span class="kw">await</span><span class="question-mark">?</span>;
<span class="macro">println</span><span class="macro">!</span>(<span class="string">&quot;{:?}&quot;</span>, <span class="ident">metadata</span>);</pre></div>
</div><h4 id="method.try_clone" class="method"><code>pub async fn <a href="#method.try_clone" class="fnname">try_clone</a>(&amp;self) -&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="struct" href="../../tokio/fs/struct.File.html" title="struct tokio::fs::File">File</a>&gt;</code><a class="srclink" href="../../src/tokio/fs/file.rs.html#388-392" title="goto source code">[src]</a></h4><div class="docblock"><p>Create a new <code>File</code> instance that shares the same underlying file handle
as the existing <code>File</code> instance. Reads, writes, and seeks will affect both
File instances simultaneously.</p>
<h1 id="examples-8" class="section-header"><a href="#examples-8">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">fs</span>::<span class="ident">File</span>;
<span class="kw">let</span> <span class="ident">file</span> <span class="op">=</span> <span class="ident">File</span>::<span class="ident">open</span>(<span class="string">&quot;foo.txt&quot;</span>).<span class="kw">await</span><span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">file_clone</span> <span class="op">=</span> <span class="ident">file</span>.<span class="ident">try_clone</span>().<span class="kw">await</span><span class="question-mark">?</span>;</pre></div>
</div><h4 id="method.into_std" class="method"><code>pub async fn <a href="#method.into_std" class="fnname">into_std</a>(self) -&gt; <a class="struct" href="https://doc.rust-lang.org/nightly/std/fs/struct.File.html" title="struct std::fs::File">File</a></code><a class="srclink" href="../../src/tokio/fs/file.rs.html#412-415" title="goto source code">[src]</a></h4><div class="docblock"><p>Destructures <code>File</code> into a <a href="https://doc.rust-lang.org/nightly/std/fs/struct.File.html"><code>std::fs::File</code></a>. This function is
async to allow any in-flight operations to complete.</p>
<p>Use <code>File::try_into_std</code> to attempt conversion immediately.</p>
<h1 id="examples-9" class="section-header"><a href="#examples-9">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">fs</span>::<span class="ident">File</span>;
<span class="kw">let</span> <span class="ident">tokio_file</span> <span class="op">=</span> <span class="ident">File</span>::<span class="ident">open</span>(<span class="string">&quot;foo.txt&quot;</span>).<span class="kw">await</span><span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">std_file</span> <span class="op">=</span> <span class="ident">tokio_file</span>.<span class="ident">into_std</span>().<span class="kw">await</span>;</pre></div>
</div><h4 id="method.try_into_std" class="method"><code>pub fn <a href="#method.try_into_std" class="fnname">try_into_std</a>(self) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="struct" href="https://doc.rust-lang.org/nightly/std/fs/struct.File.html" title="struct std::fs::File">File</a>, Self&gt;</code><a class="srclink" href="../../src/tokio/fs/file.rs.html#437-445" title="goto source code">[src]</a></h4><div class="docblock"><p>Tries to immediately destructure <code>File</code> into a <a href="https://doc.rust-lang.org/nightly/std/fs/struct.File.html"><code>std::fs::File</code></a>.</p>
<h1 id="errors-3" class="section-header"><a href="#errors-3">Errors</a></h1>
<p>This function will return an error containing the file if some
operation is in-flight.</p>
<h1 id="examples-10" class="section-header"><a href="#examples-10">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">fs</span>::<span class="ident">File</span>;
<span class="kw">let</span> <span class="ident">tokio_file</span> <span class="op">=</span> <span class="ident">File</span>::<span class="ident">open</span>(<span class="string">&quot;foo.txt&quot;</span>).<span class="kw">await</span><span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">std_file</span> <span class="op">=</span> <span class="ident">tokio_file</span>.<span class="ident">try_into_std</span>().<span class="ident">unwrap</span>();</pre></div>
</div><h4 id="method.set_permissions" class="method"><code>pub async fn <a href="#method.set_permissions" class="fnname">set_permissions</a>(&amp;self, perm: <a class="struct" href="https://doc.rust-lang.org/nightly/std/fs/struct.Permissions.html" title="struct std::fs::Permissions">Permissions</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/fs/file.rs.html#476-479" title="goto source code">[src]</a></h4><div class="docblock"><p>Changes the permissions on the underlying file.</p>
<h1 id="platform-specific-behavior" class="section-header"><a href="#platform-specific-behavior">Platform-specific behavior</a></h1>
<p>This function currently corresponds to the <code>fchmod</code> function on Unix and
the <code>SetFileInformationByHandle</code> function on Windows. Note that, this
<a href="https://doc.rust-lang.org/std/io/index.html#platform-specific-behavior">may change in the future</a>.</p>
<h1 id="errors-4" class="section-header"><a href="#errors-4">Errors</a></h1>
<p>This function will return an error if the user lacks permission change
attributes on the underlying file. It may also return an error in other
os-specific unspecified cases.</p>
<h1 id="examples-11" class="section-header"><a href="#examples-11">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">fs</span>::<span class="ident">File</span>;
<span class="kw">let</span> <span class="ident">file</span> <span class="op">=</span> <span class="ident">File</span>::<span class="ident">open</span>(<span class="string">&quot;foo.txt&quot;</span>).<span class="kw">await</span><span class="question-mark">?</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">perms</span> <span class="op">=</span> <span class="ident">file</span>.<span class="ident">metadata</span>().<span class="kw">await</span><span class="question-mark">?</span>.<span class="ident">permissions</span>();
<span class="ident">perms</span>.<span class="ident">set_readonly</span>(<span class="bool-val">true</span>);
<span class="ident">file</span>.<span class="ident">set_permissions</span>(<span class="ident">perms</span>).<span class="kw">await</span><span class="question-mark">?</span>;</pre></div>
</div></div><h2 id="trait-implementations" class="small-section-header">Trait Implementations<a href="#trait-implementations" class="anchor"></a></h2><div id="trait-implementations-list"><h3 id="impl-AsRawFd" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/std/sys/unix/ext/io/trait.AsRawFd.html" title="trait std::sys::unix::ext::io::AsRawFd">AsRawFd</a> for <a class="struct" href="../../tokio/fs/struct.File.html" title="struct tokio::fs::File">File</a></code><a href="#impl-AsRawFd" class="anchor"></a><a class="srclink" href="../../src/tokio/fs/file.rs.html#703-707" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.as_raw_fd" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/std/sys/unix/ext/io/trait.AsRawFd.html#tymethod.as_raw_fd" class="fnname">as_raw_fd</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/sys/unix/ext/io/type.RawFd.html" title="type std::sys::unix::ext::io::RawFd">RawFd</a></code><a class="srclink" href="../../src/tokio/fs/file.rs.html#704-706" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Extracts the raw file descriptor. <a href="https://doc.rust-lang.org/nightly/std/sys/unix/ext/io/trait.AsRawFd.html#tymethod.as_raw_fd">Read more</a></p>
</div></div><h3 id="impl-AsyncRead" class="impl"><code class="in-band">impl <a class="trait" href="../../tokio/io/trait.AsyncRead.html" title="trait tokio::io::AsyncRead">AsyncRead</a> for <a class="struct" href="../../tokio/fs/struct.File.html" title="struct tokio::fs::File">File</a></code><a href="#impl-AsyncRead" class="anchor"></a><a class="srclink" href="../../src/tokio/fs/file.rs.html#482-548" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.poll_read" class="method hidden"><code>fn <a href="../../tokio/io/trait.AsyncRead.html#tymethod.poll_read" class="fnname">poll_read</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>&nbsp;&nbsp;&nbsp;&nbsp;dst: &amp;mut <a class="struct" href="../../tokio/io/struct.ReadBuf.html" title="struct tokio::io::ReadBuf">ReadBuf</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.unit.html">()</a>&gt;&gt;</code><a class="srclink" href="../../src/tokio/fs/file.rs.html#483-547" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Attempts to read from the <code>AsyncRead</code> into <code>buf</code>. <a href="../../tokio/io/trait.AsyncRead.html#tymethod.poll_read">Read more</a></p>
</div></div><h3 id="impl-AsyncSeek" class="impl"><code class="in-band">impl <a class="trait" href="../../tokio/io/trait.AsyncSeek.html" title="trait tokio::io::AsyncSeek">AsyncSeek</a> for <a class="struct" href="../../tokio/fs/struct.File.html" title="struct tokio::fs::File">File</a></code><a href="#impl-AsyncSeek" class="anchor"></a><a class="srclink" href="../../src/tokio/fs/file.rs.html#550-610" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.start_seek" class="method hidden"><code>fn <a href="../../tokio/io/trait.AsyncSeek.html#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;, 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/fs/file.rs.html#551-580" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Attempts to seek to an offset, in bytes, in a stream. <a href="../../tokio/io/trait.AsyncSeek.html#tymethod.start_seek">Read more</a></p>
</div><h4 id="method.poll_complete" class="method hidden"><code>fn <a href="../../tokio/io/trait.AsyncSeek.html#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><a class="srclink" href="../../src/tokio/fs/file.rs.html#582-609" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Waits for a seek operation to complete. <a href="../../tokio/io/trait.AsyncSeek.html#tymethod.poll_complete">Read more</a></p>
</div></div><h3 id="impl-AsyncWrite" class="impl"><code class="in-band">impl <a class="trait" href="../../tokio/io/trait.AsyncWrite.html" title="trait tokio::io::AsyncWrite">AsyncWrite</a> for <a class="struct" href="../../tokio/fs/struct.File.html" title="struct tokio::fs::File">File</a></code><a href="#impl-AsyncWrite" class="anchor"></a><a class="srclink" href="../../src/tokio/fs/file.rs.html#612-686" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.poll_write" class="method hidden"><code>fn <a href="../../tokio/io/trait.AsyncWrite.html#tymethod.poll_write" class="fnname">poll_write</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>&nbsp;&nbsp;&nbsp;&nbsp;src: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;[</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><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.usize.html">usize</a>&gt;&gt;</code><a class="srclink" href="../../src/tokio/fs/file.rs.html#613-676" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Attempt to write bytes from <code>buf</code> into the object. <a href="../../tokio/io/trait.AsyncWrite.html#tymethod.poll_write">Read more</a></p>
</div><h4 id="method.poll_flush" class="method hidden"><code>fn <a href="../../tokio/io/trait.AsyncWrite.html#tymethod.poll_flush" class="fnname">poll_flush</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="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, <a class="struct" href="https://doc.rust-lang.org/nightly/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a>&gt;&gt;</code><a class="srclink" href="../../src/tokio/fs/file.rs.html#678-681" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Attempts to flush the object, ensuring that any buffered data reach
their destination. <a href="../../tokio/io/trait.AsyncWrite.html#tymethod.poll_flush">Read more</a></p>
</div><h4 id="method.poll_shutdown" class="method hidden"><code>fn <a href="../../tokio/io/trait.AsyncWrite.html#tymethod.poll_shutdown" class="fnname">poll_shutdown</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="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, <a class="struct" href="https://doc.rust-lang.org/nightly/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a>&gt;&gt;</code><a class="srclink" href="../../src/tokio/fs/file.rs.html#683-685" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Initiates or attempts to shut down this writer, returning success when
the I/O connection has completely shut down. <a href="../../tokio/io/trait.AsyncWrite.html#tymethod.poll_shutdown">Read more</a></p>
</div><h4 id="method.poll_write_vectored" class="method hidden"><code>fn <a href="../../tokio/io/trait.AsyncWrite.html#method.poll_write_vectored" class="fnname">poll_write_vectored</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>&nbsp;&nbsp;&nbsp;&nbsp;bufs: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;[</a><a class="struct" href="https://doc.rust-lang.org/nightly/std/io/struct.IoSlice.html" title="struct std::io::IoSlice">IoSlice</a>&lt;'_&gt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a><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="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>, <a class="struct" href="https://doc.rust-lang.org/nightly/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a>&gt;&gt;</code><a class="srclink" href="../../src/tokio/io/async_write.rs.html#154-164" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Like <a href="../../tokio/io/trait.AsyncWrite.html#tymethod.poll_write"><code>poll_write</code></a>, except that it writes from a slice of buffers. <a href="../../tokio/io/trait.AsyncWrite.html#method.poll_write_vectored">Read more</a></p>
</div><h4 id="method.is_write_vectored" class="method hidden"><code>fn <a href="../../tokio/io/trait.AsyncWrite.html#method.is_write_vectored" class="fnname">is_write_vectored</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code><a class="srclink" href="../../src/tokio/io/async_write.rs.html#176-178" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Determines if this writer has an efficient <a href="../../tokio/io/trait.AsyncWrite.html#method.poll_write_vectored"><code>poll_write_vectored</code></a>
implementation. <a href="../../tokio/io/trait.AsyncWrite.html#method.is_write_vectored">Read more</a></p>
</div></div><h3 id="impl-Debug" class="impl"><code class="in-band">impl <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/fs/struct.File.html" title="struct tokio::fs::File">File</a></code><a href="#impl-Debug" class="anchor"></a><a class="srclink" href="../../src/tokio/fs/file.rs.html#694-700" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.fmt" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt" class="fnname">fmt</a>(&amp;self, fmt: &amp;mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a>&lt;'_&gt;) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code><a class="srclink" href="../../src/tokio/fs/file.rs.html#695-699" title="goto source code">[src]</a></h4><div class='docblock hidden'><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-From%3CFile%3E" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;<a class="struct" href="https://doc.rust-lang.org/nightly/std/fs/struct.File.html" title="struct std::fs::File">File</a>&gt; for <a class="struct" href="../../tokio/fs/struct.File.html" title="struct tokio::fs::File">File</a></code><a href="#impl-From%3CFile%3E" class="anchor"></a><a class="srclink" href="../../src/tokio/fs/file.rs.html#688-692" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.from" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">from</a>(std: <a class="struct" href="https://doc.rust-lang.org/nightly/std/fs/struct.File.html" title="struct std::fs::File">File</a>) -&gt; Self</code><a class="srclink" href="../../src/tokio/fs/file.rs.html#689-691" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
</div></div><h3 id="impl-FromRawFd" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/std/sys/unix/ext/io/trait.FromRawFd.html" title="trait std::sys::unix::ext::io::FromRawFd">FromRawFd</a> for <a class="struct" href="../../tokio/fs/struct.File.html" title="struct tokio::fs::File">File</a></code><a href="#impl-FromRawFd" class="anchor"></a><a class="srclink" href="../../src/tokio/fs/file.rs.html#710-714" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.from_raw_fd" class="method hidden"><code>unsafe fn <a href="https://doc.rust-lang.org/nightly/std/sys/unix/ext/io/trait.FromRawFd.html#tymethod.from_raw_fd" class="fnname">from_raw_fd</a>(fd: <a class="type" href="https://doc.rust-lang.org/nightly/std/sys/unix/ext/io/type.RawFd.html" title="type std::sys::unix::ext::io::RawFd">RawFd</a>) -&gt; Self</code><a class="srclink" href="../../src/tokio/fs/file.rs.html#711-713" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Constructs a new instance of <code>Self</code> from the given raw file
descriptor. <a href="https://doc.rust-lang.org/nightly/std/sys/unix/ext/io/trait.FromRawFd.html#tymethod.from_raw_fd">Read more</a></p>
</div></div></div><h2 id="synthetic-implementations" class="small-section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor"></a></h2><div id="synthetic-implementations-list"><h3 id="impl-RefUnwindSafe" class="impl"><code class="in-band">impl !<a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.RefUnwindSafe.html" title="trait std::panic::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="../../tokio/fs/struct.File.html" title="struct tokio::fs::File">File</a></code><a href="#impl-RefUnwindSafe" class="anchor"></a><a class="srclink" href="../../src/tokio/lib.rs.html#1" title="goto source code">[src]</a></h3><div class="impl-items"></div><h3 id="impl-Send" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="../../tokio/fs/struct.File.html" title="struct tokio::fs::File">File</a></code><a href="#impl-Send" class="anchor"></a><a class="srclink" href="../../src/tokio/lib.rs.html#1" title="goto source code">[src]</a></h3><div class="impl-items"></div><h3 id="impl-Sync" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="../../tokio/fs/struct.File.html" title="struct tokio::fs::File">File</a></code><a href="#impl-Sync" class="anchor"></a><a class="srclink" href="../../src/tokio/lib.rs.html#1" title="goto source code">[src]</a></h3><div class="impl-items"></div><h3 id="impl-Unpin" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="../../tokio/fs/struct.File.html" title="struct tokio::fs::File">File</a></code><a href="#impl-Unpin" class="anchor"></a><a class="srclink" href="../../src/tokio/lib.rs.html#1" title="goto source code">[src]</a></h3><div class="impl-items"></div><h3 id="impl-UnwindSafe" class="impl"><code class="in-band">impl !<a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.UnwindSafe.html" title="trait std::panic::UnwindSafe">UnwindSafe</a> for <a class="struct" href="../../tokio/fs/struct.File.html" title="struct tokio::fs::File">File</a></code><a href="#impl-UnwindSafe" class="anchor"></a><a class="srclink" href="../../src/tokio/lib.rs.html#1" title="goto source code">[src]</a></h3><div class="impl-items"></div></div><h2 id="blanket-implementations" class="small-section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor"></a></h2><div id="blanket-implementations-list"><h3 id="impl-Any" class="impl"><code class="in-band">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></code><a href="#impl-Any" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#131-135" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.type_id" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id" class="fnname">type_id</a>(&amp;self) -&gt; <a class="struct" href="https://doc.rust-lang.org/nightly/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#132" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id">Read more</a></p>
</div></div><h3 id="impl-Borrow%3CT%3E" class="impl"><code class="in-band">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a>&lt;T&gt; for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></code><a href="#impl-Borrow%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#207-211" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow" class="fnname">borrow</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;</a>T<span class="notable-traits"><span class="notable-traits-tooltip"><div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl&lt;'_, F&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;'_ mut </a>F <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = &lt;F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>&gt;::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#208" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></p>
</div></div><h3 id="impl-BorrowMut%3CT%3E" class="impl"><code class="in-band">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a>&lt;T&gt; for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></code><a href="#impl-BorrowMut%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#214-218" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow_mut" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fnname">borrow_mut</a>(&amp;mut self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut </a>T<span class="notable-traits"><span class="notable-traits-tooltip"><div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl&lt;'_, F&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;'_ mut </a>F <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = &lt;F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>&gt;::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#215" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></p>
</div></div><h3 id="impl-From%3CT%3E" class="impl"><code class="in-band">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;T&gt; for T</code><a href="#impl-From%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#545-549" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.from-1" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">from</a>(t: T) -&gt; T</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#546" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
</div></div><h3 id="impl-Into%3CU%3E" class="impl"><code class="in-band">impl&lt;T, U&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;U&gt; for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;T&gt;,&nbsp;</span></code><a href="#impl-Into%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#534-541" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.into" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html#tymethod.into" class="fnname">into</a>(self) -&gt; U</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#538" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
</div></div><h3 id="impl-TryFrom%3CU%3E" class="impl"><code class="in-band">impl&lt;T, U&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;U&gt; for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;T&gt;,&nbsp;</span></code><a href="#impl-TryFrom%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#582-591" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Error" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" class="type">Error</a> = <a class="enum" href="https://doc.rust-lang.org/nightly/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
</div><h4 id="method.try_from" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#tymethod.try_from" class="fnname">try_from</a>(value: U) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;T, &lt;T as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;U&gt;&gt;::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>&gt;</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#588" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
</div></div><h3 id="impl-TryInto%3CU%3E" class="impl"><code class="in-band">impl&lt;T, U&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a>&lt;U&gt; for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;T&gt;,&nbsp;</span></code><a href="#impl-TryInto%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#568-577" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Error-1" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#associatedtype.Error" class="type">Error</a> = &lt;U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;T&gt;&gt;::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
</div><h4 id="method.try_into" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#tymethod.try_into" class="fnname">try_into</a>(self) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;U, &lt;U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;T&gt;&gt;::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>&gt;</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#574" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
</div></div></div></section><section id="search" class="content hidden"></section><section class="footer"></section><div id="rustdoc-vars" data-root-path="../../" data-current-crate="tokio"></div>
<script src="../../main.js"></script><script defer src="../../search-index.js"></script></body></html>