204 lines
63 KiB
HTML
204 lines
63 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 `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">☰</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<File></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<T></a><a href="#impl-BorrowMut%3CT%3E">BorrowMut<T></a><a href="#impl-From%3CT%3E">From<T></a><a href="#impl-Into%3CU%3E">Into<U></a><a href="#impl-TryFrom%3CU%3E">TryFrom<U></a><a href="#impl-TryInto%3CU%3E">TryInto<U></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">−</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">"foo.txt"</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"hello, world!"</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">"foo.txt"</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">&</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">"len = {}"</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><<a class="struct" href="https://doc.rust-lang.org/nightly/std/path/struct.Path.html" title="struct std::path::Path">Path</a>>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<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#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">"foo.txt"</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">&</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">"len = {}"</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><<a class="struct" href="https://doc.rust-lang.org/nightly/std/path/struct.Path.html" title="struct std::path::Path">Path</a>>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<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#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">"foo.txt"</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"hello, world!"</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>) -> <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">"foo.txt"</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>(&self) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></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">"foo.txt"</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"hello, world!"</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>(&self) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></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">"foo.txt"</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"hello, world!"</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>(&self, size: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></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">"foo.txt"</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"hello, world!"</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>(&self) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="struct" href="https://doc.rust-lang.org/nightly/std/fs/struct.Metadata.html" title="struct std::fs::Metadata">Metadata</a>></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">"foo.txt"</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">"{:?}"</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>(&self) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<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#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">"foo.txt"</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) -> <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">"foo.txt"</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) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="struct" href="https://doc.rust-lang.org/nightly/std/fs/struct.File.html" title="struct std::fs::File">File</a>, Self></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">"foo.txt"</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>(&self, perm: <a class="struct" href="https://doc.rust-lang.org/nightly/std/fs/struct.Permissions.html" title="struct std::fs::Permissions">Permissions</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></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">"foo.txt"</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>(&self) -> <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> self: <a class="struct" href="https://doc.rust-lang.org/nightly/core/pin/struct.Pin.html" title="struct core::pin::Pin">Pin</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>Self>, <br> cx: &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><'_>, <br> dst: &mut <a class="struct" href="../../tokio/io/struct.ReadBuf.html" title="struct tokio::io::ReadBuf">ReadBuf</a><'_><br>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/task/poll/enum.Poll.html" title="enum core::task::poll::Poll">Poll</a><<a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>>></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><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>Self>, pos: <a class="enum" href="https://doc.rust-lang.org/nightly/std/io/enum.SeekFrom.html" title="enum std::io::SeekFrom">SeekFrom</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></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> self: <a class="struct" href="https://doc.rust-lang.org/nightly/core/pin/struct.Pin.html" title="struct core::pin::Pin">Pin</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>Self>, <br> cx: &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><'_><br>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/task/poll/enum.Poll.html" title="enum core::task::poll::Poll">Poll</a><<a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a>>></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> self: <a class="struct" href="https://doc.rust-lang.org/nightly/core/pin/struct.Pin.html" title="struct core::pin::Pin">Pin</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>Self>, <br> cx: &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><'_>, <br> src: <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><br>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/task/poll/enum.Poll.html" title="enum core::task::poll::Poll">Poll</a><<a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>>></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> self: <a class="struct" href="https://doc.rust-lang.org/nightly/core/pin/struct.Pin.html" title="struct core::pin::Pin">Pin</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>Self>, <br> cx: &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><'_><br>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/task/poll/enum.Poll.html" title="enum core::task::poll::Poll">Poll</a><<a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<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>>></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> self: <a class="struct" href="https://doc.rust-lang.org/nightly/core/pin/struct.Pin.html" title="struct core::pin::Pin">Pin</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>Self>, <br> cx: &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><'_><br>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/task/poll/enum.Poll.html" title="enum core::task::poll::Poll">Poll</a><<a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<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>>></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> self: <a class="struct" href="https://doc.rust-lang.org/nightly/core/pin/struct.Pin.html" title="struct core::pin::Pin">Pin</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>Self>, <br> cx: &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><'_>, <br> bufs: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&[</a><a class="struct" href="https://doc.rust-lang.org/nightly/std/io/struct.IoSlice.html" title="struct std::io::IoSlice">IoSlice</a><'_><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a><br>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/task/poll/enum.Poll.html" title="enum core::task::poll::Poll">Poll</a><<a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<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>>></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>(&self) -> <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>(&self, fmt: &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><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><<a class="struct" href="https://doc.rust-lang.org/nightly/std/fs/struct.File.html" title="struct std::fs::File">File</a>> 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>) -> 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>) -> 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<T> <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> T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </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>(&self) -> <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<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a><T> for T <span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </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>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</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">&'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl<'_, F> <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">&'_ mut </a>F <span class="where fmt-newline">where<br> 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>, </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> = <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>>::<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<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a><T> for T <span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </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>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&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">&'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl<'_, F> <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">&'_ mut </a>F <span class="where fmt-newline">where<br> 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>, </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> = <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>>::<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<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> 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) -> 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<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T>, </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) -> 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<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><T>, </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) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><T, <T as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U>>::<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><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<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>, </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> = <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<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) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><U, <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<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><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> |