296 lines
59 KiB
HTML
296 lines
59 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 `OpenOptions` struct in crate `tokio`."><meta name="keywords" content="rust, rustlang, rust-lang, OpenOptions"><title>tokio::fs::OpenOptions - 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 OpenOptions</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#implementations">Methods</a><div class="sidebar-links"><a href="#method.append">append</a><a href="#method.create">create</a><a href="#method.create_new">create_new</a><a href="#method.custom_flags">custom_flags</a><a href="#method.mode">mode</a><a href="#method.new">new</a><a href="#method.open">open</a><a href="#method.read">read</a><a href="#method.truncate">truncate</a><a href="#method.write">write</a></div><a class="sidebar-title" href="#trait-implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-Clone">Clone</a><a href="#impl-Debug">Debug</a><a href="#impl-Default">Default</a><a href="#impl-From%3COpenOptions%3E">From<OpenOptions></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-ToOwned">ToOwned</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><script>window.sidebarCurrent = {name: "OpenOptions", 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!" 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="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/open_options.rs.html#72" title="goto source code">[src]</a></span><span class="in-band">Struct <a href="../index.html">tokio</a>::<wbr><a href="index.html">fs</a>::<wbr><a class="struct" href="">OpenOptions</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust struct">pub struct OpenOptions(_);</pre></div><div class="docblock"><p>Options and flags which can be used to configure how a file is opened.</p>
|
||
<p>This builder exposes the ability to configure how a <a href="../../tokio/fs/struct.File.html"><code>File</code></a> is opened and
|
||
what operations are permitted on the open file. The <a href="../../tokio/fs/struct.File.html#method.open"><code>File::open</code></a> and
|
||
<a href="../../tokio/fs/struct.File.html#method.create"><code>File::create</code></a> methods are aliases for commonly used options using this
|
||
builder.</p>
|
||
<p>Generally speaking, when using <code>OpenOptions</code>, you'll first call <a href="../../tokio/fs/struct.OpenOptions.html#method.new"><code>new</code></a>,
|
||
then chain calls to methods to set each option, then call <a href="../../tokio/fs/struct.OpenOptions.html#method.open"><code>open</code></a>, passing
|
||
the path of the file you're trying to open. This will give you a
|
||
<a href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html"><code>io::Result</code></a> with a <a href="../../tokio/fs/struct.File.html"><code>File</code></a> inside that you can further operate
|
||
on.</p>
|
||
<p>This is a specialized version of <a href="https://doc.rust-lang.org/nightly/std/fs/struct.OpenOptions.html"><code>std::fs::OpenOptions</code></a> for usage from
|
||
the Tokio runtime.</p>
|
||
<p><code>From<std::fs::OpenOptions></code> is implemented for more advanced configuration
|
||
than the methods provided here.</p>
|
||
<h1 id="examples" class="section-header"><a href="#examples">Examples</a></h1>
|
||
<p>Opening a file to read:</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">OpenOptions</span>;
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>;
|
||
|
||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="ident">io</span>::<span class="prelude-ty">Result</span><span class="op"><</span>()<span class="op">></span> {
|
||
<span class="kw">let</span> <span class="ident">file</span> <span class="op">=</span> <span class="ident">OpenOptions</span>::<span class="ident">new</span>()
|
||
.<span class="ident">read</span>(<span class="bool-val">true</span>)
|
||
.<span class="ident">open</span>(<span class="string">"foo.txt"</span>)
|
||
.<span class="kw">await</span><span class="question-mark">?</span>;
|
||
|
||
<span class="prelude-val">Ok</span>(())
|
||
}</pre></div>
|
||
<p>Opening a file for both reading and writing, as well as creating it if it
|
||
doesn't exist:</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">OpenOptions</span>;
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>;
|
||
|
||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="ident">io</span>::<span class="prelude-ty">Result</span><span class="op"><</span>()<span class="op">></span> {
|
||
<span class="kw">let</span> <span class="ident">file</span> <span class="op">=</span> <span class="ident">OpenOptions</span>::<span class="ident">new</span>()
|
||
.<span class="ident">read</span>(<span class="bool-val">true</span>)
|
||
.<span class="ident">write</span>(<span class="bool-val">true</span>)
|
||
.<span class="ident">create</span>(<span class="bool-val">true</span>)
|
||
.<span class="ident">open</span>(<span class="string">"foo.txt"</span>)
|
||
.<span class="kw">await</span><span class="question-mark">?</span>;
|
||
|
||
<span class="prelude-val">Ok</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.OpenOptions.html" title="struct tokio::fs::OpenOptions">OpenOptions</a></code><a href="#impl" class="anchor"></a><a class="srclink" href="../../src/tokio/fs/open_options.rs.html#74-390" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.new" class="method"><code>pub fn <a href="#method.new" class="fnname">new</a>() -> <a class="struct" href="../../tokio/fs/struct.OpenOptions.html" title="struct tokio::fs::OpenOptions">OpenOptions</a></code><a class="srclink" href="../../src/tokio/fs/open_options.rs.html#91-93" title="goto source code">[src]</a></h4><div class="docblock"><p>Creates a blank new set of options ready for configuration.</p>
|
||
<p>All options are initially set to <code>false</code>.</p>
|
||
<p>This is an async version of <a href="https://doc.rust-lang.org/nightly/std/fs/struct.OpenOptions.html#method.new"><code>std::fs::OpenOptions::new</code></a></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">OpenOptions</span>;
|
||
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">options</span> <span class="op">=</span> <span class="ident">OpenOptions</span>::<span class="ident">new</span>();
|
||
<span class="kw">let</span> <span class="ident">future</span> <span class="op">=</span> <span class="ident">options</span>.<span class="ident">read</span>(<span class="bool-val">true</span>).<span class="ident">open</span>(<span class="string">"foo.txt"</span>);</pre></div>
|
||
</div><h4 id="method.read" class="method"><code>pub fn <a href="#method.read" class="fnname">read</a>(&mut self, read: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>) -> &mut <a class="struct" href="../../tokio/fs/struct.OpenOptions.html" title="struct tokio::fs::OpenOptions">OpenOptions</a></code><a class="srclink" href="../../src/tokio/fs/open_options.rs.html#120-123" title="goto source code">[src]</a></h4><div class="docblock"><p>Sets the option for read access.</p>
|
||
<p>This option, when true, will indicate that the file should be
|
||
<code>read</code>-able if opened.</p>
|
||
<p>This is an async version of <a href="https://doc.rust-lang.org/nightly/std/fs/struct.OpenOptions.html#method.read"><code>std::fs::OpenOptions::read</code></a></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">OpenOptions</span>;
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>;
|
||
|
||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="ident">io</span>::<span class="prelude-ty">Result</span><span class="op"><</span>()<span class="op">></span> {
|
||
<span class="kw">let</span> <span class="ident">file</span> <span class="op">=</span> <span class="ident">OpenOptions</span>::<span class="ident">new</span>()
|
||
.<span class="ident">read</span>(<span class="bool-val">true</span>)
|
||
.<span class="ident">open</span>(<span class="string">"foo.txt"</span>)
|
||
.<span class="kw">await</span><span class="question-mark">?</span>;
|
||
|
||
<span class="prelude-val">Ok</span>(())
|
||
}</pre></div>
|
||
</div><h4 id="method.write" class="method"><code>pub fn <a href="#method.write" class="fnname">write</a>(&mut self, write: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>) -> &mut <a class="struct" href="../../tokio/fs/struct.OpenOptions.html" title="struct tokio::fs::OpenOptions">OpenOptions</a></code><a class="srclink" href="../../src/tokio/fs/open_options.rs.html#150-153" title="goto source code">[src]</a></h4><div class="docblock"><p>Sets the option for write access.</p>
|
||
<p>This option, when true, will indicate that the file should be
|
||
<code>write</code>-able if opened.</p>
|
||
<p>This is an async version of <a href="https://doc.rust-lang.org/nightly/std/fs/struct.OpenOptions.html#method.write"><code>std::fs::OpenOptions::write</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="kw">use</span> <span class="ident">tokio</span>::<span class="ident">fs</span>::<span class="ident">OpenOptions</span>;
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>;
|
||
|
||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="ident">io</span>::<span class="prelude-ty">Result</span><span class="op"><</span>()<span class="op">></span> {
|
||
<span class="kw">let</span> <span class="ident">file</span> <span class="op">=</span> <span class="ident">OpenOptions</span>::<span class="ident">new</span>()
|
||
.<span class="ident">write</span>(<span class="bool-val">true</span>)
|
||
.<span class="ident">open</span>(<span class="string">"foo.txt"</span>)
|
||
.<span class="kw">await</span><span class="question-mark">?</span>;
|
||
|
||
<span class="prelude-val">Ok</span>(())
|
||
}</pre></div>
|
||
</div><h4 id="method.append" class="method"><code>pub fn <a href="#method.append" class="fnname">append</a>(&mut self, append: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>) -> &mut <a class="struct" href="../../tokio/fs/struct.OpenOptions.html" title="struct tokio::fs::OpenOptions">OpenOptions</a></code><a class="srclink" href="../../src/tokio/fs/open_options.rs.html#209-212" title="goto source code">[src]</a></h4><div class="docblock"><p>Sets the option for the append mode.</p>
|
||
<p>This option, when true, means that writes will append to a file instead
|
||
of overwriting previous contents. Note that setting
|
||
<code>.write(true).append(true)</code> has the same effect as setting only
|
||
<code>.append(true)</code>.</p>
|
||
<p>For most filesystems, the operating system guarantees that all writes are
|
||
atomic: no writes get mangled because another process writes at the same
|
||
time.</p>
|
||
<p>One maybe obvious note when using append-mode: make sure that all data
|
||
that belongs together is written to the file in one operation. This
|
||
can be done by concatenating strings before passing them to <a href="../../tokio/io/trait.AsyncWriteExt.html#method.write"><code>write()</code></a>,
|
||
or using a buffered writer (with a buffer of adequate size),
|
||
and calling <a href="../../tokio/io/trait.AsyncWriteExt.html#method.flush"><code>flush()</code></a> when the message is complete.</p>
|
||
<p>If a file is opened with both read and append access, beware that after
|
||
opening, and after every write, the position for reading may be set at the
|
||
end of the file. So, before writing, save the current position (using
|
||
<a href="../../tokio/io/trait.AsyncSeekExt.html#method.seek"><code>seek</code></a><code>(</code><a href="https://doc.rust-lang.org/nightly/std/io/enum.SeekFrom.html"><code>SeekFrom</code></a><code>::</code><a href="https://doc.rust-lang.org/nightly/std/io/enum.SeekFrom.html#variant.Current"><code>Current</code></a><code>(0))</code>), and restore it before the next read.</p>
|
||
<p>This is an async version of <a href="https://doc.rust-lang.org/nightly/std/fs/struct.OpenOptions.html#method.append"><code>std::fs::OpenOptions::append</code></a></p>
|
||
<h2 id="note" class="section-header"><a href="#note">Note</a></h2>
|
||
<p>This function doesn't create the file if it doesn't exist. Use the <a href="../../tokio/fs/struct.OpenOptions.html#method.create"><code>create</code></a>
|
||
method to do so.</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">OpenOptions</span>;
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>;
|
||
|
||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="ident">io</span>::<span class="prelude-ty">Result</span><span class="op"><</span>()<span class="op">></span> {
|
||
<span class="kw">let</span> <span class="ident">file</span> <span class="op">=</span> <span class="ident">OpenOptions</span>::<span class="ident">new</span>()
|
||
.<span class="ident">append</span>(<span class="bool-val">true</span>)
|
||
.<span class="ident">open</span>(<span class="string">"foo.txt"</span>)
|
||
.<span class="kw">await</span><span class="question-mark">?</span>;
|
||
|
||
<span class="prelude-val">Ok</span>(())
|
||
}</pre></div>
|
||
</div><h4 id="method.truncate" class="method"><code>pub fn <a href="#method.truncate" class="fnname">truncate</a>(&mut self, truncate: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>) -> &mut <a class="struct" href="../../tokio/fs/struct.OpenOptions.html" title="struct tokio::fs::OpenOptions">OpenOptions</a></code><a class="srclink" href="../../src/tokio/fs/open_options.rs.html#242-245" title="goto source code">[src]</a></h4><div class="docblock"><p>Sets the option for truncating a previous file.</p>
|
||
<p>If a file is successfully opened with this option set it will truncate
|
||
the file to 0 length if it already exists.</p>
|
||
<p>The file must be opened with write access for truncate to work.</p>
|
||
<p>This is an async version of <a href="https://doc.rust-lang.org/nightly/std/fs/struct.OpenOptions.html#method.truncate"><code>std::fs::OpenOptions::truncate</code></a></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">OpenOptions</span>;
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>;
|
||
|
||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="ident">io</span>::<span class="prelude-ty">Result</span><span class="op"><</span>()<span class="op">></span> {
|
||
<span class="kw">let</span> <span class="ident">file</span> <span class="op">=</span> <span class="ident">OpenOptions</span>::<span class="ident">new</span>()
|
||
.<span class="ident">write</span>(<span class="bool-val">true</span>)
|
||
.<span class="ident">truncate</span>(<span class="bool-val">true</span>)
|
||
.<span class="ident">open</span>(<span class="string">"foo.txt"</span>)
|
||
.<span class="kw">await</span><span class="question-mark">?</span>;
|
||
|
||
<span class="prelude-val">Ok</span>(())
|
||
}</pre></div>
|
||
</div><h4 id="method.create" class="method"><code>pub fn <a href="#method.create" class="fnname">create</a>(&mut self, create: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>) -> &mut <a class="struct" href="../../tokio/fs/struct.OpenOptions.html" title="struct tokio::fs::OpenOptions">OpenOptions</a></code><a class="srclink" href="../../src/tokio/fs/open_options.rs.html#278-281" title="goto source code">[src]</a></h4><div class="docblock"><p>Sets the option for creating a new file.</p>
|
||
<p>This option indicates whether a new file will be created if the file
|
||
does not yet already exist.</p>
|
||
<p>In order for the file to be created, <a href="../../tokio/fs/struct.OpenOptions.html#method.write"><code>write</code></a> or <a href="../../tokio/fs/struct.OpenOptions.html#method.append"><code>append</code></a> access must
|
||
be used.</p>
|
||
<p>This is an async version of <a href="https://doc.rust-lang.org/nightly/std/fs/struct.OpenOptions.html#method.create"><code>std::fs::OpenOptions::create</code></a></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">OpenOptions</span>;
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>;
|
||
|
||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="ident">io</span>::<span class="prelude-ty">Result</span><span class="op"><</span>()<span class="op">></span> {
|
||
<span class="kw">let</span> <span class="ident">file</span> <span class="op">=</span> <span class="ident">OpenOptions</span>::<span class="ident">new</span>()
|
||
.<span class="ident">write</span>(<span class="bool-val">true</span>)
|
||
.<span class="ident">create</span>(<span class="bool-val">true</span>)
|
||
.<span class="ident">open</span>(<span class="string">"foo.txt"</span>)
|
||
.<span class="kw">await</span><span class="question-mark">?</span>;
|
||
|
||
<span class="prelude-val">Ok</span>(())
|
||
}</pre></div>
|
||
</div><h4 id="method.create_new" class="method"><code>pub fn <a href="#method.create_new" class="fnname">create_new</a>(&mut self, create_new: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>) -> &mut <a class="struct" href="../../tokio/fs/struct.OpenOptions.html" title="struct tokio::fs::OpenOptions">OpenOptions</a></code><a class="srclink" href="../../src/tokio/fs/open_options.rs.html#321-324" title="goto source code">[src]</a></h4><div class="docblock"><p>Sets the option to always create a new file.</p>
|
||
<p>This option indicates whether a new file will be created. No file is
|
||
allowed to exist at the target location, also no (dangling) symlink.</p>
|
||
<p>This option is useful because it is atomic. Otherwise between checking
|
||
whether a file exists and creating a new one, the file may have been
|
||
created by another process (a TOCTOU race condition / attack).</p>
|
||
<p>If <code>.create_new(true)</code> is set, <a href="../../tokio/fs/struct.OpenOptions.html#method.create"><code>.create()</code></a> and <a href="../../tokio/fs/struct.OpenOptions.html#method.truncate"><code>.truncate()</code></a> are
|
||
ignored.</p>
|
||
<p>The file must be opened with write or append access in order to create a
|
||
new file.</p>
|
||
<p>This is an async version of <a href="https://doc.rust-lang.org/nightly/std/fs/struct.OpenOptions.html#method.create_new"><code>std::fs::OpenOptions::create_new</code></a></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">OpenOptions</span>;
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>;
|
||
|
||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="ident">io</span>::<span class="prelude-ty">Result</span><span class="op"><</span>()<span class="op">></span> {
|
||
<span class="kw">let</span> <span class="ident">file</span> <span class="op">=</span> <span class="ident">OpenOptions</span>::<span class="ident">new</span>()
|
||
.<span class="ident">write</span>(<span class="bool-val">true</span>)
|
||
.<span class="ident">create_new</span>(<span class="bool-val">true</span>)
|
||
.<span class="ident">open</span>(<span class="string">"foo.txt"</span>)
|
||
.<span class="kw">await</span><span class="question-mark">?</span>;
|
||
|
||
<span class="prelude-val">Ok</span>(())
|
||
}</pre></div>
|
||
</div><h4 id="method.open" class="method"><code>pub async fn <a href="#method.open" class="fnname">open</a>(&self, 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/open_options.rs.html#378-384" title="goto source code">[src]</a></h4><div class="docblock"><p>Opens a file at <code>path</code> with the options specified by <code>self</code>.</p>
|
||
<p>This is an async version of <a href="https://doc.rust-lang.org/nightly/std/fs/struct.OpenOptions.html#method.open"><code>std::fs::OpenOptions::open</code></a></p>
|
||
<h1 id="errors" class="section-header"><a href="#errors">Errors</a></h1>
|
||
<p>This function will return an error under a number of different
|
||
circumstances. Some of these error conditions are listed here, together
|
||
with their <a href="https://doc.rust-lang.org/nightly/std/io/error/enum.ErrorKind.html"><code>ErrorKind</code></a>. The mapping to <a href="https://doc.rust-lang.org/nightly/std/io/error/enum.ErrorKind.html"><code>ErrorKind</code></a>s is not part of
|
||
the compatibility contract of the function, especially the <code>Other</code> kind
|
||
might change to more specific kinds in the future.</p>
|
||
<ul>
|
||
<li><a href="https://doc.rust-lang.org/nightly/std/io/error/enum.ErrorKind.html#variant.NotFound"><code>NotFound</code></a>: The specified file does not exist and neither <code>create</code>
|
||
or <code>create_new</code> is set.</li>
|
||
<li><a href="https://doc.rust-lang.org/nightly/std/io/error/enum.ErrorKind.html#variant.NotFound"><code>NotFound</code></a>: One of the directory components of the file path does
|
||
not exist.</li>
|
||
<li><a href="https://doc.rust-lang.org/nightly/std/io/error/enum.ErrorKind.html#variant.PermissionDenied"><code>PermissionDenied</code></a>: The user lacks permission to get the specified
|
||
access rights for the file.</li>
|
||
<li><a href="https://doc.rust-lang.org/nightly/std/io/error/enum.ErrorKind.html#variant.PermissionDenied"><code>PermissionDenied</code></a>: The user lacks permission to open one of the
|
||
directory components of the specified path.</li>
|
||
<li><a href="https://doc.rust-lang.org/nightly/std/io/error/enum.ErrorKind.html#variant.AlreadyExists"><code>AlreadyExists</code></a>: <code>create_new</code> was specified and the file already
|
||
exists.</li>
|
||
<li><a href="https://doc.rust-lang.org/nightly/std/io/error/enum.ErrorKind.html#variant.InvalidInput"><code>InvalidInput</code></a>: Invalid combinations of open options (truncate
|
||
without write access, no access mode set, etc.).</li>
|
||
<li><a href="https://doc.rust-lang.org/nightly/std/io/error/enum.ErrorKind.html#variant.Other"><code>Other</code></a>: One of the directory components of the specified file path
|
||
was not, in fact, a directory.</li>
|
||
<li><a href="https://doc.rust-lang.org/nightly/std/io/error/enum.ErrorKind.html#variant.Other"><code>Other</code></a>: Filesystem-level errors: full disk, write permission
|
||
requested on a read-only file system, exceeded disk quota, too many
|
||
open files, too long filename, too many symbolic links in the
|
||
specified path (Unix-like systems only), etc.</li>
|
||
</ul>
|
||
<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">OpenOptions</span>;
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>;
|
||
|
||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="ident">io</span>::<span class="prelude-ty">Result</span><span class="op"><</span>()<span class="op">></span> {
|
||
<span class="kw">let</span> <span class="ident">file</span> <span class="op">=</span> <span class="ident">OpenOptions</span>::<span class="ident">new</span>().<span class="ident">open</span>(<span class="string">"foo.txt"</span>).<span class="kw">await</span><span class="question-mark">?</span>;
|
||
<span class="prelude-val">Ok</span>(())
|
||
}</pre></div>
|
||
</div></div><h3 id="impl-1" class="impl"><code class="in-band">impl <a class="struct" href="../../tokio/fs/struct.OpenOptions.html" title="struct tokio::fs::OpenOptions">OpenOptions</a></code><a href="#impl-1" class="anchor"></a><a class="srclink" href="../../src/tokio/fs/open_options.rs.html#397-457" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.mode" class="method"><code>pub fn <a href="#method.mode" class="fnname">mode</a>(&mut self, mode: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>) -> &mut <a class="struct" href="../../tokio/fs/struct.OpenOptions.html" title="struct tokio::fs::OpenOptions">OpenOptions</a></code><a class="srclink" href="../../src/tokio/fs/open_options.rs.html#421-424" title="goto source code">[src]</a></h4><div class="docblock"><p>Sets the mode bits that a new file will be created with.</p>
|
||
<p>If a new file is created as part of an <code>OpenOptions::open</code> call then this
|
||
specified <code>mode</code> will be used as the permission bits for the new file.
|
||
If no <code>mode</code> is set, the default of <code>0o666</code> will be used.
|
||
The operating system masks out bits with the system's <code>umask</code>, to produce
|
||
the final permissions.</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">OpenOptions</span>;
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>;
|
||
|
||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="ident">io</span>::<span class="prelude-ty">Result</span><span class="op"><</span>()<span class="op">></span> {
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">options</span> <span class="op">=</span> <span class="ident">OpenOptions</span>::<span class="ident">new</span>();
|
||
<span class="ident">options</span>.<span class="ident">mode</span>(<span class="number">0o644</span>); <span class="comment">// Give read/write for owner and read for others.</span>
|
||
<span class="kw">let</span> <span class="ident">file</span> <span class="op">=</span> <span class="ident">options</span>.<span class="ident">open</span>(<span class="string">"foo.txt"</span>).<span class="kw">await</span><span class="question-mark">?</span>;
|
||
|
||
<span class="prelude-val">Ok</span>(())
|
||
}</pre></div>
|
||
</div><h4 id="method.custom_flags" class="method"><code>pub fn <a href="#method.custom_flags" class="fnname">custom_flags</a>(&mut self, flags: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a>) -> &mut <a class="struct" href="../../tokio/fs/struct.OpenOptions.html" title="struct tokio::fs::OpenOptions">OpenOptions</a></code><a class="srclink" href="../../src/tokio/fs/open_options.rs.html#453-456" title="goto source code">[src]</a></h4><div class="docblock"><p>Pass custom flags to the <code>flags</code> argument of <code>open</code>.</p>
|
||
<p>The bits that define the access mode are masked out with <code>O_ACCMODE</code>, to
|
||
ensure they do not interfere with the access mode set by Rusts options.</p>
|
||
<p>Custom flags can only set flags, not remove flags set by Rusts options.
|
||
This options overwrites any previously set custom flags.</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">libc</span>;
|
||
<span class="kw">use</span> <span class="ident">tokio</span>::<span class="ident">fs</span>::<span class="ident">OpenOptions</span>;
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>;
|
||
|
||
<span class="attribute">#[<span class="ident">tokio</span>::<span class="ident">main</span>]</span>
|
||
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">main</span>() <span class="op">-</span><span class="op">></span> <span class="ident">io</span>::<span class="prelude-ty">Result</span><span class="op"><</span>()<span class="op">></span> {
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">options</span> <span class="op">=</span> <span class="ident">OpenOptions</span>::<span class="ident">new</span>();
|
||
<span class="ident">options</span>.<span class="ident">write</span>(<span class="bool-val">true</span>);
|
||
<span class="kw">if</span> <span class="macro">cfg</span><span class="macro">!</span>(<span class="ident">unix</span>) {
|
||
<span class="ident">options</span>.<span class="ident">custom_flags</span>(<span class="ident">libc</span>::<span class="ident">O_NOFOLLOW</span>);
|
||
}
|
||
<span class="kw">let</span> <span class="ident">file</span> <span class="op">=</span> <span class="ident">options</span>.<span class="ident">open</span>(<span class="string">"foo.txt"</span>).<span class="kw">await</span><span class="question-mark">?</span>;
|
||
|
||
<span class="prelude-val">Ok</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-Clone" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> for <a class="struct" href="../../tokio/fs/struct.OpenOptions.html" title="struct tokio::fs::OpenOptions">OpenOptions</a></code><a href="#impl-Clone" class="anchor"></a><a class="srclink" href="../../src/tokio/fs/open_options.rs.html#71" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.clone" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#tymethod.clone" class="fnname">clone</a>(&self) -> <a class="struct" href="../../tokio/fs/struct.OpenOptions.html" title="struct tokio::fs::OpenOptions">OpenOptions</a></code><a class="srclink" href="../../src/tokio/fs/open_options.rs.html#71" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Returns a copy of the value. <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#tymethod.clone">Read more</a></p>
|
||
</div><h4 id="method.clone_from" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#method.clone_from" class="fnname">clone_from</a>(&mut self, source: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>Self)</code><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/clone.rs.html#128-130" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs copy-assignment from <code>source</code>. <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#method.clone_from">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.OpenOptions.html" title="struct tokio::fs::OpenOptions">OpenOptions</a></code><a href="#impl-Debug" class="anchor"></a><a class="srclink" href="../../src/tokio/fs/open_options.rs.html#71" 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, f: &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/open_options.rs.html#71" 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-Default" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/default/trait.Default.html" title="trait core::default::Default">Default</a> for <a class="struct" href="../../tokio/fs/struct.OpenOptions.html" title="struct tokio::fs::OpenOptions">OpenOptions</a></code><a href="#impl-Default" class="anchor"></a><a class="srclink" href="../../src/tokio/fs/open_options.rs.html#654-658" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.default" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/default/trait.Default.html#tymethod.default" class="fnname">default</a>() -> Self</code><a class="srclink" href="../../src/tokio/fs/open_options.rs.html#655-657" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Returns the "default value" for a type. <a href="https://doc.rust-lang.org/nightly/core/default/trait.Default.html#tymethod.default">Read more</a></p>
|
||
</div></div><h3 id="impl-From%3COpenOptions%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.OpenOptions.html" title="struct std::fs::OpenOptions">OpenOptions</a>> for <a class="struct" href="../../tokio/fs/struct.OpenOptions.html" title="struct tokio::fs::OpenOptions">OpenOptions</a></code><a href="#impl-From%3COpenOptions%3E" class="anchor"></a><a class="srclink" href="../../src/tokio/fs/open_options.rs.html#648-652" 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>(options: <a class="struct" href="https://doc.rust-lang.org/nightly/std/fs/struct.OpenOptions.html" title="struct std::fs::OpenOptions">OpenOptions</a>) -> <a class="struct" href="../../tokio/fs/struct.OpenOptions.html" title="struct tokio::fs::OpenOptions">OpenOptions</a></code><a class="srclink" href="../../src/tokio/fs/open_options.rs.html#649-651" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</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.OpenOptions.html" title="struct tokio::fs::OpenOptions">OpenOptions</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.OpenOptions.html" title="struct tokio::fs::OpenOptions">OpenOptions</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.OpenOptions.html" title="struct tokio::fs::OpenOptions">OpenOptions</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.OpenOptions.html" title="struct tokio::fs::OpenOptions">OpenOptions</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.OpenOptions.html" title="struct tokio::fs::OpenOptions">OpenOptions</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#108-112" 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#109-111" 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#210-214" 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#211-213" 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#217-221" 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#218-220" 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#552-556" 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#553-555" 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#541-548" 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#545-547" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||
</div></div><h3 id="impl-ToOwned" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html" title="trait alloc::borrow::ToOwned">ToOwned</a> for T <span class="where fmt-newline">where<br> T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>, </span></code><a href="#impl-ToOwned" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/alloc/borrow.rs.html#80-92" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Owned" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html#associatedtype.Owned" class="type">Owned</a> = T</code></h4><div class='docblock'><p>The resulting type after obtaining ownership.</p>
|
||
</div><h4 id="method.to_owned" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html#tymethod.to_owned" class="fnname">to_owned</a>(&self) -> T</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/alloc/borrow.rs.html#85-87" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Creates owned data from borrowed data, usually by cloning. <a href="https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html#tymethod.to_owned">Read more</a></p>
|
||
</div><h4 id="method.clone_into" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html#method.clone_into" class="fnname">clone_into</a>(&self, target: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>T)</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/alloc/borrow.rs.html#89-91" title="goto source code">[src]</a></h4><div class="item-info hidden"><div class="stab unstable"><details><summary><span class="emoji">🔬</span> This is a nightly-only experimental API. (<code>toowned_clone_into</code>)</summary><p>recently added</p>
|
||
</details></div></div><div class='docblock hidden'><p>Uses borrowed data to replace owned data, usually by cloning. <a href="https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html#method.clone_into">Read more</a></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#589-598" 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#595-597" 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#575-584" 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#581-583" 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><script>window.rootPath = "../../";window.currentCrate = "tokio";</script><script src="../../main.js"></script><script defer src="../../search-index.js"></script></body></html> |