mpvrc/tempfile/struct.Builder.html

271 lines
No EOL
61 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="Create a new temporary file or directory with custom parameters."><title>Builder in tempfile - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="tempfile" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-893ab5e7.css"></noscript><link rel="icon" href="https://www.rust-lang.org/favicon.ico"></head><body class="rustdoc struct"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button><a class="logo-container" href="../tempfile/index.html"><img src="https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png" alt=""></a></nav><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../tempfile/index.html"><img src="https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png" alt="logo"></a><h2><a href="../tempfile/index.html">tempfile</a><span class="version">3.14.0</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Builder</a></h2><h3><a href="#implementations">Methods</a></h3><ul class="block method"><li><a href="#method.append" title="append">append</a></li><li><a href="#method.keep" title="keep">keep</a></li><li><a href="#method.make" title="make">make</a></li><li><a href="#method.make_in" title="make_in">make_in</a></li><li><a href="#method.new" title="new">new</a></li><li><a href="#method.permissions" title="permissions">permissions</a></li><li><a href="#method.prefix" title="prefix">prefix</a></li><li><a href="#method.rand_bytes" title="rand_bytes">rand_bytes</a></li><li><a href="#method.suffix" title="suffix">suffix</a></li><li><a href="#method.tempdir" title="tempdir">tempdir</a></li><li><a href="#method.tempdir_in" title="tempdir_in">tempdir_in</a></li><li><a href="#method.tempfile" title="tempfile">tempfile</a></li><li><a href="#method.tempfile_in" title="tempfile_in">tempfile_in</a></li></ul><h3><a href="#trait-implementations">Trait Implementations</a></h3><ul class="block trait-implementation"><li><a href="#impl-Clone-for-Builder%3C'a,+'b%3E" title="Clone">Clone</a></li><li><a href="#impl-Debug-for-Builder%3C'a,+'b%3E" title="Debug">Debug</a></li><li><a href="#impl-Default-for-Builder%3C'a,+'b%3E" title="Default">Default</a></li><li><a href="#impl-Eq-for-Builder%3C'a,+'b%3E" title="Eq">Eq</a></li><li><a href="#impl-PartialEq-for-Builder%3C'a,+'b%3E" title="PartialEq">PartialEq</a></li><li><a href="#impl-StructuralPartialEq-for-Builder%3C'a,+'b%3E" title="StructuralPartialEq">StructuralPartialEq</a></li></ul><h3><a href="#synthetic-implementations">Auto Trait Implementations</a></h3><ul class="block synthetic-implementation"><li><a href="#impl-Freeze-for-Builder%3C'a,+'b%3E" title="Freeze">Freeze</a></li><li><a href="#impl-RefUnwindSafe-for-Builder%3C'a,+'b%3E" title="RefUnwindSafe">RefUnwindSafe</a></li><li><a href="#impl-Send-for-Builder%3C'a,+'b%3E" title="Send">Send</a></li><li><a href="#impl-Sync-for-Builder%3C'a,+'b%3E" title="Sync">Sync</a></li><li><a href="#impl-Unpin-for-Builder%3C'a,+'b%3E" title="Unpin">Unpin</a></li><li><a href="#impl-UnwindSafe-for-Builder%3C'a,+'b%3E" title="UnwindSafe">UnwindSafe</a></li></ul><h3><a href="#blanket-implementations">Blanket Implementations</a></h3><ul class="block blanket-implementation"><li><a href="#impl-Any-for-T" title="Any">Any</a></li><li><a href="#impl-Borrow%3CT%3E-for-T" title="Borrow&#60;T&#62;">Borrow&#60;T&#62;</a></li><li><a href="#impl-BorrowMut%3CT%3E-for-T" title="BorrowMut&#60;T&#62;">BorrowMut&#60;T&#62;</a></li><li><a href="#impl-CloneToUninit-for-T" title="CloneToUninit">CloneToUninit</a></li><li><a href="#impl-From%3CT%3E-for-T" title="From&#60;T&#62;">From&#60;T&#62;</a></li><li><a href="#impl-Into%3CU%3E-for-T" title="Into&#60;U&#62;">Into&#60;U&#62;</a></li><li><a href="#impl-ToOwned-for-T" title="ToOwned">ToOwned</a></li><li><a href="#impl-TryFrom%3CU%3E-for-T" title="TryFrom&#60;U&#62;">TryFrom&#60;U&#62;</a></li><li><a href="#impl-TryInto%3CU%3E-for-T" title="TryInto&#60;U&#62;">TryInto&#60;U&#62;</a></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="index.html">In crate tempfile</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="index.html">tempfile</a></span><h1>Struct <span class="struct">Builder</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/tempfile/lib.rs.html#174-181">Source</a> </span></div><pre class="rust item-decl"><code>pub struct Builder&lt;'a, 'b&gt; { <span class="comment">/* private fields */</span> }</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Create a new temporary file or directory with custom parameters.</p>
</div></details><h2 id="implementations" class="section-header">Implementations<a href="#implementations" class="anchor">§</a></h2><div id="implementations-list"><details class="toggle implementors-toggle" open><summary><section id="impl-Builder%3C'a,+'b%3E" class="impl"><a class="src rightside" href="../src/tempfile/lib.rs.html#196-698">Source</a><a href="#impl-Builder%3C'a,+'b%3E" class="anchor">§</a><h3 class="code-header">impl&lt;'a, 'b&gt; <a class="struct" href="struct.Builder.html" title="struct tempfile::Builder">Builder</a>&lt;'a, 'b&gt;</h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.new" class="method"><a class="src rightside" href="../src/tempfile/lib.rs.html#263-265">Source</a><h4 class="code-header">pub fn <a href="#method.new" class="fn">new</a>() -&gt; Self</h4></section></summary><div class="docblock"><p>Create a new <code>Builder</code>.</p>
<h5 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h5>
<p>Create a named temporary file and write some data into it:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::ffi::OsStr;
<span class="kw">use </span>tempfile::Builder;
<span class="kw">let </span>named_tempfile = Builder::new()
.prefix(<span class="string">"my-temporary-note"</span>)
.suffix(<span class="string">".txt"</span>)
.rand_bytes(<span class="number">5</span>)
.tempfile()<span class="question-mark">?</span>;
<span class="kw">let </span>name = named_tempfile
.path()
.file_name().and_then(OsStr::to_str);
<span class="kw">if let </span><span class="prelude-val">Some</span>(name) = name {
<span class="macro">assert!</span>(name.starts_with(<span class="string">"my-temporary-note"</span>));
<span class="macro">assert!</span>(name.ends_with(<span class="string">".txt"</span>));
<span class="macro">assert_eq!</span>(name.len(), <span class="string">"my-temporary-note.txt"</span>.len() + <span class="number">5</span>);
}</code></pre></div>
<p>Create a temporary directory and add a file to it:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::io::Write;
<span class="kw">use </span>std::fs::File;
<span class="kw">use </span>std::ffi::OsStr;
<span class="kw">use </span>tempfile::Builder;
<span class="kw">let </span>dir = Builder::new()
.prefix(<span class="string">"my-temporary-dir"</span>)
.rand_bytes(<span class="number">5</span>)
.tempdir()<span class="question-mark">?</span>;
<span class="kw">let </span>file_path = dir.path().join(<span class="string">"my-temporary-note.txt"</span>);
<span class="kw">let </span><span class="kw-2">mut </span>file = File::create(file_path)<span class="question-mark">?</span>;
<span class="macro">writeln!</span>(file, <span class="string">"Brian was here. Briefly."</span>)<span class="question-mark">?</span>;
<span class="comment">// By closing the `TempDir` explicitly, we can check that it has
// been deleted successfully. If we don't close it explicitly,
// the directory will still be deleted when `dir` goes out
// of scope, but we won't know whether deleting the directory
// succeeded.
</span>drop(file);
dir.close()<span class="question-mark">?</span>;</code></pre></div>
<p>Create a temporary directory with a chosen prefix under a chosen folder:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tempfile::Builder;
<span class="kw">let </span>dir = Builder::new()
.prefix(<span class="string">"my-temporary-dir"</span>)
.tempdir_in(<span class="string">"folder-with-tempdirs"</span>)<span class="question-mark">?</span>;</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.prefix" class="method"><a class="src rightside" href="../src/tempfile/lib.rs.html#282-285">Source</a><h4 class="code-header">pub fn <a href="#method.prefix" class="fn">prefix</a>&lt;S: <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a>&lt;<a class="struct" href="https://doc.rust-lang.org/1.84.1/std/ffi/os_str/struct.OsStr.html" title="struct std::ffi::os_str::OsStr">OsStr</a>&gt; + ?<a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>&gt;(&amp;mut self, prefix: <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.reference.html">&amp;'a S</a>) -&gt; &amp;mut Self</h4></section></summary><div class="docblock"><p>Set a custom filename prefix.</p>
<p>Path separators are legal but not advisable.
Default: <code>.tmp</code>.</p>
<h5 id="examples-1"><a class="doc-anchor" href="#examples-1">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tempfile::Builder;
<span class="kw">let </span>named_tempfile = Builder::new()
.prefix(<span class="string">"my-temporary-note"</span>)
.tempfile()<span class="question-mark">?</span>;</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.suffix" class="method"><a class="src rightside" href="../src/tempfile/lib.rs.html#302-305">Source</a><h4 class="code-header">pub fn <a href="#method.suffix" class="fn">suffix</a>&lt;S: <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a>&lt;<a class="struct" href="https://doc.rust-lang.org/1.84.1/std/ffi/os_str/struct.OsStr.html" title="struct std::ffi::os_str::OsStr">OsStr</a>&gt; + ?<a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>&gt;(&amp;mut self, suffix: <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.reference.html">&amp;'b S</a>) -&gt; &amp;mut Self</h4></section></summary><div class="docblock"><p>Set a custom filename suffix.</p>
<p>Path separators are legal but not advisable.
Default: empty.</p>
<h5 id="examples-2"><a class="doc-anchor" href="#examples-2">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tempfile::Builder;
<span class="kw">let </span>named_tempfile = Builder::new()
.suffix(<span class="string">".txt"</span>)
.tempfile()<span class="question-mark">?</span>;</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.rand_bytes" class="method"><a class="src rightside" href="../src/tempfile/lib.rs.html#321-324">Source</a><h4 class="code-header">pub fn <a href="#method.rand_bytes" class="fn">rand_bytes</a>(&amp;mut self, rand: <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.usize.html">usize</a>) -&gt; &amp;mut Self</h4></section></summary><div class="docblock"><p>Set the number of random bytes.</p>
<p>Default: <code>6</code>.</p>
<h5 id="examples-3"><a class="doc-anchor" href="#examples-3">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tempfile::Builder;
<span class="kw">let </span>named_tempfile = Builder::new()
.rand_bytes(<span class="number">5</span>)
.tempfile()<span class="question-mark">?</span>;</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.append" class="method"><a class="src rightside" href="../src/tempfile/lib.rs.html#340-343">Source</a><h4 class="code-header">pub fn <a href="#method.append" class="fn">append</a>(&amp;mut self, append: <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.bool.html">bool</a>) -&gt; &amp;mut Self</h4></section></summary><div class="docblock"><p>Set the file to be opened in append mode.</p>
<p>Default: <code>false</code>.</p>
<h5 id="examples-4"><a class="doc-anchor" href="#examples-4">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tempfile::Builder;
<span class="kw">let </span>named_tempfile = Builder::new()
.append(<span class="bool-val">true</span>)
.tempfile()<span class="question-mark">?</span>;</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.permissions" class="method"><a class="src rightside" href="../src/tempfile/lib.rs.html#412-415">Source</a><h4 class="code-header">pub fn <a href="#method.permissions" class="fn">permissions</a>(&amp;mut self, permissions: <a class="struct" href="https://doc.rust-lang.org/1.84.1/std/fs/struct.Permissions.html" title="struct std::fs::Permissions">Permissions</a>) -&gt; &amp;mut Self</h4></section></summary><div class="docblock"><p>The permissions to create the tempfile or <a href="struct.Builder.html#method.tempdir" title="method tempfile::Builder::tempdir">tempdir</a> with.</p>
<h5 id="security"><a class="doc-anchor" href="#security">§</a>Security</h5>
<p>By default, the permissions of tempfiles on unix are set for it to be
readable and writable by the owner only, yielding the greatest amount
of security.
As this method allows to widen the permissions, security would be
reduced in such cases.</p>
<h5 id="platform-notes"><a class="doc-anchor" href="#platform-notes">§</a>Platform Notes</h5><h6 id="unix"><a class="doc-anchor" href="#unix">§</a>Unix</h6>
<p>The actual permission bits set on the tempfile or tempdir will be affected by the <code>umask</code>
applied by the underlying syscall. The actual permission bits are calculated via
<code>permissions &amp; !umask</code>.</p>
<p>Permissions default to <code>0o600</code> for tempfiles and <code>0o777</code> for tempdirs. Note, this doesnt
include effects of the current <code>umask</code>. For example, combined with the standard umask
<code>0o022</code>, the defaults yield <code>0o600</code> for tempfiles and <code>0o755</code> for tempdirs.</p>
<h6 id="windows-and-others"><a class="doc-anchor" href="#windows-and-others">§</a>Windows and others</h6>
<p>This setting is unsupported and trying to set a file or directory read-only
will cause an error to be returned..</p>
<h5 id="examples-5"><a class="doc-anchor" href="#examples-5">§</a>Examples</h5>
<p>Create a named temporary file that is world-readable.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tempfile::Builder;
<span class="kw">use </span>std::os::unix::fs::PermissionsExt;
<span class="kw">let </span>all_read_write = std::fs::Permissions::from_mode(<span class="number">0o666</span>);
<span class="kw">let </span>tempfile = Builder::new().permissions(all_read_write).tempfile()<span class="question-mark">?</span>;
<span class="kw">let </span>actual_permissions = tempfile.path().metadata()<span class="question-mark">?</span>.permissions();
<span class="macro">assert_ne!</span>(
actual_permissions.mode() &amp; !<span class="number">0o170000</span>,
<span class="number">0o600</span>,
<span class="string">"we get broader permissions than the default despite umask"
</span>);</code></pre></div>
<p>Create a named temporary directory that is restricted to the owner.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tempfile::Builder;
<span class="kw">use </span>std::os::unix::fs::PermissionsExt;
<span class="kw">let </span>owner_rwx = std::fs::Permissions::from_mode(<span class="number">0o700</span>);
<span class="kw">let </span>tempdir = Builder::new().permissions(owner_rwx).tempdir()<span class="question-mark">?</span>;
<span class="kw">let </span>actual_permissions = tempdir.path().metadata()<span class="question-mark">?</span>.permissions();
<span class="macro">assert_eq!</span>(
actual_permissions.mode() &amp; !<span class="number">0o170000</span>,
<span class="number">0o700</span>,
<span class="string">"we get the narrow permissions we asked for"
</span>);</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.keep" class="method"><a class="src rightside" href="../src/tempfile/lib.rs.html#433-436">Source</a><h4 class="code-header">pub fn <a href="#method.keep" class="fn">keep</a>(&amp;mut self, keep: <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.bool.html">bool</a>) -&gt; &amp;mut Self</h4></section></summary><div class="docblock"><p>Set the file/folder to be kept even when the <a href="struct.NamedTempFile.html" title="struct tempfile::NamedTempFile"><code>NamedTempFile</code></a>/<a href="struct.TempDir.html" title="struct tempfile::TempDir"><code>TempDir</code></a> goes out of
scope.</p>
<p>By default, the file/folder is automatically cleaned up in the destructor of
<a href="struct.NamedTempFile.html" title="struct tempfile::NamedTempFile"><code>NamedTempFile</code></a>/<a href="struct.TempDir.html" title="struct tempfile::TempDir"><code>TempDir</code></a>. When <code>keep</code> is set to <code>true</code>, this behavior is supressed.</p>
<h5 id="examples-6"><a class="doc-anchor" href="#examples-6">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tempfile::Builder;
<span class="kw">let </span>named_tempfile = Builder::new()
.keep(<span class="bool-val">true</span>)
.tempfile()<span class="question-mark">?</span>;</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.tempfile" class="method"><a class="src rightside" href="../src/tempfile/lib.rs.html#463-465">Source</a><h4 class="code-header">pub fn <a href="#method.tempfile" class="fn">tempfile</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/1.84.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="struct" href="struct.NamedTempFile.html" title="struct tempfile::NamedTempFile">NamedTempFile</a>&gt;</h4></section></summary><div class="docblock"><p>Create the named temporary file.</p>
<h5 id="security-1"><a class="doc-anchor" href="#security-1">§</a>Security</h5>
<p>See <a href="struct.NamedTempFile.html#security">the security</a> docs on <code>NamedTempFile</code>.</p>
<h5 id="resource-leaking"><a class="doc-anchor" href="#resource-leaking">§</a>Resource leaking</h5>
<p>See <a href="struct.NamedTempFile.html#resource-leaking">the resource leaking</a> docs on <code>NamedTempFile</code>.</p>
<h5 id="errors"><a class="doc-anchor" href="#errors">§</a>Errors</h5>
<p>If the file cannot be created, <code>Err</code> is returned.</p>
<h5 id="examples-7"><a class="doc-anchor" href="#examples-7">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tempfile::Builder;
<span class="kw">let </span>tempfile = Builder::new().tempfile()<span class="question-mark">?</span>;</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.tempfile_in" class="method"><a class="src rightside" href="../src/tempfile/lib.rs.html#492-507">Source</a><h4 class="code-header">pub fn <a href="#method.tempfile_in" class="fn">tempfile_in</a>&lt;P: <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a>&lt;<a class="struct" href="https://doc.rust-lang.org/1.84.1/std/path/struct.Path.html" title="struct std::path::Path">Path</a>&gt;&gt;(&amp;self, dir: P) -&gt; <a class="type" href="https://doc.rust-lang.org/1.84.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="struct" href="struct.NamedTempFile.html" title="struct tempfile::NamedTempFile">NamedTempFile</a>&gt;</h4></section></summary><div class="docblock"><p>Create the named temporary file in the specified directory.</p>
<h5 id="security-2"><a class="doc-anchor" href="#security-2">§</a>Security</h5>
<p>See <a href="struct.NamedTempFile.html#security">the security</a> docs on <code>NamedTempFile</code>.</p>
<h5 id="resource-leaking-1"><a class="doc-anchor" href="#resource-leaking-1">§</a>Resource leaking</h5>
<p>See <a href="struct.NamedTempFile.html#resource-leaking">the resource leaking</a> docs on <code>NamedTempFile</code>.</p>
<h5 id="errors-1"><a class="doc-anchor" href="#errors-1">§</a>Errors</h5>
<p>If the file cannot be created, <code>Err</code> is returned.</p>
<h5 id="examples-8"><a class="doc-anchor" href="#examples-8">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tempfile::Builder;
<span class="kw">let </span>tempfile = Builder::new().tempfile_in(<span class="string">"./"</span>)<span class="question-mark">?</span>;</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.tempdir" class="method"><a class="src rightside" href="../src/tempfile/lib.rs.html#532-534">Source</a><h4 class="code-header">pub fn <a href="#method.tempdir" class="fn">tempdir</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/1.84.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="struct" href="struct.TempDir.html" title="struct tempfile::TempDir">TempDir</a>&gt;</h4></section></summary><div class="docblock"><p>Attempts to make a temporary directory inside of <a href="env/fn.temp_dir.html" title="fn tempfile::env::temp_dir"><code>env::temp_dir()</code></a> whose
name will have the prefix, <code>prefix</code>. The directory and
everything inside it will be automatically deleted once the
returned <code>TempDir</code> is destroyed.</p>
<h5 id="resource-leaking-2"><a class="doc-anchor" href="#resource-leaking-2">§</a>Resource leaking</h5>
<p>See <a href="struct.TempDir.html#resource-leaking">the resource leaking</a> docs on <code>TempDir</code>.</p>
<h5 id="errors-2"><a class="doc-anchor" href="#errors-2">§</a>Errors</h5>
<p>If the directory can not be created, <code>Err</code> is returned.</p>
<h5 id="examples-9"><a class="doc-anchor" href="#examples-9">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tempfile::Builder;
<span class="kw">let </span>tmp_dir = Builder::new().tempdir()<span class="question-mark">?</span>;</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.tempdir_in" class="method"><a class="src rightside" href="../src/tempfile/lib.rs.html#558-570">Source</a><h4 class="code-header">pub fn <a href="#method.tempdir_in" class="fn">tempdir_in</a>&lt;P: <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a>&lt;<a class="struct" href="https://doc.rust-lang.org/1.84.1/std/path/struct.Path.html" title="struct std::path::Path">Path</a>&gt;&gt;(&amp;self, dir: P) -&gt; <a class="type" href="https://doc.rust-lang.org/1.84.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="struct" href="struct.TempDir.html" title="struct tempfile::TempDir">TempDir</a>&gt;</h4></section></summary><div class="docblock"><p>Attempts to make a temporary directory inside of <code>dir</code>.
The directory and everything inside it will be automatically
deleted once the returned <code>TempDir</code> is destroyed.</p>
<h5 id="resource-leaking-3"><a class="doc-anchor" href="#resource-leaking-3">§</a>Resource leaking</h5>
<p>See <a href="struct.TempDir.html#resource-leaking">the resource leaking</a> docs on <code>TempDir</code>.</p>
<h5 id="errors-3"><a class="doc-anchor" href="#errors-3">§</a>Errors</h5>
<p>If the directory can not be created, <code>Err</code> is returned.</p>
<h5 id="examples-10"><a class="doc-anchor" href="#examples-10">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tempfile::Builder;
<span class="kw">let </span>tmp_dir = Builder::new().tempdir_in(<span class="string">"./"</span>)<span class="question-mark">?</span>;</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.make" class="method"><a class="src rightside" href="../src/tempfile/lib.rs.html#657-662">Source</a><h4 class="code-header">pub fn <a href="#method.make" class="fn">make</a>&lt;F, R&gt;(&amp;self, f: F) -&gt; <a class="type" href="https://doc.rust-lang.org/1.84.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="struct" href="struct.NamedTempFile.html" title="struct tempfile::NamedTempFile">NamedTempFile</a>&lt;R&gt;&gt;<div class="where">where
F: <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(&amp;<a class="struct" href="https://doc.rust-lang.org/1.84.1/std/path/struct.Path.html" title="struct std::path::Path">Path</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/1.84.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;R&gt;,</div></h4></section></summary><div class="docblock"><p>Attempts to create a temporary file (or file-like object) using the
provided closure. The closure is passed a temporary file path and
returns an <a href="https://doc.rust-lang.org/1.84.1/std/io/error/type.Result.html" title="type std::io::error::Result"><code>std::io::Result</code></a>. The path provided to the closure will be
inside of <a href="env/fn.temp_dir.html" title="fn tempfile::env::temp_dir"><code>env::temp_dir()</code></a>. Use <a href="struct.Builder.html#method.make_in" title="method tempfile::Builder::make_in"><code>Builder::make_in</code></a> to provide
a custom temporary directory. If the closure returns one of the
following errors, then another randomized file path is tried:</p>
<ul>
<li><a href="https://doc.rust-lang.org/1.84.1/std/io/error/enum.ErrorKind.html#variant.AlreadyExists" title="variant std::io::error::ErrorKind::AlreadyExists"><code>std::io::ErrorKind::AlreadyExists</code></a></li>
<li><a href="https://doc.rust-lang.org/1.84.1/std/io/error/enum.ErrorKind.html#variant.AddrInUse" title="variant std::io::error::ErrorKind::AddrInUse"><code>std::io::ErrorKind::AddrInUse</code></a></li>
</ul>
<p>This can be helpful for taking full control over the file creation, but
leaving the temporary file path construction up to the library. This
also enables creating a temporary UNIX domain socket, since it is not
possible to bind to a socket that already exists.</p>
<p>Note that <a href="struct.Builder.html#method.append" title="method tempfile::Builder::append"><code>Builder::append</code></a> is ignored when using <a href="struct.Builder.html#method.make" title="method tempfile::Builder::make"><code>Builder::make</code></a>.</p>
<h5 id="security-3"><a class="doc-anchor" href="#security-3">§</a>Security</h5>
<p>This has the same <a href="struct.NamedTempFile.html#security">security implications</a> as
<a href="struct.NamedTempFile.html" title="struct tempfile::NamedTempFile"><code>NamedTempFile</code></a>, but with additional caveats. Specifically, it is up
to the closure to ensure that the file does not exist and that such a
check is <em>atomic</em>. Otherwise, a <a href="https://en.wikipedia.org/wiki/Time-of-check_to_time-of-use">time-of-check to time-of-use
bug</a> could be introduced.</p>
<p>For example, the following is <strong>not</strong> secure:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::fs::File;
<span class="kw">use </span>tempfile::Builder;
<span class="comment">// This is NOT secure!
</span><span class="kw">let </span>tempfile = Builder::new().make(|path| {
<span class="kw">if </span>path.is_file() {
<span class="kw">return </span><span class="prelude-val">Err</span>(std::io::ErrorKind::AlreadyExists.into());
}
<span class="comment">// Between the check above and the usage below, an attacker could
// have replaced `path` with another file, which would get truncated
// by `File::create`.
</span>File::create(path)
})<span class="question-mark">?</span>;</code></pre></div>
<p>Note that simply using <a href="https://doc.rust-lang.org/1.84.1/std/fs/struct.File.html#method.create" title="associated function std::fs::File::create"><code>std::fs::File::create</code></a> alone is not correct
because it does not fail if the file already exists:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tempfile::Builder;
<span class="kw">use </span>std::fs::File;
<span class="comment">// This could overwrite an existing file!
</span><span class="kw">let </span>tempfile = Builder::new().make(|path| File::create(path))<span class="question-mark">?</span>;</code></pre></div>
<p>For creating regular temporary files, use <a href="struct.Builder.html#method.tempfile" title="method tempfile::Builder::tempfile"><code>Builder::tempfile</code></a> instead
to avoid these problems. This function is meant to enable more exotic
use-cases.</p>
<h5 id="resource-leaking-4"><a class="doc-anchor" href="#resource-leaking-4">§</a>Resource leaking</h5>
<p>See <a href="struct.NamedTempFile.html#resource-leaking">the resource leaking</a> docs on <code>NamedTempFile</code>.</p>
<h5 id="errors-4"><a class="doc-anchor" href="#errors-4">§</a>Errors</h5>
<p>If the closure returns any error besides
<a href="https://doc.rust-lang.org/1.84.1/std/io/error/enum.ErrorKind.html#variant.AlreadyExists" title="variant std::io::error::ErrorKind::AlreadyExists"><code>std::io::ErrorKind::AlreadyExists</code></a> or
<a href="https://doc.rust-lang.org/1.84.1/std/io/error/enum.ErrorKind.html#variant.AddrInUse" title="variant std::io::error::ErrorKind::AddrInUse"><code>std::io::ErrorKind::AddrInUse</code></a>, then <code>Err</code> is returned.</p>
<h5 id="examples-11"><a class="doc-anchor" href="#examples-11">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::os::unix::net::UnixListener;
<span class="kw">use </span>tempfile::Builder;
<span class="kw">let </span>tempsock = Builder::new().make(|path| UnixListener::bind(path))<span class="question-mark">?</span>;</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.make_in" class="method"><a class="src rightside" href="../src/tempfile/lib.rs.html#680-697">Source</a><h4 class="code-header">pub fn <a href="#method.make_in" class="fn">make_in</a>&lt;F, R, P&gt;(&amp;self, dir: P, f: F) -&gt; <a class="type" href="https://doc.rust-lang.org/1.84.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="struct" href="struct.NamedTempFile.html" title="struct tempfile::NamedTempFile">NamedTempFile</a>&lt;R&gt;&gt;<div class="where">where
F: <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(&amp;<a class="struct" href="https://doc.rust-lang.org/1.84.1/std/path/struct.Path.html" title="struct std::path::Path">Path</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/1.84.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;R&gt;,
P: <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a>&lt;<a class="struct" href="https://doc.rust-lang.org/1.84.1/std/path/struct.Path.html" title="struct std::path::Path">Path</a>&gt;,</div></h4></section></summary><div class="docblock"><p>This is the same as <a href="struct.Builder.html#method.make" title="method tempfile::Builder::make"><code>Builder::make</code></a>, except <code>dir</code> is used as the base
directory for the temporary file path.</p>
<p>See <a href="struct.Builder.html#method.make" title="method tempfile::Builder::make"><code>Builder::make</code></a> for more details and security implications.</p>
<h5 id="examples-12"><a class="doc-anchor" href="#examples-12">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tempfile::Builder;
<span class="kw">use </span>std::os::unix::net::UnixListener;
<span class="kw">let </span>tempsock = Builder::new().make_in(<span class="string">"./"</span>, |path| UnixListener::bind(path))<span class="question-mark">?</span>;</code></pre></div>
</div></details></div></details></div><h2 id="trait-implementations" class="section-header">Trait Implementations<a href="#trait-implementations" class="anchor">§</a></h2><div id="trait-implementations-list"><details class="toggle implementors-toggle" open><summary><section id="impl-Clone-for-Builder%3C'a,+'b%3E" class="impl"><a class="src rightside" href="../src/tempfile/lib.rs.html#173">Source</a><a href="#impl-Clone-for-Builder%3C'a,+'b%3E" class="anchor">§</a><h3 class="code-header">impl&lt;'a, 'b&gt; <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> for <a class="struct" href="struct.Builder.html" title="struct tempfile::Builder">Builder</a>&lt;'a, 'b&gt;</h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.clone" class="method trait-impl"><a class="src rightside" href="../src/tempfile/lib.rs.html#173">Source</a><a href="#method.clone" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.1/core/clone/trait.Clone.html#tymethod.clone" class="fn">clone</a>(&amp;self) -&gt; <a class="struct" href="struct.Builder.html" title="struct tempfile::Builder">Builder</a>&lt;'a, 'b&gt;</h4></section></summary><div class='docblock'>Returns a copy of the value. <a href="https://doc.rust-lang.org/1.84.1/core/clone/trait.Clone.html#tymethod.clone">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.clone_from" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/1.84.1/src/core/clone.rs.html#174">Source</a></span><a href="#method.clone_from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.1/core/clone/trait.Clone.html#method.clone_from" class="fn">clone_from</a>(&amp;mut self, source: &amp;Self)</h4></section></summary><div class='docblock'>Performs copy-assignment from <code>source</code>. <a href="https://doc.rust-lang.org/1.84.1/core/clone/trait.Clone.html#method.clone_from">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Debug-for-Builder%3C'a,+'b%3E" class="impl"><a class="src rightside" href="../src/tempfile/lib.rs.html#173">Source</a><a href="#impl-Debug-for-Builder%3C'a,+'b%3E" class="anchor">§</a><h3 class="code-header">impl&lt;'a, 'b&gt; <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="struct.Builder.html" title="struct tempfile::Builder">Builder</a>&lt;'a, 'b&gt;</h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.fmt" class="method trait-impl"><a class="src rightside" href="../src/tempfile/lib.rs.html#173">Source</a><a href="#method.fmt" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.1/core/fmt/trait.Debug.html#tymethod.fmt" class="fn">fmt</a>(&amp;self, f: &amp;mut <a class="struct" href="https://doc.rust-lang.org/1.84.1/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a>&lt;'_&gt;) -&gt; <a class="type" href="https://doc.rust-lang.org/1.84.1/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></h4></section></summary><div class='docblock'>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/1.84.1/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Default-for-Builder%3C'a,+'b%3E" class="impl"><a class="src rightside" href="../src/tempfile/lib.rs.html#183-194">Source</a><a href="#impl-Default-for-Builder%3C'a,+'b%3E" class="anchor">§</a><h3 class="code-header">impl&lt;'a, 'b&gt; <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/default/trait.Default.html" title="trait core::default::Default">Default</a> for <a class="struct" href="struct.Builder.html" title="struct tempfile::Builder">Builder</a>&lt;'a, 'b&gt;</h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.default" class="method trait-impl"><a class="src rightside" href="../src/tempfile/lib.rs.html#184-193">Source</a><a href="#method.default" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.1/core/default/trait.Default.html#tymethod.default" class="fn">default</a>() -&gt; Self</h4></section></summary><div class='docblock'>Returns the “default value” for a type. <a href="https://doc.rust-lang.org/1.84.1/core/default/trait.Default.html#tymethod.default">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-PartialEq-for-Builder%3C'a,+'b%3E" class="impl"><a class="src rightside" href="../src/tempfile/lib.rs.html#173">Source</a><a href="#impl-PartialEq-for-Builder%3C'a,+'b%3E" class="anchor">§</a><h3 class="code-header">impl&lt;'a, 'b&gt; <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/cmp/trait.PartialEq.html" title="trait core::cmp::PartialEq">PartialEq</a> for <a class="struct" href="struct.Builder.html" title="struct tempfile::Builder">Builder</a>&lt;'a, 'b&gt;</h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.eq" class="method trait-impl"><a class="src rightside" href="../src/tempfile/lib.rs.html#173">Source</a><a href="#method.eq" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.1/core/cmp/trait.PartialEq.html#tymethod.eq" class="fn">eq</a>(&amp;self, other: &amp;<a class="struct" href="struct.Builder.html" title="struct tempfile::Builder">Builder</a>&lt;'a, 'b&gt;) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.bool.html">bool</a></h4></section></summary><div class='docblock'>Tests for <code>self</code> and <code>other</code> values to be equal, and is used by <code>==</code>.</div></details><details class="toggle method-toggle" open><summary><section id="method.ne" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/1.84.1/src/core/cmp.rs.html#261">Source</a></span><a href="#method.ne" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.1/core/cmp/trait.PartialEq.html#method.ne" class="fn">ne</a>(&amp;self, other: <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.reference.html">&amp;Rhs</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.bool.html">bool</a></h4></section></summary><div class='docblock'>Tests for <code>!=</code>. The default implementation is almost always sufficient,
and should not be overridden without very good reason.</div></details></div></details><section id="impl-Eq-for-Builder%3C'a,+'b%3E" class="impl"><a class="src rightside" href="../src/tempfile/lib.rs.html#173">Source</a><a href="#impl-Eq-for-Builder%3C'a,+'b%3E" class="anchor">§</a><h3 class="code-header">impl&lt;'a, 'b&gt; <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/cmp/trait.Eq.html" title="trait core::cmp::Eq">Eq</a> for <a class="struct" href="struct.Builder.html" title="struct tempfile::Builder">Builder</a>&lt;'a, 'b&gt;</h3></section><section id="impl-StructuralPartialEq-for-Builder%3C'a,+'b%3E" class="impl"><a class="src rightside" href="../src/tempfile/lib.rs.html#173">Source</a><a href="#impl-StructuralPartialEq-for-Builder%3C'a,+'b%3E" class="anchor">§</a><h3 class="code-header">impl&lt;'a, 'b&gt; <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.StructuralPartialEq.html" title="trait core::marker::StructuralPartialEq">StructuralPartialEq</a> for <a class="struct" href="struct.Builder.html" title="struct tempfile::Builder">Builder</a>&lt;'a, 'b&gt;</h3></section></div><h2 id="synthetic-implementations" class="section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor">§</a></h2><div id="synthetic-implementations-list"><section id="impl-Freeze-for-Builder%3C'a,+'b%3E" class="impl"><a href="#impl-Freeze-for-Builder%3C'a,+'b%3E" class="anchor">§</a><h3 class="code-header">impl&lt;'a, 'b&gt; <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Freeze.html" title="trait core::marker::Freeze">Freeze</a> for <a class="struct" href="struct.Builder.html" title="struct tempfile::Builder">Builder</a>&lt;'a, 'b&gt;</h3></section><section id="impl-RefUnwindSafe-for-Builder%3C'a,+'b%3E" class="impl"><a href="#impl-RefUnwindSafe-for-Builder%3C'a,+'b%3E" class="anchor">§</a><h3 class="code-header">impl&lt;'a, 'b&gt; <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/panic/unwind_safe/trait.RefUnwindSafe.html" title="trait core::panic::unwind_safe::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="struct.Builder.html" title="struct tempfile::Builder">Builder</a>&lt;'a, 'b&gt;</h3></section><section id="impl-Send-for-Builder%3C'a,+'b%3E" class="impl"><a href="#impl-Send-for-Builder%3C'a,+'b%3E" class="anchor">§</a><h3 class="code-header">impl&lt;'a, 'b&gt; <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="struct.Builder.html" title="struct tempfile::Builder">Builder</a>&lt;'a, 'b&gt;</h3></section><section id="impl-Sync-for-Builder%3C'a,+'b%3E" class="impl"><a href="#impl-Sync-for-Builder%3C'a,+'b%3E" class="anchor">§</a><h3 class="code-header">impl&lt;'a, 'b&gt; <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="struct.Builder.html" title="struct tempfile::Builder">Builder</a>&lt;'a, 'b&gt;</h3></section><section id="impl-Unpin-for-Builder%3C'a,+'b%3E" class="impl"><a href="#impl-Unpin-for-Builder%3C'a,+'b%3E" class="anchor">§</a><h3 class="code-header">impl&lt;'a, 'b&gt; <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="struct.Builder.html" title="struct tempfile::Builder">Builder</a>&lt;'a, 'b&gt;</h3></section><section id="impl-UnwindSafe-for-Builder%3C'a,+'b%3E" class="impl"><a href="#impl-UnwindSafe-for-Builder%3C'a,+'b%3E" class="anchor">§</a><h3 class="code-header">impl&lt;'a, 'b&gt; <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/panic/unwind_safe/trait.UnwindSafe.html" title="trait core::panic::unwind_safe::UnwindSafe">UnwindSafe</a> for <a class="struct" href="struct.Builder.html" title="struct tempfile::Builder">Builder</a>&lt;'a, 'b&gt;</h3></section></div><h2 id="blanket-implementations" class="section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor">§</a></h2><div id="blanket-implementations-list"><details class="toggle implementors-toggle"><summary><section id="impl-Any-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/any.rs.html#138">Source</a><a href="#impl-Any-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T<div class="where">where
T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.type_id" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/any.rs.html#139">Source</a><a href="#method.type_id" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.1/core/any/trait.Any.html#tymethod.type_id" class="fn">type_id</a>(&amp;self) -&gt; <a class="struct" href="https://doc.rust-lang.org/1.84.1/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></h4></section></summary><div class='docblock'>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/1.84.1/core/any/trait.Any.html#tymethod.type_id">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Borrow%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/borrow.rs.html#209">Source</a><a href="#impl-Borrow%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a>&lt;T&gt; for T<div class="where">where
T: ?<a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.borrow" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/borrow.rs.html#211">Source</a><a href="#method.borrow" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.1/core/borrow/trait.Borrow.html#tymethod.borrow" class="fn">borrow</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.reference.html">&amp;T</a></h4></section></summary><div class='docblock'>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/1.84.1/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-BorrowMut%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/borrow.rs.html#217">Source</a><a href="#impl-BorrowMut%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a>&lt;T&gt; for T<div class="where">where
T: ?<a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.borrow_mut" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/borrow.rs.html#218">Source</a><a href="#method.borrow_mut" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.1/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fn">borrow_mut</a>(&amp;mut self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.reference.html">&amp;mut T</a></h4></section></summary><div class='docblock'>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/1.84.1/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-CloneToUninit-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/clone.rs.html#273">Source</a><a href="#impl-CloneToUninit-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/clone/trait.CloneToUninit.html" title="trait core::clone::CloneToUninit">CloneToUninit</a> for T<div class="where">where
T: <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.clone_to_uninit" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/clone.rs.html#275">Source</a><a href="#method.clone_to_uninit" class="anchor">§</a><h4 class="code-header">unsafe fn <a href="https://doc.rust-lang.org/1.84.1/core/clone/trait.CloneToUninit.html#tymethod.clone_to_uninit" class="fn">clone_to_uninit</a>(&amp;self, dst: <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.pointer.html">*mut </a><a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.u8.html">u8</a>)</h4></section></summary><span class="item-info"><div class="stab unstable"><span class="emoji">🔬</span><span>This is a nightly-only experimental API. (<code>clone_to_uninit</code>)</span></div></span><div class='docblock'>Performs copy-assignment from <code>self</code> to <code>dst</code>. <a href="https://doc.rust-lang.org/1.84.1/core/clone/trait.CloneToUninit.html#tymethod.clone_to_uninit">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-From%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#765">Source</a><a href="#impl-From%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;T&gt; for T</h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.from" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#768">Source</a><a href="#method.from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.1/core/convert/trait.From.html#tymethod.from" class="fn">from</a>(t: T) -&gt; T</h4></section></summary><div class="docblock"><p>Returns the argument unchanged.</p>
</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Into%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#748-750">Source</a><a href="#impl-Into%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T, U&gt; <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;U&gt; for T<div class="where">where
U: <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;T&gt;,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.into" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#758">Source</a><a href="#method.into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.1/core/convert/trait.Into.html#tymethod.into" class="fn">into</a>(self) -&gt; U</h4></section></summary><div class="docblock"><p>Calls <code>U::from(self)</code>.</p>
<p>That is, this conversion is whatever the implementation of
<code><a href="https://doc.rust-lang.org/1.84.1/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;T&gt; for U</code> chooses to do.</p>
</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-ToOwned-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/alloc/borrow.rs.html#82-84">Source</a><a href="#impl-ToOwned-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/1.84.1/alloc/borrow/trait.ToOwned.html" title="trait alloc::borrow::ToOwned">ToOwned</a> for T<div class="where">where
T: <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Owned" class="associatedtype trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/alloc/borrow.rs.html#86">Source</a><a href="#associatedtype.Owned" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.84.1/alloc/borrow/trait.ToOwned.html#associatedtype.Owned" class="associatedtype">Owned</a> = T</h4></section></summary><div class='docblock'>The resulting type after obtaining ownership.</div></details><details class="toggle method-toggle" open><summary><section id="method.to_owned" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/alloc/borrow.rs.html#87">Source</a><a href="#method.to_owned" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.1/alloc/borrow/trait.ToOwned.html#tymethod.to_owned" class="fn">to_owned</a>(&amp;self) -&gt; T</h4></section></summary><div class='docblock'>Creates owned data from borrowed data, usually by cloning. <a href="https://doc.rust-lang.org/1.84.1/alloc/borrow/trait.ToOwned.html#tymethod.to_owned">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.clone_into" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/alloc/borrow.rs.html#91">Source</a><a href="#method.clone_into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.1/alloc/borrow/trait.ToOwned.html#method.clone_into" class="fn">clone_into</a>(&amp;self, target: <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.reference.html">&amp;mut T</a>)</h4></section></summary><div class='docblock'>Uses borrowed data to replace owned data, usually by cloning. <a href="https://doc.rust-lang.org/1.84.1/alloc/borrow/trait.ToOwned.html#method.clone_into">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-TryFrom%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#805-807">Source</a><a href="#impl-TryFrom%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T, U&gt; <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;U&gt; for T<div class="where">where
U: <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;T&gt;,</div></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Error-1" class="associatedtype trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#809">Source</a><a href="#associatedtype.Error-1" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html#associatedtype.Error" class="associatedtype">Error</a> = <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a></h4></section></summary><div class='docblock'>The type returned in the event of a conversion error.</div></details><details class="toggle method-toggle" open><summary><section id="method.try_from" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#812">Source</a><a href="#method.try_from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html#tymethod.try_from" class="fn">try_from</a>(value: U) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.84.1/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/1.84.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;U&gt;&gt;::<a class="associatedtype" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>&gt;</h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-TryInto%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#790-792">Source</a><a href="#impl-TryInto%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T, U&gt; <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a>&lt;U&gt; for T<div class="where">where
U: <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;T&gt;,</div></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Error" class="associatedtype trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#794">Source</a><a href="#associatedtype.Error" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryInto.html#associatedtype.Error" class="associatedtype">Error</a> = &lt;U as <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;T&gt;&gt;::<a class="associatedtype" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a></h4></section></summary><div class='docblock'>The type returned in the event of a conversion error.</div></details><details class="toggle method-toggle" open><summary><section id="method.try_into" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#797">Source</a><a href="#method.try_into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryInto.html#tymethod.try_into" class="fn">try_into</a>(self) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.84.1/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/1.84.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;T&gt;&gt;::<a class="associatedtype" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>&gt;</h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details></div></section></div></main></body></html>