deploy: de38ae62916547ad097c066f94a32e9ba7790eeb

This commit is contained in:
NotAShelf 2025-02-05 00:10:33 +00:00
commit 9a86359447
28502 changed files with 1261284 additions and 0 deletions

1
tempfile/all.html Normal file
View file

@ -0,0 +1 @@
<!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="List of all items in this crate"><title>List of all items in this crate</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="../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 mod sys"><!--[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"><h3><a href="#structs">Crate Items</a></h3><ul class="block"><li><a href="#structs" title="Structs">Structs</a></li><li><a href="#enums" title="Enums">Enums</a></li><li><a href="#functions" title="Functions">Functions</a></li></ul></section><div id="rustdoc-modnav"></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><h1>List of all items</h1><h3 id="structs">Structs</h3><ul class="all-items"><li><a href="struct.Builder.html">Builder</a></li><li><a href="struct.NamedTempFile.html">NamedTempFile</a></li><li><a href="struct.PathPersistError.html">PathPersistError</a></li><li><a href="struct.PersistError.html">PersistError</a></li><li><a href="struct.SpooledTempFile.html">SpooledTempFile</a></li><li><a href="struct.TempDir.html">TempDir</a></li><li><a href="struct.TempPath.html">TempPath</a></li></ul><h3 id="enums">Enums</h3><ul class="all-items"><li><a href="enum.SpooledData.html">SpooledData</a></li></ul><h3 id="functions">Functions</h3><ul class="all-items"><li><a href="env/fn.override_temp_dir.html">env::override_temp_dir</a></li><li><a href="env/fn.temp_dir.html">env::temp_dir</a></li><li><a href="fn.spooled_tempfile.html">spooled_tempfile</a></li><li><a href="fn.tempdir.html">tempdir</a></li><li><a href="fn.tempdir_in.html">tempdir_in</a></li><li><a href="fn.tempfile.html">tempfile</a></li><li><a href="fn.tempfile_in.html">tempfile_in</a></li></ul></section></div></main></body></html>

View file

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="refresh" content="0;URL=../../tempfile/fn.tempdir.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="../../tempfile/fn.tempdir.html">../../tempfile/fn.tempdir.html</a>...</p>
<script>location.replace("../../tempfile/fn.tempdir.html" + location.search + location.hash);</script>
</body>
</html>

View file

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="refresh" content="0;URL=../../tempfile/fn.tempdir_in.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="../../tempfile/fn.tempdir_in.html">../../tempfile/fn.tempdir_in.html</a>...</p>
<script>location.replace("../../tempfile/fn.tempdir_in.html" + location.search + location.hash);</script>
</body>
</html>

View file

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="refresh" content="0;URL=../../tempfile/struct.TempDir.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="../../tempfile/struct.TempDir.html">../../tempfile/struct.TempDir.html</a>...</p>
<script>location.replace("../../tempfile/struct.TempDir.html" + location.search + location.hash);</script>
</body>
</html>

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,7 @@
<!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="Override the default temporary directory (defaults to `std::env::temp_dir`). This function changes the global default temporary directory for the entire program and should not be called except in exceptional cases where its not configured correctly by the platform."><title>override_temp_dir in tempfile::env - 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 fn"><!--[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"><div id="rustdoc-modnav"><h2><a href="index.html">In tempfile::<wbr>env</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>::<wbr><a href="index.html">env</a></span><h1>Function <span class="fn">override_temp_dir</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/env.rs.html#17-28">Source</a> </span></div><pre class="rust item-decl"><code>pub fn override_temp_dir(path: &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="enum" href="https://doc.rust-lang.org/1.84.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.unit.html">()</a>, <a class="struct" href="https://doc.rust-lang.org/1.84.1/std/path/struct.PathBuf.html" title="struct std::path::PathBuf">PathBuf</a>&gt;</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Override the default temporary directory (defaults to <a href="https://doc.rust-lang.org/1.84.1/std/env/fn.temp_dir.html" title="fn std::env::temp_dir"><code>std::env::temp_dir</code></a>). This function
changes the <em>global</em> default temporary directory for the entire program and should not be called
except in exceptional cases where its not configured correctly by the platform.</p>
<p>Only the first call to this function will succeed. All further calls will fail with <code>Err(path)</code>
where <code>path</code> is previously set default temporary directory override.</p>
<p><strong>NOTE:</strong> This function does not check if the specified directory exists and/or is writable.</p>
</div></details></section></div></main></body></html>

6
tempfile/env/fn.temp_dir.html vendored Normal file
View file

@ -0,0 +1,6 @@
<!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="Returns the default temporary directory, used for both temporary directories and files if no directory is explicitly specified."><title>temp_dir in tempfile::env - 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 fn"><!--[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"><div id="rustdoc-modnav"><h2><a href="index.html">In tempfile::<wbr>env</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>::<wbr><a href="index.html">env</a></span><h1>Function <span class="fn">temp_dir</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/env.rs.html#37-43">Source</a> </span></div><pre class="rust item-decl"><code>pub fn temp_dir() -&gt; <a class="struct" href="https://doc.rust-lang.org/1.84.1/std/path/struct.PathBuf.html" title="struct std::path::PathBuf">PathBuf</a></code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Returns the default temporary directory, used for both temporary directories and files if no
directory is explicitly specified.</p>
<p>This function simply delegates to <a href="https://doc.rust-lang.org/1.84.1/std/env/fn.temp_dir.html" title="fn std::env::temp_dir"><code>std::env::temp_dir</code></a> unless the default temporary directory
has been override by a call to <a href="fn.override_temp_dir.html" title="fn tempfile::env::override_temp_dir"><code>override_temp_dir</code></a>.</p>
<p><strong>NOTE:</strong> This function does check if the returned directory exists and/or is writable.</p>
</div></details></section></div></main></body></html>

4
tempfile/env/index.html vendored Normal file
View file

@ -0,0 +1,4 @@
<!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 `env` mod in crate `tempfile`."><title>tempfile::env - 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 mod"><!--[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="#">Module env</a></h2><h3><a href="#functions">Module Items</a></h3><ul class="block"><li><a href="#functions" title="Functions">Functions</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>Module <span>env</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/env.rs.html#1-43">Source</a> </span></div><h2 id="functions" class="section-header">Functions<a href="#functions" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="fn" href="fn.override_temp_dir.html" title="fn tempfile::env::override_temp_dir">override_<wbr>temp_<wbr>dir</a></div><div class="desc docblock-short">Override the default temporary directory (defaults to <a href="https://doc.rust-lang.org/1.84.1/std/env/fn.temp_dir.html" title="fn std::env::temp_dir"><code>std::env::temp_dir</code></a>). This function
changes the <em>global</em> default temporary directory for the entire program and should not be called
except in exceptional cases where its not configured correctly by the platform.</div></li><li><div class="item-name"><a class="fn" href="fn.temp_dir.html" title="fn tempfile::env::temp_dir">temp_<wbr>dir</a></div><div class="desc docblock-short">Returns the default temporary directory, used for both temporary directories and files if no
directory is explicitly specified.</div></li></ul></section></div></main></body></html>

1
tempfile/env/sidebar-items.js vendored Normal file
View file

@ -0,0 +1 @@
window.SIDEBAR_ITEMS = {"fn":["override_temp_dir","temp_dir"]};

View file

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="refresh" content="0;URL=../../tempfile/fn.tempfile.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="../../tempfile/fn.tempfile.html">../../tempfile/fn.tempfile.html</a>...</p>
<script>location.replace("../../tempfile/fn.tempfile.html" + location.search + location.hash);</script>
</body>
</html>

View file

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="refresh" content="0;URL=../../tempfile/fn.tempfile_in.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="../../tempfile/fn.tempfile_in.html">../../tempfile/fn.tempfile_in.html</a>...</p>
<script>location.replace("../../tempfile/fn.tempfile_in.html" + location.search + location.hash);</script>
</body>
</html>

View file

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="refresh" content="0;URL=../../tempfile/struct.NamedTempFile.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="../../tempfile/struct.NamedTempFile.html">../../tempfile/struct.NamedTempFile.html</a>...</p>
<script>location.replace("../../tempfile/struct.NamedTempFile.html" + location.search + location.hash);</script>
</body>
</html>

View file

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="refresh" content="0;URL=../../tempfile/struct.PathPersistError.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="../../tempfile/struct.PathPersistError.html">../../tempfile/struct.PathPersistError.html</a>...</p>
<script>location.replace("../../tempfile/struct.PathPersistError.html" + location.search + location.hash);</script>
</body>
</html>

View file

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="refresh" content="0;URL=../../tempfile/struct.PersistError.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="../../tempfile/struct.PersistError.html">../../tempfile/struct.PersistError.html</a>...</p>
<script>location.replace("../../tempfile/struct.PersistError.html" + location.search + location.hash);</script>
</body>
</html>

View file

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="refresh" content="0;URL=../../tempfile/struct.TempPath.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="../../tempfile/struct.TempPath.html">../../tempfile/struct.TempPath.html</a>...</p>
<script>location.replace("../../tempfile/struct.TempPath.html" + location.search + location.hash);</script>
</body>
</html>

View file

@ -0,0 +1,23 @@
<!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 spooled temporary file."><title>spooled_tempfile 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 fn"><!--[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="#">spooled_<wbr>tempfile</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#security" title="Security">Security</a></li><li><a href="#resource-leaking" title="Resource Leaking">Resource Leaking</a></li><li><a href="#examples" title="Examples">Examples</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>Function <span class="fn">spooled_tempfile</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/spooled.rs.html#54-56">Source</a> </span></div><pre class="rust item-decl"><code>pub fn spooled_tempfile(max_size: <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.usize.html">usize</a>) -&gt; <a class="struct" href="struct.SpooledTempFile.html" title="struct tempfile::SpooledTempFile">SpooledTempFile</a> <a href="#" class="tooltip" data-notable-ty="SpooledTempFile"></a></code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Create a new spooled temporary file.</p>
<h2 id="security"><a class="doc-anchor" href="#security">§</a>Security</h2>
<p>This variant is secure/reliable in the presence of a pathological temporary
file cleaner.</p>
<h2 id="resource-leaking"><a class="doc-anchor" href="#resource-leaking">§</a>Resource Leaking</h2>
<p>The temporary file will be automatically removed by the OS when the last
handle to it is closed. This doesnt rely on Rust destructors being run, so
will (almost) never fail to clean up the temporary file.</p>
<h2 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h2>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tempfile::spooled_tempfile;
<span class="kw">use </span>std::io::Write;
<span class="kw">let </span><span class="kw-2">mut </span>file = spooled_tempfile(<span class="number">15</span>);
<span class="macro">writeln!</span>(file, <span class="string">"short line"</span>)<span class="question-mark">?</span>;
<span class="macro">assert!</span>(!file.is_rolled());
<span class="comment">// as a result of this write call, the size of the data will exceed
// `max_size` (15), so it will be written to a temporary file on disk,
// and the in-memory buffer will be dropped
</span><span class="macro">writeln!</span>(file, <span class="string">"marvin gardens"</span>)<span class="question-mark">?</span>;
<span class="macro">assert!</span>(file.is_rolled());</code></pre></div>
</div></details><script type="text/json" id="notable-traits-data">{"SpooledTempFile":"<h3>Notable traits for <code><a class=\"struct\" href=\"struct.SpooledTempFile.html\" title=\"struct tempfile::SpooledTempFile\">SpooledTempFile</a></code></h3><pre><code><div class=\"where\">impl <a class=\"trait\" href=\"https://doc.rust-lang.org/1.84.1/std/io/trait.Read.html\" title=\"trait std::io::Read\">Read</a> for <a class=\"struct\" href=\"struct.SpooledTempFile.html\" title=\"struct tempfile::SpooledTempFile\">SpooledTempFile</a></div><div class=\"where\">impl <a class=\"trait\" href=\"https://doc.rust-lang.org/1.84.1/std/io/trait.Write.html\" title=\"trait std::io::Write\">Write</a> for <a class=\"struct\" href=\"struct.SpooledTempFile.html\" title=\"struct tempfile::SpooledTempFile\">SpooledTempFile</a></div>"}</script></section></div></main></body></html>

26
tempfile/fn.tempdir.html Normal file
View file

@ -0,0 +1,26 @@
<!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 directory."><title>tempdir 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 fn"><!--[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="#">tempdir</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#resource-leaking" title="Resource Leaking">Resource Leaking</a></li><li><a href="#errors" title="Errors">Errors</a></li><li><a href="#examples" title="Examples">Examples</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>Function <span class="fn">tempdir</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/dir/mod.rs.html#61-63">Source</a> </span></div><pre class="rust item-decl"><code>pub fn tempdir() -&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;</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Create a new temporary directory.</p>
<p>The <code>tempdir</code> function creates a directory in the file system
and returns a <a href="struct.TempDir.html"><code>TempDir</code></a>.
The directory will be automatically deleted when the <code>TempDir</code>s
destructor is run.</p>
<h2 id="resource-leaking"><a class="doc-anchor" href="#resource-leaking">§</a>Resource Leaking</h2>
<p>See <a href="struct.TempDir.html#resource-leaking">the resource leaking</a> docs on <code>TempDir</code>.</p>
<h2 id="errors"><a class="doc-anchor" href="#errors">§</a>Errors</h2>
<p>If the directory can not be created, <code>Err</code> is returned.</p>
<h2 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h2>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tempfile::tempdir;
<span class="kw">use </span>std::fs::File;
<span class="kw">use </span>std::io::Write;
<span class="comment">// Create a directory inside of `env::temp_dir()`
</span><span class="kw">let </span>tmp_dir = tempdir()<span class="question-mark">?</span>;
<span class="kw">let </span>file_path = tmp_dir.path().join(<span class="string">"my-temporary-note.txt"</span>);
<span class="kw">let </span><span class="kw-2">mut </span>tmp_file = File::create(file_path)<span class="question-mark">?</span>;
<span class="macro">writeln!</span>(tmp_file, <span class="string">"Brian was here. Briefly."</span>)<span class="question-mark">?</span>;
<span class="comment">// `tmp_dir` goes out of scope, the directory as well as
// `tmp_file` will be deleted here.
</span>drop(tmp_file);
tmp_dir.close()<span class="question-mark">?</span>;</code></pre></div>
</div></details></section></div></main></body></html>

View file

@ -0,0 +1,26 @@
<!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 directory in a specific directory."><title>tempdir_in 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 fn"><!--[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="#">tempdir_<wbr>in</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#resource-leaking" title="Resource Leaking">Resource Leaking</a></li><li><a href="#errors" title="Errors">Errors</a></li><li><a href="#examples" title="Examples">Examples</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>Function <span class="fn">tempdir_in</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/dir/mod.rs.html#103-105">Source</a> </span></div><pre class="rust item-decl"><code>pub fn tempdir_in&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;(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;</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Create a new temporary directory in a specific directory.</p>
<p>The <code>tempdir_in</code> function creates a directory in the specified directory
and returns a <a href="struct.TempDir.html"><code>TempDir</code></a>.
The directory will be automatically deleted when the <code>TempDir</code>s
destructor is run.</p>
<h2 id="resource-leaking"><a class="doc-anchor" href="#resource-leaking">§</a>Resource Leaking</h2>
<p>See <a href="struct.TempDir.html#resource-leaking">the resource leaking</a> docs on <code>TempDir</code>.</p>
<h2 id="errors"><a class="doc-anchor" href="#errors">§</a>Errors</h2>
<p>If the directory can not be created, <code>Err</code> is returned.</p>
<h2 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h2>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tempfile::tempdir_in;
<span class="kw">use </span>std::fs::File;
<span class="kw">use </span>std::io::Write;
<span class="comment">// Create a directory inside of the current directory.
</span><span class="kw">let </span>tmp_dir = tempdir_in(<span class="string">"."</span>)<span class="question-mark">?</span>;
<span class="kw">let </span>file_path = tmp_dir.path().join(<span class="string">"my-temporary-note.txt"</span>);
<span class="kw">let </span><span class="kw-2">mut </span>tmp_file = File::create(file_path)<span class="question-mark">?</span>;
<span class="macro">writeln!</span>(tmp_file, <span class="string">"Brian was here. Briefly."</span>)<span class="question-mark">?</span>;
<span class="comment">// `tmp_dir` goes out of scope, the directory as well as
// `tmp_file` will be deleted here.
</span>drop(tmp_file);
tmp_dir.close()<span class="question-mark">?</span>;</code></pre></div>
</div></details></section></div></main></body></html>

18
tempfile/fn.tempfile.html Normal file
View file

@ -0,0 +1,18 @@
<!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."><title>tempfile 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 fn"><!--[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="#">tempfile</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#security" title="Security">Security</a></li><li><a href="#resource-leaking" title="Resource Leaking">Resource Leaking</a></li><li><a href="#errors" title="Errors">Errors</a></li><li><a href="#examples" title="Examples">Examples</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>Function <span class="fn">tempfile</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/file/mod.rs.html#51-53">Source</a> </span></div><pre class="rust item-decl"><code>pub fn tempfile() -&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="https://doc.rust-lang.org/1.84.1/std/fs/struct.File.html" title="struct std::fs::File">File</a>&gt;</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.</p>
<p>The file will be created in the location returned by <a href="env/fn.temp_dir.html" title="fn tempfile::env::temp_dir"><code>env::temp_dir()</code></a>.</p>
<h2 id="security"><a class="doc-anchor" href="#security">§</a>Security</h2>
<p>This variant is secure/reliable in the presence of a pathological temporary file cleaner.</p>
<h2 id="resource-leaking"><a class="doc-anchor" href="#resource-leaking">§</a>Resource Leaking</h2>
<p>The temporary file will be automatically removed by the OS when the last handle to it is closed.
This doesnt rely on Rust destructors being run, so will (almost) never fail to clean up the temporary file.</p>
<h2 id="errors"><a class="doc-anchor" href="#errors">§</a>Errors</h2>
<p>If the file can not be created, <code>Err</code> is returned.</p>
<h2 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h2>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tempfile::tempfile;
<span class="kw">use </span>std::io::Write;
<span class="comment">// Create a file inside of `env::temp_dir()`.
</span><span class="kw">let </span><span class="kw-2">mut </span>file = tempfile()<span class="question-mark">?</span>;
<span class="macro">writeln!</span>(file, <span class="string">"Brian was here. Briefly."</span>)<span class="question-mark">?</span>;</code></pre></div>
</div></details></section></div></main></body></html>

View file

@ -0,0 +1,18 @@
<!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 in the specified directory."><title>tempfile_in 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 fn"><!--[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="#">tempfile_<wbr>in</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#security" title="Security">Security</a></li><li><a href="#resource-leaking" title="Resource Leaking">Resource Leaking</a></li><li><a href="#errors" title="Errors">Errors</a></li><li><a href="#examples" title="Examples">Examples</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>Function <span class="fn">tempfile_in</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/file/mod.rs.html#83-85">Source</a> </span></div><pre class="rust item-decl"><code>pub fn tempfile_in&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;(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="https://doc.rust-lang.org/1.84.1/std/fs/struct.File.html" title="struct std::fs::File">File</a>&gt;</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 in the specified directory.</p>
<h2 id="security"><a class="doc-anchor" href="#security">§</a>Security</h2>
<p>This variant is secure/reliable in the presence of a pathological temporary file cleaner.
If the temporary file isnt created in <a href="env/fn.temp_dir.html" title="fn tempfile::env::temp_dir"><code>env::temp_dir()</code></a> then temporary file cleaners arent an issue.</p>
<h2 id="resource-leaking"><a class="doc-anchor" href="#resource-leaking">§</a>Resource Leaking</h2>
<p>The temporary file will be automatically removed by the OS when the last handle to it is closed.
This doesnt rely on Rust destructors being run, so will (almost) never fail to clean up the temporary file.</p>
<h2 id="errors"><a class="doc-anchor" href="#errors">§</a>Errors</h2>
<p>If the file can not be created, <code>Err</code> is returned.</p>
<h2 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h2>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tempfile::tempfile_in;
<span class="kw">use </span>std::io::Write;
<span class="comment">// Create a file inside of the current working directory
</span><span class="kw">let </span><span class="kw-2">mut </span>file = tempfile_in(<span class="string">"./"</span>)<span class="question-mark">?</span>;
<span class="macro">writeln!</span>(file, <span class="string">"Brian was here. Briefly."</span>)<span class="question-mark">?</span>;</code></pre></div>
</div></details></section></div></main></body></html>

101
tempfile/index.html Normal file
View file

@ -0,0 +1,101 @@
<!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="Temporary files and directories."><title>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="../crates.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 mod crate"><!--[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"><ul class="block"><li><a id="all-types" href="all.html">All Items</a></li></ul><section id="rustdoc-toc"><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#design" title="Design">Design</a><ul><li><a href="#resource-leaking" title="Resource Leaking">Resource Leaking</a></li><li><a href="#security" title="Security">Security</a></li><li><a href="#early-drop-pitfall" title="Early drop pitfall">Early drop pitfall</a></li><li><a href="#examples" title="Examples">Examples</a></li></ul></li></ul><h3><a href="#modules">Crate Items</a></h3><ul class="block"><li><a href="#modules" title="Modules">Modules</a></li><li><a href="#structs" title="Structs">Structs</a></li><li><a href="#enums" title="Enums">Enums</a></li><li><a href="#functions" title="Functions">Functions</a></li></ul></section><div id="rustdoc-modnav"></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"><h1>Crate <span>tempfile</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#1-698">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Temporary files and directories.</p>
<ul>
<li>Use the <a href="fn.tempfile.html"><code>tempfile()</code></a> function for temporary files</li>
<li>Use the <a href="fn.tempdir.html"><code>tempdir()</code></a> function for temporary directories.</li>
</ul>
<h2 id="design"><a class="doc-anchor" href="#design">§</a>Design</h2>
<p>This crate provides several approaches to creating temporary files and directories.
<a href="fn.tempfile.html"><code>tempfile()</code></a> relies on the OS to remove the temporary file once the last handle is closed.
<a href="struct.TempDir.html"><code>TempDir</code></a> and <a href="struct.NamedTempFile.html"><code>NamedTempFile</code></a> both rely on Rust destructors for cleanup.</p>
<p>When choosing between the temporary file variants, prefer <code>tempfile</code>
unless you either need to know the files path or to be able to persist it.</p>
<h3 id="resource-leaking"><a class="doc-anchor" href="#resource-leaking">§</a>Resource Leaking</h3>
<p><code>tempfile</code> will (almost) never fail to cleanup temporary resources. However <code>TempDir</code> and <code>NamedTempFile</code> will
fail if their destructors dont run. This is because <code>tempfile</code> relies on the OS to cleanup the
underlying file, while <code>TempDir</code> and <code>NamedTempFile</code> rely on rust destructors to do so.
Destructors may fail to run if the process exits through an unhandled signal interrupt (like <code>SIGINT</code>),
or if the instance is declared statically (like with <a href="https://github.com/rust-lang-nursery/lazy-static.rs/issues/62"><code>lazy_static</code></a>), among other possible
reasons.</p>
<h3 id="security"><a class="doc-anchor" href="#security">§</a>Security</h3>
<p>In the presence of pathological temporary file cleaner, relying on file paths is unsafe because
a temporary file cleaner could delete the temporary file which an attacker could then replace.</p>
<p><code>tempfile</code> doesnt rely on file paths so this isnt an issue. However, <code>NamedTempFile</code> does
rely on file paths for <em>some</em> operations. See the security documentation on
the <code>NamedTempFile</code> type for more information.</p>
<h3 id="early-drop-pitfall"><a class="doc-anchor" href="#early-drop-pitfall">§</a>Early drop pitfall</h3>
<p>Because <code>TempDir</code> and <code>NamedTempFile</code> rely on their destructors for cleanup, this can lead
to an unexpected early removal of the directory/file, usually when working with APIs which are
generic over <code>AsRef&lt;Path&gt;</code>. Consider the following example:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tempfile::tempdir;
<span class="kw">use </span>std::process::Command;
<span class="comment">// Create a directory inside of `env::temp_dir()`.
</span><span class="kw">let </span>temp_dir = tempdir()<span class="question-mark">?</span>;
<span class="comment">// Spawn the `touch` command inside the temporary directory and collect the exit status
// Note that `temp_dir` is **not** moved into `current_dir`, but passed as a reference
</span><span class="kw">let </span>exit_status = Command::new(<span class="string">"touch"</span>).arg(<span class="string">"tmp"</span>).current_dir(<span class="kw-2">&amp;</span>temp_dir).status()<span class="question-mark">?</span>;
<span class="macro">assert!</span>(exit_status.success());
</code></pre></div>
<p>This works because a reference to <code>temp_dir</code> is passed to <code>current_dir</code>, resulting in the
destructor of <code>temp_dir</code> being run after the <code>Command</code> has finished execution. Moving the
<code>TempDir</code> into the <code>current_dir</code> call would result in the <code>TempDir</code> being converted into
an internal representation, with the original value being dropped and the directory thus
being deleted, before the command can be executed.</p>
<p>The <code>touch</code> command would fail with an <code>No such file or directory</code> error.</p>
<h3 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h3>
<p>Create a 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>tempfile::tempfile;
<span class="kw">use </span>std::io::Write;
<span class="comment">// Create a file inside of `env::temp_dir()`.
</span><span class="kw">let </span><span class="kw-2">mut </span>file = tempfile()<span class="question-mark">?</span>;
<span class="macro">writeln!</span>(file, <span class="string">"Brian was here. Briefly."</span>)<span class="question-mark">?</span>;</code></pre></div>
<p>Create a named temporary file and open an independent file handle:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tempfile::NamedTempFile;
<span class="kw">use </span>std::io::{Write, Read};
<span class="kw">let </span>text = <span class="string">"Brian was here. Briefly."</span>;
<span class="comment">// Create a file inside of `env::temp_dir()`.
</span><span class="kw">let </span><span class="kw-2">mut </span>file1 = NamedTempFile::new()<span class="question-mark">?</span>;
<span class="comment">// Re-open it.
</span><span class="kw">let </span><span class="kw-2">mut </span>file2 = file1.reopen()<span class="question-mark">?</span>;
<span class="comment">// Write some test data to the first handle.
</span>file1.write_all(text.as_bytes())<span class="question-mark">?</span>;
<span class="comment">// Read the test data using the second handle.
</span><span class="kw">let </span><span class="kw-2">mut </span>buf = String::new();
file2.read_to_string(<span class="kw-2">&amp;mut </span>buf)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(buf, text);</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>tempfile::tempdir;
<span class="kw">use </span>std::fs::File;
<span class="kw">use </span>std::io::Write;
<span class="comment">// Create a directory inside of `env::temp_dir()`.
</span><span class="kw">let </span>dir = 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>
</div></details><h2 id="modules" class="section-header">Modules<a href="#modules" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="mod" href="env/index.html" title="mod tempfile::env">env</a></div></li></ul><h2 id="structs" class="section-header">Structs<a href="#structs" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="struct" href="struct.Builder.html" title="struct tempfile::Builder">Builder</a></div><div class="desc docblock-short">Create a new temporary file or directory with custom parameters.</div></li><li><div class="item-name"><a class="struct" href="struct.NamedTempFile.html" title="struct tempfile::NamedTempFile">Named<wbr>Temp<wbr>File</a></div><div class="desc docblock-short">A named temporary file.</div></li><li><div class="item-name"><a class="struct" href="struct.PathPersistError.html" title="struct tempfile::PathPersistError">Path<wbr>Persist<wbr>Error</a></div><div class="desc docblock-short">Error returned when persisting a temporary file path fails.</div></li><li><div class="item-name"><a class="struct" href="struct.PersistError.html" title="struct tempfile::PersistError">Persist<wbr>Error</a></div><div class="desc docblock-short">Error returned when persisting a temporary file fails.</div></li><li><div class="item-name"><a class="struct" href="struct.SpooledTempFile.html" title="struct tempfile::SpooledTempFile">Spooled<wbr>Temp<wbr>File</a></div><div class="desc docblock-short">An object that behaves like a regular temporary file, but keeps data in
memory until it reaches a configured size, at which point the data is
written to a temporary file on disk, and further operations use the file
on disk.</div></li><li><div class="item-name"><a class="struct" href="struct.TempDir.html" title="struct tempfile::TempDir">TempDir</a></div><div class="desc docblock-short">A directory in the filesystem that is automatically deleted when
it goes out of scope.</div></li><li><div class="item-name"><a class="struct" href="struct.TempPath.html" title="struct tempfile::TempPath">Temp<wbr>Path</a></div><div class="desc docblock-short">A path to a named temporary file without an open file handle.</div></li></ul><h2 id="enums" class="section-header">Enums<a href="#enums" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="enum" href="enum.SpooledData.html" title="enum tempfile::SpooledData">Spooled<wbr>Data</a></div><div class="desc docblock-short">A wrapper for the two states of a <code>SpooledTempFile</code>.</div></li></ul><h2 id="functions" class="section-header">Functions<a href="#functions" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="fn" href="fn.spooled_tempfile.html" title="fn tempfile::spooled_tempfile">spooled_<wbr>tempfile</a></div><div class="desc docblock-short">Create a new spooled temporary file.</div></li><li><div class="item-name"><a class="fn" href="fn.tempdir.html" title="fn tempfile::tempdir">tempdir</a></div><div class="desc docblock-short">Create a new temporary directory.</div></li><li><div class="item-name"><a class="fn" href="fn.tempdir_in.html" title="fn tempfile::tempdir_in">tempdir_<wbr>in</a></div><div class="desc docblock-short">Create a new temporary directory in a specific directory.</div></li><li><div class="item-name"><a class="fn" href="fn.tempfile.html" title="fn tempfile::tempfile">tempfile</a></div><div class="desc docblock-short">Create a new temporary file.</div></li><li><div class="item-name"><a class="fn" href="fn.tempfile_in.html" title="fn tempfile::tempfile_in">tempfile_<wbr>in</a></div><div class="desc docblock-short">Create a new temporary file in the specified directory.</div></li></ul></section></div></main></body></html>

View file

@ -0,0 +1 @@
window.SIDEBAR_ITEMS = {"enum":["SpooledData"],"fn":["spooled_tempfile","tempdir","tempdir_in","tempfile","tempfile_in"],"mod":["env"],"struct":["Builder","NamedTempFile","PathPersistError","PersistError","SpooledTempFile","TempDir","TempPath"]};

View file

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="refresh" content="0;URL=../../tempfile/enum.SpooledData.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="../../tempfile/enum.SpooledData.html">../../tempfile/enum.SpooledData.html</a>...</p>
<script>location.replace("../../tempfile/enum.SpooledData.html" + location.search + location.hash);</script>
</body>
</html>

View file

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="refresh" content="0;URL=../../tempfile/fn.spooled_tempfile.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="../../tempfile/fn.spooled_tempfile.html">../../tempfile/fn.spooled_tempfile.html</a>...</p>
<script>location.replace("../../tempfile/fn.spooled_tempfile.html" + location.search + location.hash);</script>
</body>
</html>

View file

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="refresh" content="0;URL=../../tempfile/struct.SpooledTempFile.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="../../tempfile/struct.SpooledTempFile.html">../../tempfile/struct.SpooledTempFile.html</a>...</p>
<script>location.replace("../../tempfile/struct.SpooledTempFile.html" + location.search + location.hash);</script>
</body>
</html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long