1
0
mirror of https://github.com/actix/actix-website synced 2024-12-01 03:24:36 +01:00
actix-website/static/api/actix-web/stable/actix_web/fs/struct.NamedFile.html
2018-10-10 08:38:33 -07:00

178 lines
55 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 `NamedFile` struct in crate `actix_web`."><meta name="keywords" content="rust, rustlang, rust-lang, NamedFile"><title>actix_web::fs::NamedFile - Rust</title><link rel="stylesheet" type="text/css" href="../../normalize.css"><link rel="stylesheet" type="text/css" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../dark.css"><link rel="stylesheet" type="text/css" href="../../light.css" id="themeStyle"><script src="../../storage.js"></script></head><body class="rustdoc struct"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">&#9776;</div><p class='location'>Struct NamedFile</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#methods">Methods</a><div class="sidebar-links"><a href="#method.open">open</a><a href="#method.open_with_config">open_with_config</a><a href="#method.file">file</a><a href="#method.path">path</a><a href="#method.set_cpu_pool">set_cpu_pool</a><a href="#method.set_status_code">set_status_code</a><a href="#method.set_content_type">set_content_type</a><a href="#method.set_content_disposition">set_content_disposition</a><a href="#method.set_content_encoding">set_content_encoding</a></div><a class="sidebar-title" href="#deref-methods">Methods from Deref&lt;Target=File&gt;</a><div class="sidebar-links"><a href="#method.sync_all">sync_all</a><a href="#method.sync_data">sync_data</a><a href="#method.set_len">set_len</a><a href="#method.metadata">metadata</a><a href="#method.try_clone">try_clone</a><a href="#method.set_permissions">set_permissions</a></div><a class="sidebar-title" href="#implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-Responder">Responder</a><a href="#impl-Debug">Debug</a><a href="#impl-Deref">Deref</a><a href="#impl-DerefMut">DerefMut</a></div><a class="sidebar-title" href="#synthetic-implementations">Auto Trait Implementations</a><div class="sidebar-links"><a href="#impl-Send">Send</a><a href="#impl-Sync">Sync</a></div><a class="sidebar-title" href="#blanket-implementations">Blanket Implementations</a><div class="sidebar-links"><a href="#impl-From">From</a><a href="#impl-Into">Into</a><a href="#impl-TryFrom">TryFrom</a><a href="#impl-Borrow">Borrow</a><a href="#impl-BorrowMut">BorrowMut</a><a href="#impl-TryInto">TryInto</a><a href="#impl-Any">Any</a><a href="#impl-Erased">Erased</a></div></div><p class='location'><a href='../index.html'>actix_web</a>::<wbr><a href='index.html'>fs</a></p><script>window.sidebarCurrent = {name: 'NamedFile', ty: 'struct', relpath: ''};</script><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!"><img src="../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices"></div></div><script src="../../theme.js"></script><nav class="sub"><form class="search-form js-only"><div class="search-container"><input class="search-input" name="search" autocomplete="off" placeholder="Click or press S to search, ? for more options…" type="search"><a id="settings-menu" href="../../settings.html"><img src="../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class='fqn'><span class='out-of-band'><span id='render-detail'><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class='inner'>&#x2212;</span>]</a></span><a class='srclink' href='../../src/actix_web/fs.rs.html#109-120' title='goto source code'>[src]</a></span><span class='in-band'>Struct <a href='../index.html'>actix_web</a>::<wbr><a href='index.html'>fs</a>::<wbr><a class="struct" href=''>NamedFile</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class='rust struct'>pub struct NamedFile&lt;C&nbsp;=&nbsp;<a class="struct" href="../../actix_web/fs/struct.DefaultConfig.html" title="struct actix_web::fs::DefaultConfig">DefaultConfig</a>&gt; { /* fields omitted */ }</pre></div><div class='docblock'><p>A file with an associated name.</p>
</div><h2 id='methods' class='small-section-header'>Methods<a href='#methods' class='anchor'></a></h2><h3 id='impl' class='impl'><span class='in-band'><table class='table-display'><tbody><tr><td><code>impl <a class="struct" href="../../actix_web/fs/struct.NamedFile.html" title="struct actix_web::fs::NamedFile">NamedFile</a></code><a href='#impl' class='anchor'></a></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/actix_web/fs.rs.html#122-135' title='goto source code'>[src]</a></span></td></tr></tbody></table></h3><div class='impl-items'><h4 id='method.open' class="method"><span id='open.v' class='invisible'><table class='table-display'><tbody><tr><td><code>pub fn <a href='#method.open' class='fnname'>open</a>&lt;P:&nbsp;<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;(path: P) -&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="../../actix_web/fs/struct.NamedFile.html" title="struct actix_web::fs::NamedFile">NamedFile</a>&gt;</code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/actix_web/fs.rs.html#132-134' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock'><p>Attempts to open a file in read-only mode.</p>
<h1 id="examples" class="section-header"><a href="#examples">Examples</a></h1>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">actix_web</span>::<span class="ident">fs</span>::<span class="ident">NamedFile</span>;
<span class="kw">let</span> <span class="ident">file</span> <span class="op">=</span> <span class="ident">NamedFile</span>::<span class="ident">open</span>(<span class="string">&quot;foo.txt&quot;</span>);</pre>
</div></div><h3 id='impl-1' class='impl'><span class='in-band'><table class='table-display'><tbody><tr><td><code>impl&lt;C:&nbsp;<a class="trait" href="../../actix_web/fs/trait.StaticFileConfig.html" title="trait actix_web::fs::StaticFileConfig">StaticFileConfig</a>&gt; <a class="struct" href="../../actix_web/fs/struct.NamedFile.html" title="struct actix_web::fs::NamedFile">NamedFile</a>&lt;C&gt;</code><a href='#impl-1' class='anchor'></a></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/actix_web/fs.rs.html#137-287' title='goto source code'>[src]</a></span></td></tr></tbody></table></h3><div class='impl-items'><h4 id='method.open_with_config' class="method"><span id='open_with_config.v' class='invisible'><table class='table-display'><tbody><tr><td><code>pub fn <a href='#method.open_with_config' class='fnname'>open_with_config</a>&lt;P:&nbsp;<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;(path: P, _: C) -&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="../../actix_web/fs/struct.NamedFile.html" title="struct actix_web::fs::NamedFile">NamedFile</a>&lt;C&gt;&gt;</code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/actix_web/fs.rs.html#147-189' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock'><p>Attempts to open a file in read-only mode using provided configiration.</p>
<h1 id="examples-1" class="section-header"><a href="#examples-1">Examples</a></h1>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">actix_web</span>::<span class="ident">fs</span>::{<span class="ident">DefaultConfig</span>, <span class="ident">NamedFile</span>};
<span class="kw">let</span> <span class="ident">file</span> <span class="op">=</span> <span class="ident">NamedFile</span>::<span class="ident">open_with_config</span>(<span class="string">&quot;foo.txt&quot;</span>, <span class="ident">DefaultConfig</span>);</pre>
</div><h4 id='method.file' class="method"><span id='file.v' class='invisible'><table class='table-display'><tbody><tr><td><code>pub fn <a href='#method.file' class='fnname'>file</a>(&amp;self) -&gt; &amp;<a class="struct" href="https://doc.rust-lang.org/nightly/std/fs/struct.File.html" title="struct std::fs::File">File</a></code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/actix_web/fs.rs.html#193-195' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock'><p>Returns reference to the underlying <code>File</code> object.</p>
</div><h4 id='method.path' class="method"><span id='path.v' class='invisible'><table class='table-display'><tbody><tr><td><code>pub fn <a href='#method.path' class='fnname'>path</a>(&amp;self) -&gt; &amp;<a class="struct" href="https://doc.rust-lang.org/nightly/std/path/struct.Path.html" title="struct std::path::Path">Path</a></code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/actix_web/fs.rs.html#212-214' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock'><p>Retrieve the path of this file.</p>
<h1 id="examples-2" class="section-header"><a href="#examples-2">Examples</a></h1>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">actix_web</span>::<span class="ident">fs</span>::<span class="ident">NamedFile</span>;
<span class="kw">let</span> <span class="ident">file</span> <span class="op">=</span> <span class="ident">NamedFile</span>::<span class="ident">open</span>(<span class="string">&quot;test.txt&quot;</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">file</span>.<span class="ident">path</span>().<span class="ident">as_os_str</span>(), <span class="string">&quot;foo.txt&quot;</span>);</pre>
</div><h4 id='method.set_cpu_pool' class="method"><span id='set_cpu_pool.v' class='invisible'><table class='table-display'><tbody><tr><td><code>pub fn <a href='#method.set_cpu_pool' class='fnname'>set_cpu_pool</a>(self, cpu_pool: CpuPool) -&gt; Self</code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/actix_web/fs.rs.html#218-221' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock'><p>Set <code>CpuPool</code> to use</p>
</div><h4 id='method.set_status_code' class="method"><span id='set_status_code.v' class='invisible'><table class='table-display'><tbody><tr><td><code>pub fn <a href='#method.set_status_code' class='fnname'>set_status_code</a>(self, status: <a class="struct" href="../../actix_web/http/struct.StatusCode.html" title="struct actix_web::http::StatusCode">StatusCode</a>) -&gt; Self</code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/actix_web/fs.rs.html#224-227' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock'><p>Set response <strong>Status Code</strong></p>
</div><h4 id='method.set_content_type' class="method"><span id='set_content_type.v' class='invisible'><table class='table-display'><tbody><tr><td><code>pub fn <a href='#method.set_content_type' class='fnname'>set_content_type</a>(self, mime_type: <a class="struct" href="https://docs.rs/mime/0.3.9/mime/struct.Mime.html" title="struct mime::Mime">Mime</a>) -&gt; Self</code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/actix_web/fs.rs.html#232-235' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock'><p>Set the MIME Content-Type for serving this file. By default
the Content-Type is inferred from the filename extension.</p>
</div><h4 id='method.set_content_disposition' class="method"><span id='set_content_disposition.v' class='invisible'><table class='table-display'><tbody><tr><td><code>pub fn <a href='#method.set_content_disposition' class='fnname'>set_content_disposition</a>(self, cd: <a class="struct" href="../../actix_web/http/header/struct.ContentDisposition.html" title="struct actix_web::http::header::ContentDisposition">ContentDisposition</a>) -&gt; Self</code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/actix_web/fs.rs.html#245-248' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock'><p>Set the Content-Disposition for serving this file. This allows
changing the inline/attachment disposition as well as the filename
sent to the peer. By default the disposition is <code>inline</code> for text,
image, and video content types, and <code>attachment</code> otherwise, and
the filename is taken from the path provided in the <code>open</code> method
after converting it to UTF-8 using
<a href="https://doc.rust-lang.org/std/ffi/struct.OsStr.html#method.to_string_lossy">to_string_lossy</a>.</p>
</div><h4 id='method.set_content_encoding' class="method"><span id='set_content_encoding.v' class='invisible'><table class='table-display'><tbody><tr><td><code>pub fn <a href='#method.set_content_encoding' class='fnname'>set_content_encoding</a>(self, enc: <a class="enum" href="../../actix_web/http/enum.ContentEncoding.html" title="enum actix_web::http::ContentEncoding">ContentEncoding</a>) -&gt; Self</code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/actix_web/fs.rs.html#252-255' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock'><p>Set content encoding for serving this file</p>
</div></div><h2 id='deref-methods' class='small-section-header'>Methods from <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/deref/trait.Deref.html" title="trait core::ops::deref::Deref">Deref</a>&lt;Target = <a class="struct" href="https://doc.rust-lang.org/nightly/std/fs/struct.File.html" title="struct std::fs::File">File</a>&gt;<a href='#deref-methods' class='anchor'></a></h2><div class='impl-items'><h4 id='method.sync_all' class="method"><span id='sync_all.v' class='invisible'><table class='table-display'><tbody><tr><td><code>pub fn <a href='#method.sync_all' class='fnname'>sync_all</a>(&amp;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="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;</code></span></td><td><span class='out-of-band'><div class='ghost'></div><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/std/fs.rs.html#412-414' title='goto source code'>[src]</a></td></tr></tbody></table></span></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-3" class="section-header"><a href="#examples-3">Examples</a></h1>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">fs</span>::<span class="ident">File</span>;
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>::<span class="ident">prelude</span>::<span class="kw-2">*</span>;
<span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-&gt;</span> <span class="ident">std</span>::<span class="ident">io</span>::<span class="prelude-ty">Result</span><span class="op">&lt;</span>()<span class="op">&gt;</span> {
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">f</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="question-mark">?</span>;
<span class="ident">f</span>.<span class="ident">write_all</span>(<span class="string">b&quot;Hello, world!&quot;</span>)<span class="question-mark">?</span>;
<span class="ident">f</span>.<span class="ident">sync_all</span>()<span class="question-mark">?</span>;
<span class="prelude-val">Ok</span>(())
}</pre>
</div><h4 id='method.sync_data' class="method"><span id='sync_data.v' class='invisible'><table class='table-display'><tbody><tr><td><code>pub fn <a href='#method.sync_data' class='fnname'>sync_data</a>(&amp;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="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;</code></span></td><td><span class='out-of-band'><div class='ghost'></div><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/std/fs.rs.html#443-445' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock'><p>This function is similar to <a href="struct.File.html#method.sync_all"><code>sync_all</code></a>, 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
<a href="struct.File.html#method.sync_all"><code>sync_all</code></a>.</p>
<h1 id="examples-4" class="section-header"><a href="#examples-4">Examples</a></h1>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">fs</span>::<span class="ident">File</span>;
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>::<span class="ident">prelude</span>::<span class="kw-2">*</span>;
<span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-&gt;</span> <span class="ident">std</span>::<span class="ident">io</span>::<span class="prelude-ty">Result</span><span class="op">&lt;</span>()<span class="op">&gt;</span> {
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">f</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="question-mark">?</span>;
<span class="ident">f</span>.<span class="ident">write_all</span>(<span class="string">b&quot;Hello, world!&quot;</span>)<span class="question-mark">?</span>;
<span class="ident">f</span>.<span class="ident">sync_data</span>()<span class="question-mark">?</span>;
<span class="prelude-val">Ok</span>(())
}</pre>
</div><h4 id='method.set_len' class="method"><span id='set_len.v' class='invisible'><table class='table-display'><tbody><tr><td><code>pub 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="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;</code></span></td><td><span class='out-of-band'><div class='ghost'></div><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/std/fs.rs.html#478-480' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock'><p>Truncates or extends the underlying file, updating the size of
this file to become <code>size</code>.</p>
<p>If the <code>size</code> 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 <code>size</code> and have all of the intermediate data filled
in with 0s.</p>
<p>The file's cursor isn't changed. In particular, if the cursor was at the
end and the file is shrunk using this operation, the cursor will now be
past the end.</p>
<h1 id="errors" class="section-header"><a href="#errors">Errors</a></h1>
<p>This function will return an error if the file is not opened for writing.</p>
<h1 id="examples-5" class="section-header"><a href="#examples-5">Examples</a></h1>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">fs</span>::<span class="ident">File</span>;
<span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-&gt;</span> <span class="ident">std</span>::<span class="ident">io</span>::<span class="prelude-ty">Result</span><span class="op">&lt;</span>()<span class="op">&gt;</span> {
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">f</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="question-mark">?</span>;
<span class="ident">f</span>.<span class="ident">set_len</span>(<span class="number">10</span>)<span class="question-mark">?</span>;
<span class="prelude-val">Ok</span>(())
}</pre>
<p>Note that this method alters the content of the underlying file, even
though it takes <code>&amp;self</code> rather than <code>&amp;mut self</code>.</p>
</div><h4 id='method.metadata' class="method"><span id='metadata.v' class='invisible'><table class='table-display'><tbody><tr><td><code>pub fn <a href='#method.metadata' class='fnname'>metadata</a>(&amp;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.Metadata.html" title="struct std::fs::Metadata">Metadata</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;</code></span></td><td><span class='out-of-band'><div class='ghost'></div><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/std/fs.rs.html#496-498' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock'><p>Queries metadata about the underlying file.</p>
<h1 id="examples-6" class="section-header"><a href="#examples-6">Examples</a></h1>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">fs</span>::<span class="ident">File</span>;
<span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-&gt;</span> <span class="ident">std</span>::<span class="ident">io</span>::<span class="prelude-ty">Result</span><span class="op">&lt;</span>()<span class="op">&gt;</span> {
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">f</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="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">metadata</span> <span class="op">=</span> <span class="ident">f</span>.<span class="ident">metadata</span>()<span class="question-mark">?</span>;
<span class="prelude-val">Ok</span>(())
}</pre>
</div><h4 id='method.try_clone' class="method"><span id='try_clone.v' class='invisible'><table class='table-display'><tbody><tr><td><code>pub fn <a href='#method.try_clone' class='fnname'>try_clone</a>(&amp;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>, <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;</code></span></td><td><span class='out-of-band'><div class='ghost'></div><div class='since' title='Stable since Rust version 1.9.0'>1.9.0</div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/std/fs.rs.html#540-544' title='goto source code'>[src]</a></td></tr></tbody></table></span></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 <code>File</code> instances simultaneously.</p>
<h1 id="examples-7" class="section-header"><a href="#examples-7">Examples</a></h1>
<p>Create two handles for a file named <code>foo.txt</code>:</p>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">fs</span>::<span class="ident">File</span>;
<span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-&gt;</span> <span class="ident">std</span>::<span class="ident">io</span>::<span class="prelude-ty">Result</span><span class="op">&lt;</span>()<span class="op">&gt;</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="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">file_copy</span> <span class="op">=</span> <span class="ident">file</span>.<span class="ident">try_clone</span>()<span class="question-mark">?</span>;
<span class="prelude-val">Ok</span>(())
}</pre>
<p>Assuming theres a file named <code>foo.txt</code> with contents <code>abcdef\n</code>, create
two handles, seek one of them, and read the remaining bytes from the
other handle:</p>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">fs</span>::<span class="ident">File</span>;
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>::<span class="ident">SeekFrom</span>;
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>::<span class="ident">prelude</span>::<span class="kw-2">*</span>;
<span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-&gt;</span> <span class="ident">std</span>::<span class="ident">io</span>::<span class="prelude-ty">Result</span><span class="op">&lt;</span>()<span class="op">&gt;</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="question-mark">?</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">file_copy</span> <span class="op">=</span> <span class="ident">file</span>.<span class="ident">try_clone</span>()<span class="question-mark">?</span>;
<span class="ident">file</span>.<span class="ident">seek</span>(<span class="ident">SeekFrom</span>::<span class="ident">Start</span>(<span class="number">3</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_copy</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="question-mark">?</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">contents</span>, <span class="string">b&quot;def\n&quot;</span>);
<span class="prelude-val">Ok</span>(())
}</pre>
</div><h4 id='method.set_permissions' class="method"><span id='set_permissions.v' class='invisible'><table class='table-display'><tbody><tr><td><code>pub 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="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;</code></span></td><td><span class='out-of-band'><div class='ghost'></div><div class='since' title='Stable since Rust version 1.16.0'>1.16.0</div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/std/fs.rs.html#579-581' title='goto source code'>[src]</a></td></tr></tbody></table></span></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="../io/index.html#platform-specific-behavior">may change in the future</a>.</p>
<h1 id="errors-1" class="section-header"><a href="#errors-1">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-8" class="section-header"><a href="#examples-8">Examples</a></h1>
<pre class="rust rust-example-rendered">
<span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-&gt;</span> <span class="ident">std</span>::<span class="ident">io</span>::<span class="prelude-ty">Result</span><span class="op">&lt;</span>()<span class="op">&gt;</span> {
<span class="kw">use</span> <span class="ident">std</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="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="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="question-mark">?</span>;
<span class="prelude-val">Ok</span>(())
}</pre>
<p>Note that this method alters the permissions of the underlying file,
even though it takes <code>&amp;self</code> rather than <code>&amp;mut self</code>.</p>
</div></div><h2 id='implementations' class='small-section-header'>Trait Implementations<a href='#implementations' class='anchor'></a></h2><div id='implementations-list'><h3 id='impl-Responder' class='impl'><span class='in-band'><table class='table-display'><tbody><tr><td><code>impl&lt;C:&nbsp;<a class="trait" href="../../actix_web/fs/trait.StaticFileConfig.html" title="trait actix_web::fs::StaticFileConfig">StaticFileConfig</a>&gt; <a class="trait" href="../../actix_web/trait.Responder.html" title="trait actix_web::Responder">Responder</a> for <a class="struct" href="../../actix_web/fs/struct.NamedFile.html" title="struct actix_web::fs::NamedFile">NamedFile</a>&lt;C&gt;</code><a href='#impl-Responder' class='anchor'></a></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/actix_web/fs.rs.html#338-473' title='goto source code'>[src]</a></span></td></tr></tbody></table></h3><div class='impl-items'><h4 id='associatedtype.Item' class="type"><span id='Item.t' class='invisible'><code>type <a href='../../actix_web/trait.Responder.html#associatedtype.Item' class="type">Item</a> = <a class="struct" href="../../actix_web/struct.HttpResponse.html" title="struct actix_web::HttpResponse">HttpResponse</a></code></span></h4>
<div class='docblock'><p>The associated item which can be returned.</p>
</div><h4 id='associatedtype.Error' class="type"><span id='Error.t' class='invisible'><code>type <a href='../../actix_web/trait.Responder.html#associatedtype.Error' class="type">Error</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></span></h4>
<div class='docblock'><p>The associated error which can be returned.</p>
</div><h4 id='method.respond_to' class="method"><span id='respond_to.v' class='invisible'><table class='table-display'><tbody><tr><td><code>fn <a href='../../actix_web/trait.Responder.html#tymethod.respond_to' class='fnname'>respond_to</a>&lt;S&gt;(self, req: &amp;<a class="struct" href="../../actix_web/struct.HttpRequest.html" title="struct actix_web::HttpRequest">HttpRequest</a>&lt;S&gt;) -&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="../../actix_web/struct.HttpResponse.html" title="struct actix_web::HttpResponse">HttpResponse</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;</code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/actix_web/fs.rs.html#342-472' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock'><p>Convert itself to <code>AsyncResult</code> or <code>Error</code>.</p>
</div></div><h3 id='impl-Debug' class='impl'><span class='in-band'><table class='table-display'><tbody><tr><td><code>impl&lt;C:&nbsp;<a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a>&gt; <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="../../actix_web/fs/struct.NamedFile.html" title="struct actix_web::fs::NamedFile">NamedFile</a>&lt;C&gt;</code><a href='#impl-Debug' class='anchor'></a></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/actix_web/fs.rs.html#108' title='goto source code'>[src]</a></span></td></tr></tbody></table></h3><div class='impl-items'><h4 id='method.fmt' class="method"><span id='fmt.v' class='invisible'><table class='table-display'><tbody><tr><td><code>fn <a href='https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt' class='fnname'>fmt</a>(&amp;self, f: &amp;mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/actix_web/fs.rs.html#108' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></p>
</div></div><h3 id='impl-Deref' class='impl'><span class='in-band'><table class='table-display'><tbody><tr><td><code>impl&lt;C&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/deref/trait.Deref.html" title="trait core::ops::deref::Deref">Deref</a> for <a class="struct" href="../../actix_web/fs/struct.NamedFile.html" title="struct actix_web::fs::NamedFile">NamedFile</a>&lt;C&gt;</code><a href='#impl-Deref' class='anchor'></a></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/actix_web/fs.rs.html#289-295' title='goto source code'>[src]</a></span></td></tr></tbody></table></h3><div class='impl-items'><h4 id='associatedtype.Target' class="type"><span id='Target.t' class='invisible'><code>type <a href='https://doc.rust-lang.org/nightly/core/ops/deref/trait.Deref.html#associatedtype.Target' class="type">Target</a> = <a class="struct" href="https://doc.rust-lang.org/nightly/std/fs/struct.File.html" title="struct std::fs::File">File</a></code></span></h4>
<div class='docblock'><p>The resulting type after dereferencing.</p>
</div><h4 id='method.deref' class="method"><span id='deref.v' class='invisible'><table class='table-display'><tbody><tr><td><code>fn <a href='https://doc.rust-lang.org/nightly/core/ops/deref/trait.Deref.html#tymethod.deref' class='fnname'>deref</a>(&amp;self) -&gt; &amp;<a class="struct" href="https://doc.rust-lang.org/nightly/std/fs/struct.File.html" title="struct std::fs::File">File</a></code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/actix_web/fs.rs.html#292-294' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock'><p>Dereferences the value.</p>
</div></div><h3 id='impl-DerefMut' class='impl'><span class='in-band'><table class='table-display'><tbody><tr><td><code>impl&lt;C&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/deref/trait.DerefMut.html" title="trait core::ops::deref::DerefMut">DerefMut</a> for <a class="struct" href="../../actix_web/fs/struct.NamedFile.html" title="struct actix_web::fs::NamedFile">NamedFile</a>&lt;C&gt;</code><a href='#impl-DerefMut' class='anchor'></a></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/actix_web/fs.rs.html#297-301' title='goto source code'>[src]</a></span></td></tr></tbody></table></h3><div class='impl-items'><h4 id='method.deref_mut' class="method"><span id='deref_mut.v' class='invisible'><table class='table-display'><tbody><tr><td><code>fn <a href='https://doc.rust-lang.org/nightly/core/ops/deref/trait.DerefMut.html#tymethod.deref_mut' class='fnname'>deref_mut</a>(&amp;mut self) -&gt; &amp;mut <a class="struct" href="https://doc.rust-lang.org/nightly/std/fs/struct.File.html" title="struct std::fs::File">File</a></code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/actix_web/fs.rs.html#298-300' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock'><p>Mutably dereferences the value.</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-Send' class='impl'><span class='in-band'><table class='table-display'><tbody><tr><td><code>impl&lt;C&gt; <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="../../actix_web/fs/struct.NamedFile.html" title="struct actix_web::fs::NamedFile">NamedFile</a>&lt;C&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;C: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a>,&nbsp;</span></code><a href='#impl-Send' class='anchor'></a></span></td><td><span class='out-of-band'></span></td></tr></tbody></table></h3><div class='impl-items'></div><h3 id='impl-Sync' class='impl'><span class='in-band'><table class='table-display'><tbody><tr><td><code>impl&lt;C&gt; <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="../../actix_web/fs/struct.NamedFile.html" title="struct actix_web::fs::NamedFile">NamedFile</a>&lt;C&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;C: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a>,&nbsp;</span></code><a href='#impl-Sync' class='anchor'></a></span></td><td><span class='out-of-band'></span></td></tr></tbody></table></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-From' class='impl'><span class='in-band'><table class='table-display'><tbody><tr><td><code>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> for T</code><a href='#impl-From' class='anchor'></a></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/convert.rs.html#462-464' title='goto source code'>[src]</a></span></td></tr></tbody></table></h3><div class='impl-items'><h4 id='method.from' class="method"><span id='from.v' class='invisible'><table class='table-display'><tbody><tr><td><code>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></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/convert.rs.html#463' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock'><p>Performs the conversion.</p>
</div></div><h3 id='impl-Into' class='impl'><span class='in-band'><table class='table-display'><tbody><tr><td><code>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> 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' class='anchor'></a></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/convert.rs.html#453-458' title='goto source code'>[src]</a></span></td></tr></tbody></table></h3><div class='impl-items'><h4 id='method.into' class="method"><span id='into.v' class='invisible'><table class='table-display'><tbody><tr><td><code>fn <a href='https://doc.rust-lang.org/nightly/core/convert/trait.Into.html#tymethod.into' class='fnname'>into</a>(self) -&gt; U</code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/convert.rs.html#455-457' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock'><p>Performs the conversion.</p>
</div></div><h3 id='impl-TryFrom' class='impl'><span class='in-band'><table class='table-display'><tbody><tr><td><code>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> 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/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;U&gt;,&nbsp;</span></code><a href='#impl-TryFrom' class='anchor'></a></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/convert.rs.html#481-487' title='goto source code'>[src]</a></span></td></tr></tbody></table></h3><div class='impl-items'><h4 id='associatedtype.Error-1' class="type"><span id='Error.t-1' class='invisible'><code>type <a href='https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error' class="type">Error</a> = <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.never.html">!</a></code></span></h4>
<div class='stability'><div class='stab unstable'><span class=microscope>🔬</span> This is a nightly-only experimental API. (<code>try_from</code>)</div></div><div class='docblock'><p>The type returned in the event of a conversion error.</p>
</div><h4 id='method.try_from' class="method"><span id='try_from.v' class='invisible'><table class='table-display'><tbody><tr><td><code>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></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/convert.rs.html#484-486' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='stability'><div class='stab unstable'><span class=microscope>🔬</span> This is a nightly-only experimental API. (<code>try_from</code>)</div></div><div class='docblock'><p>Performs the conversion.</p>
</div></div><h3 id='impl-Borrow' class='impl'><span class='in-band'><table class='table-display'><tbody><tr><td><code>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> 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' class='anchor'></a></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#219-221' title='goto source code'>[src]</a></span></td></tr></tbody></table></h3><div class='impl-items'><h4 id='method.borrow' class="method"><span id='borrow.v' class='invisible'><table class='table-display'><tbody><tr><td><code>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</code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#220' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock'><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' class='impl'><span class='in-band'><table class='table-display'><tbody><tr><td><code>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> 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' class='anchor'></a></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#224-226' title='goto source code'>[src]</a></span></td></tr></tbody></table></h3><div class='impl-items'><h4 id='method.borrow_mut' class="method"><span id='borrow_mut.v' class='invisible'><table class='table-display'><tbody><tr><td><code>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</code></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#225' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='docblock'><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-TryInto' class='impl'><span class='in-band'><table class='table-display'><tbody><tr><td><code>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> 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' class='anchor'></a></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/convert.rs.html#469-476' title='goto source code'>[src]</a></span></td></tr></tbody></table></h3><div class='impl-items'><h4 id='associatedtype.Error-2' class="type"><span id='Error.t-2' class='invisible'><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></span></h4>
<div class='stability'><div class='stab unstable'><span class=microscope>🔬</span> This is a nightly-only experimental API. (<code>try_from</code>)</div></div><div class='docblock'><p>The type returned in the event of a conversion error.</p>
</div><h4 id='method.try_into' class="method"><span id='try_into.v' class='invisible'><table class='table-display'><tbody><tr><td><code>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></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/convert.rs.html#473-475' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='stability'><div class='stab unstable'><span class=microscope>🔬</span> This is a nightly-only experimental API. (<code>try_from</code>)</div></div><div class='docblock'><p>Performs the conversion.</p>
</div></div><h3 id='impl-Any' class='impl'><span class='in-band'><table class='table-display'><tbody><tr><td><code>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></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/any.rs.html#114-116' title='goto source code'>[src]</a></span></td></tr></tbody></table></h3><div class='impl-items'><h4 id='method.get_type_id' class="method"><span id='get_type_id.v' class='invisible'><table class='table-display'><tbody><tr><td><code>fn <a href='https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.get_type_id' class='fnname'>get_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></span></td><td><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/any.rs.html#115' title='goto source code'>[src]</a></td></tr></tbody></table></span></h4><div class='stability'><div class='stab unstable'><details><summary><span class=microscope>🔬</span> This is a nightly-only experimental API. (<code>get_type_id</code>)</summary><p>this method will likely be replaced by an associated static</p>
</details></div></div><div class='docblock'><p>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.get_type_id">Read more</a></p>
</div></div><h3 id='impl-Erased' class='impl'><span class='in-band'><table class='table-display'><tbody><tr><td><code>impl&lt;T&gt; Erased for T</code><a href='#impl-Erased' class='anchor'></a></span></td><td><span class='out-of-band'></span></td></tr></tbody></table></h3><div class='impl-items'></div></div></section><section id="search" class="content hidden"></section><section class="footer"></section><aside id="help" class="hidden"><div><h1 class="hidden">Help</h1><div class="shortcuts"><h2>Keyboard Shortcuts</h2><dl><dt><kbd>?</kbd></dt><dd>Show this help dialog</dd><dt><kbd>S</kbd></dt><dd>Focus the search field</dd><dt><kbd></kbd></dt><dd>Move up in search results</dd><dt><kbd></kbd></dt><dd>Move down in search results</dd><dt><kbd></kbd></dt><dd>Switch tab</dd><dt><kbd>&#9166;</kbd></dt><dd>Go to active search result</dd><dt><kbd>+</kbd></dt><dd>Expand all sections</dd><dt><kbd>-</kbd></dt><dd>Collapse all sections</dd></dl></div><div class="infos"><h2>Search Tricks</h2><p>Prefix searches with a type followed by a colon (e.g. <code>fn:</code>) to restrict the search to a given type.</p><p>Accepted types are: <code>fn</code>, <code>mod</code>, <code>struct</code>, <code>enum</code>, <code>trait</code>, <code>type</code>, <code>macro</code>, and <code>const</code>.</p><p>Search functions by type signature (e.g. <code>vec -> usize</code> or <code>* -> vec</code>)</p><p>Search multiple things at once by splitting your query with comma (e.g. <code>str,u8</code> or <code>String,struct:Vec,test</code>)</p></div></div></aside><script>window.rootPath = "../../";window.currentCrate = "actix_web";</script><script src="../../aliases.js"></script><script src="../../main.js"></script><script defer src="../../search-index.js"></script></body></html>