Adding large folders

This commit is contained in:
2026-02-26 12:00:21 -05:00
parent 5400d82acd
commit 49701c85ad
47332 changed files with 1942573 additions and 0 deletions

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,2 @@
<!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="Time error types."><title>tokio::time::error - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.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"href="../../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../../../" data-static-root-path="../../../static.files/" data-current-crate="tokio" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../../../static.files/storage-e2aeef58.js"></script><script defer src="../sidebar-items.js"></script><script defer src="../../../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../../../static.files/noscript-263c88ec.css"></noscript><link rel="alternate icon" type="image/png" href="../../../static.files/favicon-32x32-eab170b8.png"><link rel="icon" type="image/svg+xml" href="../../../static.files/favicon-044be391.svg"></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]--><rustdoc-topbar><h2><a href="#">Module error</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../../tokio/index.html">tokio</a><span class="version">1.49.0</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Module error</a></h2><h3><a href="#structs">Module Items</a></h3><ul class="block"><li><a href="#structs" title="Structs">Structs</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="../index.html">In tokio::<wbr>time</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../../index.html">tokio</a>::<wbr><a href="../index.html">time</a></div><h1>Module <span>error</span>&nbsp;<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/tokio/time/error.rs.html#1-123">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Time error types.</p>
</div></details><h2 id="structs" class="section-header">Structs<a href="#structs" class="anchor">§</a></h2><dl class="item-table"><dt><a class="struct" href="struct.Elapsed.html" title="struct tokio::time::error::Elapsed">Elapsed</a></dt><dd>Errors returned by <code>Timeout</code>.</dd><dt><a class="struct" href="struct.Error.html" title="struct tokio::time::error::Error">Error</a></dt><dd>Errors encountered by the timer implementation.</dd></dl></section></div></main></body></html>

View File

@@ -0,0 +1 @@
window.SIDEBAR_ITEMS = {"struct":["Elapsed","Error"]};

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,41 @@
<!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="Creates new `Interval` that yields with interval of `period`. The first tick completes immediately. The default `MissedTickBehavior` is `Burst`, but this can be configured by calling `set_missed_tick_behavior`."><title>interval in tokio::time - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.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"href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="tokio" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-263c88ec.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-eab170b8.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></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]--><rustdoc-topbar><h2><a href="#">interval</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../tokio/index.html">tokio</a><span class="version">1.49.0</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">interval</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#panics" title="Panics">Panics</a></li><li><a href="#examples" title="Examples">Examples</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="index.html">In tokio::<wbr>time</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../index.html">tokio</a>::<wbr><a href="index.html">time</a></div><h1>Function <span class="fn">interval</span>&nbsp;<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/tokio/time/interval.rs.html#73-76">Source</a> </span></div><pre class="rust item-decl"><code>pub fn interval(period: <a class="struct" href="https://doc.rust-lang.org/1.93.1/core/time/struct.Duration.html" title="struct core::time::Duration">Duration</a>) -&gt; <a class="struct" href="struct.Interval.html" title="struct tokio::time::Interval">Interval</a></code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Creates new <a href="struct.Interval.html" title="struct tokio::time::Interval"><code>Interval</code></a> that yields with interval of <code>period</code>. The first
tick completes immediately. The default <a href="enum.MissedTickBehavior.html" title="enum tokio::time::MissedTickBehavior"><code>MissedTickBehavior</code></a> is
<a href="enum.MissedTickBehavior.html#variant.Burst" title="variant tokio::time::MissedTickBehavior::Burst"><code>Burst</code></a>, but this can be configured
by calling <a href="struct.Interval.html#method.set_missed_tick_behavior" title="method tokio::time::Interval::set_missed_tick_behavior"><code>set_missed_tick_behavior</code></a>.</p>
<p>An interval will tick indefinitely. At any time, the <a href="struct.Interval.html" title="struct tokio::time::Interval"><code>Interval</code></a> value can
be dropped. This cancels the interval.</p>
<p>This function is equivalent to
<a href="fn.interval_at.html" title="fn tokio::time::interval_at"><code>interval_at(Instant::now(), period)</code></a>.</p>
<h2 id="panics"><a class="doc-anchor" href="#panics">§</a>Panics</h2>
<p>This function panics if <code>period</code> is zero.</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>tokio::time::{<span class="self">self</span>, Duration};
<span class="kw">let </span><span class="kw-2">mut </span>interval = time::interval(Duration::from_millis(<span class="number">10</span>));
interval.tick().<span class="kw">await</span>; <span class="comment">// ticks immediately
</span>interval.tick().<span class="kw">await</span>; <span class="comment">// ticks after 10ms
</span>interval.tick().<span class="kw">await</span>; <span class="comment">// ticks after 10ms
// approximately 20ms have elapsed.</span></code></pre></div>
<p>A simple example using <code>interval</code> to execute a task every two seconds.</p>
<p>The difference between <code>interval</code> and <a href="fn.sleep.html" title="fn tokio::time::sleep"><code>sleep</code></a> is that an <a href="struct.Interval.html" title="struct tokio::time::Interval"><code>Interval</code></a>
measures the time since the last tick, which means that <a href="struct.Interval.html#method.tick" title="method tokio::time::Interval::tick"><code>.tick().await</code></a>
may wait for a shorter time than the duration specified for the interval
if some time has passed between calls to <a href="struct.Interval.html#method.tick" title="method tokio::time::Interval::tick"><code>.tick().await</code></a>.</p>
<p>If the tick in the example below was replaced with <a href="fn.sleep.html" title="fn tokio::time::sleep"><code>sleep</code></a>, the task
would only be executed once every three seconds, and not every two
seconds.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio::time;
<span class="kw">async fn </span>task_that_takes_a_second() {
<span class="macro">println!</span>(<span class="string">"hello"</span>);
time::sleep(time::Duration::from_secs(<span class="number">1</span>)).<span class="kw">await
</span>}
<span class="kw">let </span><span class="kw-2">mut </span>interval = time::interval(time::Duration::from_secs(<span class="number">2</span>));
<span class="kw">for </span>_i <span class="kw">in </span><span class="number">0</span>..<span class="number">5 </span>{
interval.tick().<span class="kw">await</span>;
task_that_takes_a_second().<span class="kw">await</span>;
}</code></pre></div></div></details></section></div></main></body></html>

View File

@@ -0,0 +1,19 @@
<!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="Creates new `Interval` that yields with interval of `period` with the first tick completing at `start`. The default `MissedTickBehavior` is `Burst`, but this can be configured by calling `set_missed_tick_behavior`."><title>interval_at in tokio::time - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.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"href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="tokio" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-263c88ec.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-eab170b8.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></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]--><rustdoc-topbar><h2><a href="#">interval_at</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../tokio/index.html">tokio</a><span class="version">1.49.0</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">interval_<wbr>at</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#panics" title="Panics">Panics</a></li><li><a href="#examples" title="Examples">Examples</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="index.html">In tokio::<wbr>time</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../index.html">tokio</a>::<wbr><a href="index.html">time</a></div><h1>Function <span class="fn">interval_<wbr>at</span>&nbsp;<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/tokio/time/interval.rs.html#108-111">Source</a> </span></div><pre class="rust item-decl"><code>pub fn interval_at(start: <a class="struct" href="struct.Instant.html" title="struct tokio::time::Instant">Instant</a>, period: <a class="struct" href="https://doc.rust-lang.org/1.93.1/core/time/struct.Duration.html" title="struct core::time::Duration">Duration</a>) -&gt; <a class="struct" href="struct.Interval.html" title="struct tokio::time::Interval">Interval</a></code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Creates new <a href="struct.Interval.html" title="struct tokio::time::Interval"><code>Interval</code></a> that yields with interval of <code>period</code> with the
first tick completing at <code>start</code>. The default <a href="enum.MissedTickBehavior.html" title="enum tokio::time::MissedTickBehavior"><code>MissedTickBehavior</code></a> is
<a href="enum.MissedTickBehavior.html#variant.Burst" title="variant tokio::time::MissedTickBehavior::Burst"><code>Burst</code></a>, but this can be configured
by calling <a href="struct.Interval.html#method.set_missed_tick_behavior" title="method tokio::time::Interval::set_missed_tick_behavior"><code>set_missed_tick_behavior</code></a>.</p>
<p>An interval will tick indefinitely. At any time, the <a href="struct.Interval.html" title="struct tokio::time::Interval"><code>Interval</code></a> value can
be dropped. This cancels the interval.</p>
<h2 id="panics"><a class="doc-anchor" href="#panics">§</a>Panics</h2>
<p>This function panics if <code>period</code> is zero.</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>tokio::time::{interval_at, Duration, Instant};
<span class="kw">let </span>start = Instant::now() + Duration::from_millis(<span class="number">50</span>);
<span class="kw">let </span><span class="kw-2">mut </span>interval = interval_at(start, Duration::from_millis(<span class="number">10</span>));
interval.tick().<span class="kw">await</span>; <span class="comment">// ticks after 50ms
</span>interval.tick().<span class="kw">await</span>; <span class="comment">// ticks after 10ms
</span>interval.tick().<span class="kw">await</span>; <span class="comment">// ticks after 10ms
// approximately 70ms have elapsed.</span></code></pre></div></div></details></section></div></main></body></html>

View File

@@ -0,0 +1,32 @@
<!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="Waits until `duration` has elapsed."><title>sleep in tokio::time - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.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"href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="tokio" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-263c88ec.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-eab170b8.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></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]--><rustdoc-topbar><h2><a href="#">sleep</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../tokio/index.html">tokio</a><span class="version">1.49.0</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">sleep</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#cancellation" title="Cancellation">Cancellation</a></li><li><a href="#examples" title="Examples">Examples</a></li><li><a href="#panics" title="Panics">Panics</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="index.html">In tokio::<wbr>time</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../index.html">tokio</a>::<wbr><a href="index.html">time</a></div><h1>Function <span class="fn">sleep</span>&nbsp;<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/tokio/time/sleep.rs.html#123-130">Source</a> </span></div><pre class="rust item-decl"><code>pub fn sleep(duration: <a class="struct" href="https://doc.rust-lang.org/1.93.1/core/time/struct.Duration.html" title="struct core::time::Duration">Duration</a>) -&gt; <a class="struct" href="struct.Sleep.html" title="struct tokio::time::Sleep">Sleep</a> <a href="#" class="tooltip" data-notable-ty="Sleep"></a></code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Waits until <code>duration</code> has elapsed.</p>
<p>Equivalent to <code>sleep_until(Instant::now() + duration)</code>. An asynchronous
analog to <code>std::thread::sleep</code>.</p>
<p>No work is performed while awaiting on the sleep future to complete. <code>Sleep</code>
operates at millisecond granularity and should not be used for tasks that
require high-resolution timers. The implementation is platform specific,
and some platforms (specifically Windows) will provide timers with a
larger resolution than 1 ms.</p>
<p>To run something regularly on a schedule, see <a href="fn.interval.html" title="fn tokio::time::interval"><code>interval</code></a>.</p>
<h2 id="cancellation"><a class="doc-anchor" href="#cancellation">§</a>Cancellation</h2>
<p>Canceling a sleep instance is done by dropping the returned future. No additional
cleanup work is required.</p>
<h2 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h2>
<p>Wait 100ms and print “100 ms have elapsed”.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio::time::{sleep, Duration};
sleep(Duration::from_millis(<span class="number">100</span>)).<span class="kw">await</span>;
<span class="macro">println!</span>(<span class="string">"100 ms have elapsed"</span>);</code></pre></div>
<p>See the documentation for the <a href="struct.Sleep.html" title="struct tokio::time::Sleep"><code>Sleep</code></a> type for more examples.</p>
<h2 id="panics"><a class="doc-anchor" href="#panics">§</a>Panics</h2>
<p>This function panics if there is no current timer set.</p>
<p>It can be triggered when <a href="../runtime/struct.Builder.html#method.enable_time" title="method tokio::runtime::Builder::enable_time"><code>Builder::enable_time</code></a> or
<a href="../runtime/struct.Builder.html#method.enable_all" title="method tokio::runtime::Builder::enable_all"><code>Builder::enable_all</code></a> are not included in the builder.</p>
<p>It can also panic whenever a timer is created outside of a
Tokio runtime. That is why <code>rt.block_on(sleep(...))</code> will panic,
since the function is executed outside of the runtime.
Whereas <code>rt.block_on(async {sleep(...).await})</code> doesnt panic.
And this is because wrapping the function on an async makes it lazy,
and so gets executed inside the runtime successfully without
panicking.</p>
</div></details><script type="text/json" id="notable-traits-data">{"Sleep":"<h3>Notable traits for <code><a class=\"struct\" href=\"struct.Sleep.html\" title=\"struct tokio::time::Sleep\">Sleep</a></code></h3><pre><code><div class=\"where\">impl <a class=\"trait\" href=\"https://doc.rust-lang.org/1.93.1/core/future/future/trait.Future.html\" title=\"trait core::future::future::Future\">Future</a> for <a class=\"struct\" href=\"struct.Sleep.html\" title=\"struct tokio::time::Sleep\">Sleep</a></div><div class=\"where\"> type <a href=\"https://doc.rust-lang.org/1.93.1/core/future/future/trait.Future.html#associatedtype.Output\" class=\"associatedtype\">Output</a> = <a class=\"primitive\" href=\"https://doc.rust-lang.org/1.93.1/std/primitive.unit.html\">()</a>;</div>"}</script></section></div></main></body></html>

View File

@@ -0,0 +1,28 @@
<!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="Waits until `deadline` is reached."><title>sleep_until in tokio::time - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.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"href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="tokio" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-263c88ec.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-eab170b8.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></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]--><rustdoc-topbar><h2><a href="#">sleep_until</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../tokio/index.html">tokio</a><span class="version">1.49.0</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">sleep_<wbr>until</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#cancellation" title="Cancellation">Cancellation</a></li><li><a href="#examples" title="Examples">Examples</a></li><li><a href="#panics" title="Panics">Panics</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="index.html">In tokio::<wbr>time</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../index.html">tokio</a>::<wbr><a href="index.html">time</a></div><h1>Function <span class="fn">sleep_<wbr>until</span>&nbsp;<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/tokio/time/sleep.rs.html#62-64">Source</a> </span></div><pre class="rust item-decl"><code>pub fn sleep_until(deadline: <a class="struct" href="struct.Instant.html" title="struct tokio::time::Instant">Instant</a>) -&gt; <a class="struct" href="struct.Sleep.html" title="struct tokio::time::Sleep">Sleep</a> <a href="#" class="tooltip" data-notable-ty="Sleep"></a></code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Waits until <code>deadline</code> is reached.</p>
<p>No work is performed while awaiting on the sleep future to complete. <code>Sleep</code>
operates at millisecond granularity and should not be used for tasks that
require high-resolution timers.</p>
<p>To run something regularly on a schedule, see <a href="fn.interval.html" title="fn tokio::time::interval"><code>interval</code></a>.</p>
<h2 id="cancellation"><a class="doc-anchor" href="#cancellation">§</a>Cancellation</h2>
<p>Canceling a sleep instance is done by dropping the returned future. No additional
cleanup work is required.</p>
<h2 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h2>
<p>Wait 100ms and print “100 ms have elapsed”.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio::time::{sleep_until, Instant, Duration};
sleep_until(Instant::now() + Duration::from_millis(<span class="number">100</span>)).<span class="kw">await</span>;
<span class="macro">println!</span>(<span class="string">"100 ms have elapsed"</span>);</code></pre></div>
<p>See the documentation for the <a href="struct.Sleep.html" title="struct tokio::time::Sleep"><code>Sleep</code></a> type for more examples.</p>
<h2 id="panics"><a class="doc-anchor" href="#panics">§</a>Panics</h2>
<p>This function panics if there is no current timer set.</p>
<p>It can be triggered when <a href="../runtime/struct.Builder.html#method.enable_time" title="method tokio::runtime::Builder::enable_time"><code>Builder::enable_time</code></a> or
<a href="../runtime/struct.Builder.html#method.enable_all" title="method tokio::runtime::Builder::enable_all"><code>Builder::enable_all</code></a> are not included in the builder.</p>
<p>It can also panic whenever a timer is created outside of a
Tokio runtime. That is why <code>rt.block_on(sleep(...))</code> will panic,
since the function is executed outside of the runtime.
Whereas <code>rt.block_on(async {sleep(...).await})</code> doesnt panic.
And this is because wrapping the function on an async makes it lazy,
and so gets executed inside the runtime successfully without
panicking.</p>
</div></details><script type="text/json" id="notable-traits-data">{"Sleep":"<h3>Notable traits for <code><a class=\"struct\" href=\"struct.Sleep.html\" title=\"struct tokio::time::Sleep\">Sleep</a></code></h3><pre><code><div class=\"where\">impl <a class=\"trait\" href=\"https://doc.rust-lang.org/1.93.1/core/future/future/trait.Future.html\" title=\"trait core::future::future::Future\">Future</a> for <a class=\"struct\" href=\"struct.Sleep.html\" title=\"struct tokio::time::Sleep\">Sleep</a></div><div class=\"where\"> type <a href=\"https://doc.rust-lang.org/1.93.1/core/future/future/trait.Future.html#associatedtype.Output\" class=\"associatedtype\">Output</a> = <a class=\"primitive\" href=\"https://doc.rust-lang.org/1.93.1/std/primitive.unit.html\">()</a>;</div>"}</script></section></div></main></body></html>

View File

@@ -0,0 +1,43 @@
<!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="Requires a `Future` to complete before the specified duration has elapsed."><title>timeout in tokio::time - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.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"href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="tokio" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-263c88ec.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-eab170b8.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></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]--><rustdoc-topbar><h2><a href="#">timeout</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../tokio/index.html">tokio</a><span class="version">1.49.0</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">timeout</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#cancellation" title="Cancellation">Cancellation</a></li><li><a href="#examples" title="Examples">Examples</a></li><li><a href="#panics" title="Panics">Panics</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="index.html">In tokio::<wbr>time</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../index.html">tokio</a>::<wbr><a href="index.html">time</a></div><h1>Function <span class="fn">timeout</span>&nbsp;<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/tokio/time/timeout.rs.html#86-98">Source</a> </span></div><pre class="rust item-decl"><code>pub fn timeout&lt;F&gt;(duration: <a class="struct" href="https://doc.rust-lang.org/1.93.1/core/time/struct.Duration.html" title="struct core::time::Duration">Duration</a>, future: F) -&gt; <a class="struct" href="struct.Timeout.html" title="struct tokio::time::Timeout">Timeout</a>&lt;F::<a class="associatedtype" href="https://doc.rust-lang.org/1.93.1/core/future/into_future/trait.IntoFuture.html#associatedtype.IntoFuture" title="type core::future::into_future::IntoFuture::IntoFuture">IntoFuture</a>&gt; <a href="#" class="tooltip" data-notable-ty="Timeout&lt;F::IntoFuture&gt;"></a><div class="where">where
F: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/future/into_future/trait.IntoFuture.html" title="trait core::future::into_future::IntoFuture">IntoFuture</a>,</div></code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Requires a <code>Future</code> to complete before the specified duration has elapsed.</p>
<p>If the future completes before the duration has elapsed, then the completed
value is returned. Otherwise, an error is returned and the future is
canceled.</p>
<p>Note that the timeout is checked before polling the future, so if the future
does not yield during execution then it is possible for the future to complete
and exceed the timeout <em>without</em> returning an error.</p>
<p>This function returns a future whose return type is <a href="https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html" title="enum core::result::Result"><code>Result</code></a><code>&lt;T,</code><a href="error/struct.Elapsed.html" title="struct tokio::time::error::Elapsed"><code>Elapsed</code></a><code>&gt;</code>, where <code>T</code> is the
return type of the provided future.</p>
<p>If the provided future completes immediately, then the future returned from
this function is guaranteed to complete immediately with an <a href="https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html#variant.Ok" title="variant core::result::Result::Ok"><code>Ok</code></a> variant
no matter the provided duration.</p>
<h2 id="cancellation"><a class="doc-anchor" href="#cancellation">§</a>Cancellation</h2>
<p>Cancelling a timeout is done by dropping the future. No additional cleanup
or other work is required.</p>
<p>The original future may be obtained by calling <a href="struct.Timeout.html#method.into_inner" title="method tokio::time::Timeout::into_inner"><code>Timeout::into_inner</code></a>. This
consumes the <code>Timeout</code>.</p>
<h2 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h2>
<p>Create a new <code>Timeout</code> set to expire in 10 milliseconds.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio::time::timeout;
<span class="kw">use </span>tokio::sync::oneshot;
<span class="kw">use </span>std::time::Duration;
<span class="kw">let </span>(tx, rx) = oneshot::channel();
<span class="comment">// Wrap the future with a `Timeout` set to expire in 10 milliseconds.
</span><span class="kw">if let </span><span class="prelude-val">Err</span>(<span class="kw">_</span>) = timeout(Duration::from_millis(<span class="number">10</span>), rx).<span class="kw">await </span>{
<span class="macro">println!</span>(<span class="string">"did not receive value within 10 ms"</span>);
}</code></pre></div><h2 id="panics"><a class="doc-anchor" href="#panics">§</a>Panics</h2>
<p>This function panics if there is no current timer set.</p>
<p>It can be triggered when <a href="../runtime/struct.Builder.html#method.enable_time" title="method tokio::runtime::Builder::enable_time"><code>Builder::enable_time</code></a> or
<a href="../runtime/struct.Builder.html#method.enable_all" title="method tokio::runtime::Builder::enable_all"><code>Builder::enable_all</code></a> are not included in the builder.</p>
<p>It can also panic whenever a timer is created outside of a
Tokio runtime. That is why <code>rt.block_on(sleep(...))</code> will panic,
since the function is executed outside of the runtime.
Whereas <code>rt.block_on(async {sleep(...).await})</code> doesnt panic.
And this is because wrapping the function on an async makes it lazy,
and so gets executed inside the runtime successfully without
panicking.</p>
</div></details><script type="text/json" id="notable-traits-data">{"Timeout<F::IntoFuture>":"<h3>Notable traits for <code><a class=\"struct\" href=\"struct.Timeout.html\" title=\"struct tokio::time::Timeout\">Timeout</a>&lt;T&gt;</code></h3><pre><code><div class=\"where\">impl&lt;T&gt; <a class=\"trait\" href=\"https://doc.rust-lang.org/1.93.1/core/future/future/trait.Future.html\" title=\"trait core::future::future::Future\">Future</a> for <a class=\"struct\" href=\"struct.Timeout.html\" title=\"struct tokio::time::Timeout\">Timeout</a>&lt;T&gt;<div class=\"where\">where\n T: <a class=\"trait\" href=\"https://doc.rust-lang.org/1.93.1/core/future/future/trait.Future.html\" title=\"trait core::future::future::Future\">Future</a>,</div></div><div class=\"where\"> type <a href=\"https://doc.rust-lang.org/1.93.1/core/future/future/trait.Future.html#associatedtype.Output\" class=\"associatedtype\">Output</a> = <a class=\"enum\" href=\"https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html\" title=\"enum core::result::Result\">Result</a>&lt;T::<a class=\"associatedtype\" href=\"https://doc.rust-lang.org/1.93.1/core/future/future/trait.Future.html#associatedtype.Output\" title=\"type core::future::future::Future::Output\">Output</a>, <a class=\"struct\" href=\"error/struct.Elapsed.html\" title=\"struct tokio::time::error::Elapsed\">Elapsed</a>&gt;;</div>"}</script></section></div></main></body></html>

View File

@@ -0,0 +1,29 @@
<!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="Requires a `Future` to complete before the specified instant in time."><title>timeout_at in tokio::time - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.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"href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="tokio" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-263c88ec.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-eab170b8.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></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]--><rustdoc-topbar><h2><a href="#">timeout_at</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../tokio/index.html">tokio</a><span class="version">1.49.0</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">timeout_<wbr>at</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#cancellation" title="Cancellation">Cancellation</a></li><li><a href="#examples" title="Examples">Examples</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="index.html">In tokio::<wbr>time</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../index.html">tokio</a>::<wbr><a href="index.html">time</a></div><h1>Function <span class="fn">timeout_<wbr>at</span>&nbsp;<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/tokio/time/timeout.rs.html#145-155">Source</a> </span></div><pre class="rust item-decl"><code>pub fn timeout_at&lt;F&gt;(deadline: <a class="struct" href="struct.Instant.html" title="struct tokio::time::Instant">Instant</a>, future: F) -&gt; <a class="struct" href="struct.Timeout.html" title="struct tokio::time::Timeout">Timeout</a>&lt;F::<a class="associatedtype" href="https://doc.rust-lang.org/1.93.1/core/future/into_future/trait.IntoFuture.html#associatedtype.IntoFuture" title="type core::future::into_future::IntoFuture::IntoFuture">IntoFuture</a>&gt; <a href="#" class="tooltip" data-notable-ty="Timeout&lt;F::IntoFuture&gt;"></a><div class="where">where
F: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/future/into_future/trait.IntoFuture.html" title="trait core::future::into_future::IntoFuture">IntoFuture</a>,</div></code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Requires a <code>Future</code> to complete before the specified instant in time.</p>
<p>If the future completes before the instant is reached, then the completed
value is returned. Otherwise, an error is returned.</p>
<p>This function returns a future whose return type is <a href="https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html" title="enum core::result::Result"><code>Result</code></a><code>&lt;T,</code><a href="error/struct.Elapsed.html" title="struct tokio::time::error::Elapsed"><code>Elapsed</code></a><code>&gt;</code>, where <code>T</code> is the
return type of the provided future.</p>
<p>If the provided future completes immediately, then the future returned from
this function is guaranteed to complete immediately with an <a href="https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html#variant.Ok" title="variant core::result::Result::Ok"><code>Ok</code></a> variant
no matter the provided deadline.</p>
<h2 id="cancellation"><a class="doc-anchor" href="#cancellation">§</a>Cancellation</h2>
<p>Cancelling a timeout is done by dropping the future. No additional cleanup
or other work is required.</p>
<p>The original future may be obtained by calling <a href="struct.Timeout.html#method.into_inner" title="method tokio::time::Timeout::into_inner"><code>Timeout::into_inner</code></a>. This
consumes the <code>Timeout</code>.</p>
<h2 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h2>
<p>Create a new <code>Timeout</code> set to expire in 10 milliseconds.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio::time::{Instant, timeout_at};
<span class="kw">use </span>tokio::sync::oneshot;
<span class="kw">use </span>std::time::Duration;
<span class="kw">let </span>(tx, rx) = oneshot::channel();
<span class="comment">// Wrap the future with a `Timeout` set to expire 10 milliseconds into the
// future.
</span><span class="kw">if let </span><span class="prelude-val">Err</span>(<span class="kw">_</span>) = timeout_at(Instant::now() + Duration::from_millis(<span class="number">10</span>), rx).<span class="kw">await </span>{
<span class="macro">println!</span>(<span class="string">"did not receive value within 10 ms"</span>);
}</code></pre></div></div></details><script type="text/json" id="notable-traits-data">{"Timeout<F::IntoFuture>":"<h3>Notable traits for <code><a class=\"struct\" href=\"struct.Timeout.html\" title=\"struct tokio::time::Timeout\">Timeout</a>&lt;T&gt;</code></h3><pre><code><div class=\"where\">impl&lt;T&gt; <a class=\"trait\" href=\"https://doc.rust-lang.org/1.93.1/core/future/future/trait.Future.html\" title=\"trait core::future::future::Future\">Future</a> for <a class=\"struct\" href=\"struct.Timeout.html\" title=\"struct tokio::time::Timeout\">Timeout</a>&lt;T&gt;<div class=\"where\">where\n T: <a class=\"trait\" href=\"https://doc.rust-lang.org/1.93.1/core/future/future/trait.Future.html\" title=\"trait core::future::future::Future\">Future</a>,</div></div><div class=\"where\"> type <a href=\"https://doc.rust-lang.org/1.93.1/core/future/future/trait.Future.html#associatedtype.Output\" class=\"associatedtype\">Output</a> = <a class=\"enum\" href=\"https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html\" title=\"enum core::result::Result\">Result</a>&lt;T::<a class=\"associatedtype\" href=\"https://doc.rust-lang.org/1.93.1/core/future/future/trait.Future.html#associatedtype.Output\" title=\"type core::future::future::Future::Output\">Output</a>, <a class=\"struct\" href=\"error/struct.Elapsed.html\" title=\"struct tokio::time::error::Elapsed\">Elapsed</a>&gt;;</div>"}</script></section></div></main></body></html>

View File

@@ -0,0 +1,71 @@
<!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="Utilities for tracking time."><title>tokio::time - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.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"href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="tokio" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../../static.files/storage-e2aeef58.js"></script><script defer src="../sidebar-items.js"></script><script defer src="../../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-263c88ec.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-eab170b8.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></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]--><rustdoc-topbar><h2><a href="#">Module time</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../tokio/index.html">tokio</a><span class="version">1.49.0</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Module time</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#examples" title="Examples">Examples</a></li></ul><h3><a href="#reexports">Module Items</a></h3><ul class="block"><li><a href="#reexports" title="Re-exports">Re-exports</a></li><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"><h2 class="in-crate"><a href="../index.html">In crate tokio</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../index.html">tokio</a></div><h1>Module <span>time</span>&nbsp;<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/tokio/time/mod.rs.html#1-110">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Utilities for tracking time.</p>
<p>This module provides a number of types for executing code after a set period
of time.</p>
<ul>
<li>
<p><a href="fn.sleep.html" title="fn tokio::time::sleep"><code>Sleep</code></a> is a future that does no work and completes at a specific <a href="struct.Instant.html" title="struct tokio::time::Instant"><code>Instant</code></a>
in time.</p>
</li>
<li>
<p><a href="fn.interval.html" title="fn tokio::time::interval"><code>Interval</code></a> is a stream yielding a value at a fixed period. It is
initialized with a <a href="https://doc.rust-lang.org/1.93.1/core/time/struct.Duration.html" title="struct core::time::Duration"><code>Duration</code></a> and repeatedly yields each time the duration
elapses.</p>
</li>
<li>
<p><a href="struct.Timeout.html" title="struct tokio::time::Timeout"><code>Timeout</code></a>: Wraps a future or stream, setting an upper bound to the amount
of time it is allowed to execute. If the future or stream does not
complete in time, then it is canceled and an error is returned.</p>
</li>
</ul>
<p>These types are sufficient for handling a large number of scenarios
involving time.</p>
<p>These types must be used from within the context of the <a href="../runtime/struct.Runtime.html" title="struct tokio::runtime::Runtime"><code>Runtime</code></a>.</p>
<h2 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h2>
<p>Wait 100ms and print “100 ms have elapsed”</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::time::Duration;
<span class="kw">use </span>tokio::time::sleep;
sleep(Duration::from_millis(<span class="number">100</span>)).<span class="kw">await</span>;
<span class="macro">println!</span>(<span class="string">"100 ms have elapsed"</span>);</code></pre></div>
<p>Require that an operation takes no more than 1s.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio::time::{timeout, Duration};
<span class="kw">async fn </span>long_future() {
<span class="comment">// do work here
</span>}
<span class="kw">let </span>res = timeout(Duration::from_secs(<span class="number">1</span>), long_future()).<span class="kw">await</span>;
<span class="kw">if </span>res.is_err() {
<span class="macro">println!</span>(<span class="string">"operation timed out"</span>);
}</code></pre></div>
<p>A simple example using <a href="fn.interval.html" title="fn tokio::time::interval"><code>interval</code></a> to execute a task every two seconds.</p>
<p>The difference between <a href="fn.interval.html" title="fn tokio::time::interval"><code>interval</code></a> and <a href="fn.sleep.html" title="fn tokio::time::sleep"><code>sleep</code></a> is that an <a href="fn.interval.html" title="fn tokio::time::interval"><code>interval</code></a>
measures the time since the last tick, which means that <code>.tick().await</code> may
wait for a shorter time than the duration specified for the interval
if some time has passed between calls to <code>.tick().await</code>.</p>
<p>If the tick in the example below was replaced with <a href="fn.sleep.html" title="fn tokio::time::sleep"><code>sleep</code></a>, the task
would only be executed once every three seconds, and not every two
seconds.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio::time;
<span class="kw">async fn </span>task_that_takes_a_second() {
<span class="macro">println!</span>(<span class="string">"hello"</span>);
time::sleep(time::Duration::from_secs(<span class="number">1</span>)).<span class="kw">await
</span>}
<span class="kw">let </span><span class="kw-2">mut </span>interval = time::interval(time::Duration::from_secs(<span class="number">2</span>));
<span class="kw">for </span>_i <span class="kw">in </span><span class="number">0</span>..<span class="number">5 </span>{
interval.tick().<span class="kw">await</span>;
task_that_takes_a_second().<span class="kw">await</span>;
}</code></pre></div></div></details><h2 id="reexports" class="section-header">Re-exports<a href="#reexports" class="anchor">§</a></h2><dl class="item-table reexports"><dt id="reexport.Duration"><code>pub use std::time::<a class="struct" href="https://doc.rust-lang.org/1.93.1/core/time/struct.Duration.html" title="struct core::time::Duration">Duration</a>;</code></dt></dl><h2 id="modules" class="section-header">Modules<a href="#modules" class="anchor">§</a></h2><dl class="item-table"><dt><a class="mod" href="error/index.html" title="mod tokio::time::error">error</a></dt><dd>Time error types.</dd></dl><h2 id="structs" class="section-header">Structs<a href="#structs" class="anchor">§</a></h2><dl class="item-table"><dt><a class="struct" href="struct.Instant.html" title="struct tokio::time::Instant">Instant</a></dt><dd>A measurement of a monotonically nondecreasing clock.
Opaque and useful only with <code>Duration</code>.</dd><dt><a class="struct" href="struct.Interval.html" title="struct tokio::time::Interval">Interval</a></dt><dd>Interval returned by <a href="fn.interval.html" title="fn tokio::time::interval"><code>interval</code></a> and <a href="fn.interval_at.html" title="fn tokio::time::interval_at"><code>interval_at</code></a>.</dd><dt><a class="struct" href="struct.Sleep.html" title="struct tokio::time::Sleep">Sleep</a></dt><dd>Future returned by <a href="fn.sleep.html" title="fn tokio::time::sleep"><code>sleep</code></a> and <a href="fn.sleep_until.html" title="fn tokio::time::sleep_until"><code>sleep_until</code></a>.</dd><dt><a class="struct" href="struct.Timeout.html" title="struct tokio::time::Timeout">Timeout</a></dt><dd>Future returned by <a href="fn.timeout.html" title="fn tokio::time::timeout"><code>timeout</code></a> and <a href="fn.timeout_at.html" title="fn tokio::time::timeout_at"><code>timeout_at</code></a>.</dd></dl><h2 id="enums" class="section-header">Enums<a href="#enums" class="anchor">§</a></h2><dl class="item-table"><dt><a class="enum" href="enum.MissedTickBehavior.html" title="enum tokio::time::MissedTickBehavior">Missed<wbr>Tick<wbr>Behavior</a></dt><dd>Defines the behavior of an <a href="struct.Interval.html" title="struct tokio::time::Interval"><code>Interval</code></a> when it misses a tick.</dd></dl><h2 id="functions" class="section-header">Functions<a href="#functions" class="anchor">§</a></h2><dl class="item-table"><dt><a class="fn" href="fn.interval.html" title="fn tokio::time::interval">interval</a></dt><dd>Creates new <a href="struct.Interval.html" title="struct tokio::time::Interval"><code>Interval</code></a> that yields with interval of <code>period</code>. The first
tick completes immediately. The default <a href="enum.MissedTickBehavior.html" title="enum tokio::time::MissedTickBehavior"><code>MissedTickBehavior</code></a> is
<a href="enum.MissedTickBehavior.html#variant.Burst" title="variant tokio::time::MissedTickBehavior::Burst"><code>Burst</code></a>, but this can be configured
by calling <a href="struct.Interval.html#method.set_missed_tick_behavior" title="method tokio::time::Interval::set_missed_tick_behavior"><code>set_missed_tick_behavior</code></a>.</dd><dt><a class="fn" href="fn.interval_at.html" title="fn tokio::time::interval_at">interval_<wbr>at</a></dt><dd>Creates new <a href="struct.Interval.html" title="struct tokio::time::Interval"><code>Interval</code></a> that yields with interval of <code>period</code> with the
first tick completing at <code>start</code>. The default <a href="enum.MissedTickBehavior.html" title="enum tokio::time::MissedTickBehavior"><code>MissedTickBehavior</code></a> is
<a href="enum.MissedTickBehavior.html#variant.Burst" title="variant tokio::time::MissedTickBehavior::Burst"><code>Burst</code></a>, but this can be configured
by calling <a href="struct.Interval.html#method.set_missed_tick_behavior" title="method tokio::time::Interval::set_missed_tick_behavior"><code>set_missed_tick_behavior</code></a>.</dd><dt><a class="fn" href="fn.sleep.html" title="fn tokio::time::sleep">sleep</a></dt><dd>Waits until <code>duration</code> has elapsed.</dd><dt><a class="fn" href="fn.sleep_until.html" title="fn tokio::time::sleep_until">sleep_<wbr>until</a></dt><dd>Waits until <code>deadline</code> is reached.</dd><dt><a class="fn" href="fn.timeout.html" title="fn tokio::time::timeout">timeout</a></dt><dd>Requires a <code>Future</code> to complete before the specified duration has elapsed.</dd><dt><a class="fn" href="fn.timeout_at.html" title="fn tokio::time::timeout_at">timeout_<wbr>at</a></dt><dd>Requires a <code>Future</code> to complete before the specified instant in time.</dd></dl></section></div></main></body></html>

View File

@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="refresh" content="0;URL=../../../tokio/time/struct.Instant.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="../../../tokio/time/struct.Instant.html">../../../tokio/time/struct.Instant.html</a>...</p>
<script>location.replace("../../../tokio/time/struct.Instant.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=../../../tokio/time/enum.MissedTickBehavior.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="../../../tokio/time/enum.MissedTickBehavior.html">../../../tokio/time/enum.MissedTickBehavior.html</a>...</p>
<script>location.replace("../../../tokio/time/enum.MissedTickBehavior.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=../../../tokio/time/fn.interval.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="../../../tokio/time/fn.interval.html">../../../tokio/time/fn.interval.html</a>...</p>
<script>location.replace("../../../tokio/time/fn.interval.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=../../../tokio/time/fn.interval_at.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="../../../tokio/time/fn.interval_at.html">../../../tokio/time/fn.interval_at.html</a>...</p>
<script>location.replace("../../../tokio/time/fn.interval_at.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=../../../tokio/time/struct.Interval.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="../../../tokio/time/struct.Interval.html">../../../tokio/time/struct.Interval.html</a>...</p>
<script>location.replace("../../../tokio/time/struct.Interval.html" + location.search + location.hash);</script>
</body>
</html>

View File

@@ -0,0 +1 @@
window.SIDEBAR_ITEMS = {"enum":["MissedTickBehavior"],"fn":["interval","interval_at","sleep","sleep_until","timeout","timeout_at"],"mod":["error"],"struct":["Instant","Interval","Sleep","Timeout"]};

View File

@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="refresh" content="0;URL=../../../tokio/time/fn.sleep.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="../../../tokio/time/fn.sleep.html">../../../tokio/time/fn.sleep.html</a>...</p>
<script>location.replace("../../../tokio/time/fn.sleep.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=../../../tokio/time/fn.sleep_until.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="../../../tokio/time/fn.sleep_until.html">../../../tokio/time/fn.sleep_until.html</a>...</p>
<script>location.replace("../../../tokio/time/fn.sleep_until.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=../../../tokio/time/struct.Sleep.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="../../../tokio/time/struct.Sleep.html">../../../tokio/time/struct.Sleep.html</a>...</p>
<script>location.replace("../../../tokio/time/struct.Sleep.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

View File

@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="refresh" content="0;URL=../../../tokio/time/fn.timeout.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="../../../tokio/time/fn.timeout.html">../../../tokio/time/fn.timeout.html</a>...</p>
<script>location.replace("../../../tokio/time/fn.timeout.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=../../../tokio/time/fn.timeout_at.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="../../../tokio/time/fn.timeout_at.html">../../../tokio/time/fn.timeout_at.html</a>...</p>
<script>location.replace("../../../tokio/time/fn.timeout_at.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=../../../tokio/time/struct.Timeout.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="../../../tokio/time/struct.Timeout.html">../../../tokio/time/struct.Timeout.html</a>...</p>
<script>location.replace("../../../tokio/time/struct.Timeout.html" + location.search + location.hash);</script>
</body>
</html>