1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-06-30 16:34:26 +02:00

Deploying to gh-pages from @ actix/actix-web@26efa64278 🚀

This commit is contained in:
github-merge-queue[bot]
2024-05-27 01:16:31 +00:00
commit a33fe13cd1
1715 changed files with 215638 additions and 0 deletions

View File

@ -0,0 +1,48 @@
<!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 actix_web::rt::time - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-46f98efaafac5295.ttf.woff2,FiraSans-Regular-018c141bf0843ffd.woff2,FiraSans-Medium-8f9a781e4970d388.woff2,SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2,SourceCodePro-Semibold-d899c5a5c4aeb14a.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-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../static.files/rustdoc-dd39b87e5fcfba68.css"><meta name="rustdoc-vars" data-root-path="../../../" data-static-root-path="../../../static.files/" data-current-crate="actix_web" data-themes="" data-resource-suffix="" data-rustdoc-version="1.80.0-nightly (bdbbb6c6a 2024-05-26)" data-channel="nightly" data-search-js="search-d52510db62a78183.js" data-settings-js="settings-4313503d2e1961c2.js" ><script src="../../../static.files/storage-118b08c4c78b968e.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../../static.files/main-20a3ad099b048cf2.js"></script><noscript><link rel="stylesheet" href="../../../static.files/noscript-df360f571f6edeae.css"></noscript><link rel="icon" href="https://actix.rs/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="../../../actix_web/index.html"><img src="https://actix.rs/img/logo.png" alt=""></a></nav><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../../../actix_web/index.html"><img src="https://actix.rs/img/logo.png" alt="logo"></a><h2><a href="../../../actix_web/index.html">actix_web</a><span class="version">4.6.0</span></h2></div><div class="sidebar-elems"><h2><a href="index.html">In actix_web::rt::time</a></h2></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>Function <a href="../../index.html">actix_web</a>::<wbr><a href="../index.html">rt</a>::<wbr><a href="index.html">time</a>::<wbr><a class="fn" href="#">interval</a><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><span class="out-of-band"><button id="toggle-all-docs" title="collapse all docs">[<span>&#x2212;</span>]</button></span></div><pre class="rust item-decl"><code>pub fn interval(period: <a class="struct" href="https://doc.rust-lang.org/nightly/core/time/struct.Duration.html" title="struct core::time::Duration">Duration</a>) -&gt; <a class="struct" href="struct.Interval.html" title="struct actix_web::rt::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 actix_web::rt::time::Interval"><code>Interval</code></a> that yields with interval of <code>period</code>. The first
tick completes immediately. The default [<code>MissedTickBehavior</code>] is
<a href="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 actix_web::rt::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 actix_web::rt::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 actix_web::rt::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="attr">#[tokio::main]
</span><span class="kw">async fn </span>main() {
<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 actix_web::rt::time::sleep"><code>sleep</code></a> is that an <a href="struct.Interval.html" title="struct actix_web::rt::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 actix_web::rt::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 actix_web::rt::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 actix_web::rt::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="attr">#[tokio::main]
</span><span class="kw">async fn </span>main() {
<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,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="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 actix_web::rt::time - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-46f98efaafac5295.ttf.woff2,FiraSans-Regular-018c141bf0843ffd.woff2,FiraSans-Medium-8f9a781e4970d388.woff2,SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2,SourceCodePro-Semibold-d899c5a5c4aeb14a.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-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../static.files/rustdoc-dd39b87e5fcfba68.css"><meta name="rustdoc-vars" data-root-path="../../../" data-static-root-path="../../../static.files/" data-current-crate="actix_web" data-themes="" data-resource-suffix="" data-rustdoc-version="1.80.0-nightly (bdbbb6c6a 2024-05-26)" data-channel="nightly" data-search-js="search-d52510db62a78183.js" data-settings-js="settings-4313503d2e1961c2.js" ><script src="../../../static.files/storage-118b08c4c78b968e.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../../static.files/main-20a3ad099b048cf2.js"></script><noscript><link rel="stylesheet" href="../../../static.files/noscript-df360f571f6edeae.css"></noscript><link rel="icon" href="https://actix.rs/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="../../../actix_web/index.html"><img src="https://actix.rs/img/logo.png" alt=""></a></nav><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../../../actix_web/index.html"><img src="https://actix.rs/img/logo.png" alt="logo"></a><h2><a href="../../../actix_web/index.html">actix_web</a><span class="version">4.6.0</span></h2></div><div class="sidebar-elems"><h2><a href="index.html">In actix_web::rt::time</a></h2></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>Function <a href="../../index.html">actix_web</a>::<wbr><a href="../index.html">rt</a>::<wbr><a href="index.html">time</a>::<wbr><a class="fn" href="#">interval_at</a><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><span class="out-of-band"><button id="toggle-all-docs" title="collapse all docs">[<span>&#x2212;</span>]</button></span></div><pre class="rust item-decl"><code>pub fn interval_at(start: <a class="struct" href="struct.Instant.html" title="struct actix_web::rt::time::Instant">Instant</a>, period: <a class="struct" href="https://doc.rust-lang.org/nightly/core/time/struct.Duration.html" title="struct core::time::Duration">Duration</a>) -&gt; <a class="struct" href="struct.Interval.html" title="struct actix_web::rt::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 actix_web::rt::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 [<code>MissedTickBehavior</code>] is
<a href="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 actix_web::rt::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 actix_web::rt::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="attr">#[tokio::main]
</span><span class="kw">async fn </span>main() {
<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,36 @@
<!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 actix_web::rt::time - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-46f98efaafac5295.ttf.woff2,FiraSans-Regular-018c141bf0843ffd.woff2,FiraSans-Medium-8f9a781e4970d388.woff2,SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2,SourceCodePro-Semibold-d899c5a5c4aeb14a.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-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../static.files/rustdoc-dd39b87e5fcfba68.css"><meta name="rustdoc-vars" data-root-path="../../../" data-static-root-path="../../../static.files/" data-current-crate="actix_web" data-themes="" data-resource-suffix="" data-rustdoc-version="1.80.0-nightly (bdbbb6c6a 2024-05-26)" data-channel="nightly" data-search-js="search-d52510db62a78183.js" data-settings-js="settings-4313503d2e1961c2.js" ><script src="../../../static.files/storage-118b08c4c78b968e.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../../static.files/main-20a3ad099b048cf2.js"></script><noscript><link rel="stylesheet" href="../../../static.files/noscript-df360f571f6edeae.css"></noscript><link rel="icon" href="https://actix.rs/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="../../../actix_web/index.html"><img src="https://actix.rs/img/logo.png" alt=""></a></nav><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../../../actix_web/index.html"><img src="https://actix.rs/img/logo.png" alt="logo"></a><h2><a href="../../../actix_web/index.html">actix_web</a><span class="version">4.6.0</span></h2></div><div class="sidebar-elems"><h2><a href="index.html">In actix_web::rt::time</a></h2></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>Function <a href="../../index.html">actix_web</a>::<wbr><a href="../index.html">rt</a>::<wbr><a href="index.html">time</a>::<wbr><a class="fn" href="#">sleep</a><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><span class="out-of-band"><button id="toggle-all-docs" title="collapse all docs">[<span>&#x2212;</span>]</button></span></div><pre class="rust item-decl"><code>pub fn sleep(duration: <a class="struct" href="https://doc.rust-lang.org/nightly/core/time/struct.Duration.html" title="struct core::time::Duration">Duration</a>) -&gt; <a class="struct" href="struct.Sleep.html" title="struct actix_web::rt::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 actix_web::rt::time::interval"><code>interval</code></a>.</p>
<p>The maximum duration for a sleep is 68719476734 milliseconds (approximately 2.2 years).</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};
<span class="attr">#[tokio::main]
</span><span class="kw">async fn </span>main() {
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 actix_web::rt::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="crate::runtime::Builder::enable_time"><code>Builder::enable_time</code></a> or
<a href="crate::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 actix_web::rt::time::Sleep\">Sleep</a></code></h3><pre><code><div class=\"where\">impl <a class=\"trait\" href=\"https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html\" title=\"trait core::future::future::Future\">Future</a> for <a class=\"struct\" href=\"struct.Sleep.html\" title=\"struct actix_web::rt::time::Sleep\">Sleep</a></div><div class=\"where\"> type <a href=\"https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output\" class=\"associatedtype\">Output</a> = <a class=\"primitive\" href=\"https://doc.rust-lang.org/nightly/std/primitive.unit.html\">()</a>;</div>"}</script></section></div></main></body></html>

View File

@ -0,0 +1,31 @@
<!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 actix_web::rt::time - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-46f98efaafac5295.ttf.woff2,FiraSans-Regular-018c141bf0843ffd.woff2,FiraSans-Medium-8f9a781e4970d388.woff2,SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2,SourceCodePro-Semibold-d899c5a5c4aeb14a.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-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../static.files/rustdoc-dd39b87e5fcfba68.css"><meta name="rustdoc-vars" data-root-path="../../../" data-static-root-path="../../../static.files/" data-current-crate="actix_web" data-themes="" data-resource-suffix="" data-rustdoc-version="1.80.0-nightly (bdbbb6c6a 2024-05-26)" data-channel="nightly" data-search-js="search-d52510db62a78183.js" data-settings-js="settings-4313503d2e1961c2.js" ><script src="../../../static.files/storage-118b08c4c78b968e.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../../static.files/main-20a3ad099b048cf2.js"></script><noscript><link rel="stylesheet" href="../../../static.files/noscript-df360f571f6edeae.css"></noscript><link rel="icon" href="https://actix.rs/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="../../../actix_web/index.html"><img src="https://actix.rs/img/logo.png" alt=""></a></nav><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../../../actix_web/index.html"><img src="https://actix.rs/img/logo.png" alt="logo"></a><h2><a href="../../../actix_web/index.html">actix_web</a><span class="version">4.6.0</span></h2></div><div class="sidebar-elems"><h2><a href="index.html">In actix_web::rt::time</a></h2></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>Function <a href="../../index.html">actix_web</a>::<wbr><a href="../index.html">rt</a>::<wbr><a href="index.html">time</a>::<wbr><a class="fn" href="#">sleep_until</a><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><span class="out-of-band"><button id="toggle-all-docs" title="collapse all docs">[<span>&#x2212;</span>]</button></span></div><pre class="rust item-decl"><code>pub fn sleep_until(deadline: <a class="struct" href="struct.Instant.html" title="struct actix_web::rt::time::Instant">Instant</a>) -&gt; <a class="struct" href="struct.Sleep.html" title="struct actix_web::rt::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 actix_web::rt::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};
<span class="attr">#[tokio::main]
</span><span class="kw">async fn </span>main() {
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 actix_web::rt::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="crate::runtime::Builder::enable_time"><code>Builder::enable_time</code></a> or
<a href="crate::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 actix_web::rt::time::Sleep\">Sleep</a></code></h3><pre><code><div class=\"where\">impl <a class=\"trait\" href=\"https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html\" title=\"trait core::future::future::Future\">Future</a> for <a class=\"struct\" href=\"struct.Sleep.html\" title=\"struct actix_web::rt::time::Sleep\">Sleep</a></div><div class=\"where\"> type <a href=\"https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output\" class=\"associatedtype\">Output</a> = <a class=\"primitive\" href=\"https://doc.rust-lang.org/nightly/std/primitive.unit.html\">()</a>;</div>"}</script></section></div></main></body></html>

View File

@ -0,0 +1,44 @@
<!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 actix_web::rt::time - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-46f98efaafac5295.ttf.woff2,FiraSans-Regular-018c141bf0843ffd.woff2,FiraSans-Medium-8f9a781e4970d388.woff2,SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2,SourceCodePro-Semibold-d899c5a5c4aeb14a.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-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../static.files/rustdoc-dd39b87e5fcfba68.css"><meta name="rustdoc-vars" data-root-path="../../../" data-static-root-path="../../../static.files/" data-current-crate="actix_web" data-themes="" data-resource-suffix="" data-rustdoc-version="1.80.0-nightly (bdbbb6c6a 2024-05-26)" data-channel="nightly" data-search-js="search-d52510db62a78183.js" data-settings-js="settings-4313503d2e1961c2.js" ><script src="../../../static.files/storage-118b08c4c78b968e.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../../static.files/main-20a3ad099b048cf2.js"></script><noscript><link rel="stylesheet" href="../../../static.files/noscript-df360f571f6edeae.css"></noscript><link rel="icon" href="https://actix.rs/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="../../../actix_web/index.html"><img src="https://actix.rs/img/logo.png" alt=""></a></nav><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../../../actix_web/index.html"><img src="https://actix.rs/img/logo.png" alt="logo"></a><h2><a href="../../../actix_web/index.html">actix_web</a><span class="version">4.6.0</span></h2></div><div class="sidebar-elems"><h2><a href="index.html">In actix_web::rt::time</a></h2></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>Function <a href="../../index.html">actix_web</a>::<wbr><a href="../index.html">rt</a>::<wbr><a href="index.html">time</a>::<wbr><a class="fn" href="#">timeout</a><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><span class="out-of-band"><button id="toggle-all-docs" title="collapse all docs">[<span>&#x2212;</span>]</button></span></div><pre class="rust item-decl"><code>pub fn timeout&lt;F&gt;(duration: <a class="struct" href="https://doc.rust-lang.org/nightly/core/time/struct.Duration.html" title="struct core::time::Duration">Duration</a>, future: F) -&gt; <a class="struct" href="struct.Timeout.html" title="struct actix_web::rt::time::Timeout">Timeout</a>&lt;F&gt; <a href="#" class="tooltip" data-notable-ty="Timeout&lt;F&gt;"></a><div class="where">where
F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>,</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/nightly/core/result/enum.Result.html" title="enum core::result::Result"><code>Result</code></a><code>&lt;T,</code><a href="crate::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/nightly/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 actix_web::rt::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="crate::runtime::Builder::enable_time"><code>Builder::enable_time</code></a> or
<a href="crate::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>":"<h3>Notable traits for <code><a class=\"struct\" href=\"struct.Timeout.html\" title=\"struct actix_web::rt::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/nightly/core/future/future/trait.Future.html\" title=\"trait core::future::future::Future\">Future</a> for <a class=\"struct\" href=\"struct.Timeout.html\" title=\"struct actix_web::rt::time::Timeout\">Timeout</a>&lt;T&gt;<div class=\"where\">where\n T: <a class=\"trait\" href=\"https://doc.rust-lang.org/nightly/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/nightly/core/future/future/trait.Future.html#associatedtype.Output\" class=\"associatedtype\">Output</a> = <a class=\"enum\" href=\"https://doc.rust-lang.org/nightly/core/result/enum.Result.html\" title=\"enum core::result::Result\">Result</a>&lt;&lt;T as <a class=\"trait\" href=\"https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html\" title=\"trait core::future::future::Future\">Future</a>&gt;::<a class=\"associatedtype\" href=\"https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output\" title=\"type core::future::future::Future::Output\">Output</a>, Elapsed&gt;;</div>"}</script></section></div></main></body></html>

View File

@ -0,0 +1,9 @@
<!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 (Tokio re-exports)."><title>actix_web::rt::time - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-46f98efaafac5295.ttf.woff2,FiraSans-Regular-018c141bf0843ffd.woff2,FiraSans-Medium-8f9a781e4970d388.woff2,SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2,SourceCodePro-Semibold-d899c5a5c4aeb14a.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-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../../static.files/rustdoc-dd39b87e5fcfba68.css"><meta name="rustdoc-vars" data-root-path="../../../" data-static-root-path="../../../static.files/" data-current-crate="actix_web" data-themes="" data-resource-suffix="" data-rustdoc-version="1.80.0-nightly (bdbbb6c6a 2024-05-26)" data-channel="nightly" data-search-js="search-d52510db62a78183.js" data-settings-js="settings-4313503d2e1961c2.js" ><script src="../../../static.files/storage-118b08c4c78b968e.js"></script><script defer src="../sidebar-items.js"></script><script defer src="../../../static.files/main-20a3ad099b048cf2.js"></script><noscript><link rel="stylesheet" href="../../../static.files/noscript-df360f571f6edeae.css"></noscript><link rel="icon" href="https://actix.rs/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="../../../actix_web/index.html"><img src="https://actix.rs/img/logo.png" alt=""></a></nav><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../../../actix_web/index.html"><img src="https://actix.rs/img/logo.png" alt="logo"></a><h2><a href="../../../actix_web/index.html">actix_web</a><span class="version">4.6.0</span></h2></div><h2 class="location"><a href="#">Module time</a></h2><div class="sidebar-elems"><section><ul class="block"><li><a href="#structs">Structs</a></li><li><a href="#functions">Functions</a></li></ul></section><h2><a href="../index.html">In actix_web::rt</a></h2></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>Module <a href="../../index.html">actix_web</a>::<wbr><a href="../index.html">rt</a>::<wbr><a class="mod" href="#">time</a><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><span class="out-of-band"><button id="toggle-all-docs" title="collapse all docs">[<span>&#x2212;</span>]</button></span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Utilities for tracking time (Tokio re-exports).</p>
</div></details><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.Instant.html" title="struct actix_web::rt::time::Instant">Instant</a></div><div class="desc docblock-short">A measurement of a monotonically nondecreasing clock.
Opaque and useful only with <code>Duration</code>.</div></li><li><div class="item-name"><a class="struct" href="struct.Interval.html" title="struct actix_web::rt::time::Interval">Interval</a></div><div class="desc docblock-short">Interval returned by <a href="fn.interval.html" title="fn actix_web::rt::time::interval"><code>interval</code></a> and <a href="fn.interval_at.html" title="fn actix_web::rt::time::interval_at"><code>interval_at</code></a>.</div></li><li><div class="item-name"><a class="struct" href="struct.Sleep.html" title="struct actix_web::rt::time::Sleep">Sleep</a></div><div class="desc docblock-short">Future returned by <a href="fn.sleep.html" title="fn actix_web::rt::time::sleep"><code>sleep</code></a> and <a href="fn.sleep_until.html" title="fn actix_web::rt::time::sleep_until"><code>sleep_until</code></a>.</div></li><li><div class="item-name"><a class="struct" href="struct.Timeout.html" title="struct actix_web::rt::time::Timeout">Timeout</a></div><div class="desc docblock-short">Future returned by <a href="fn.timeout.html" title="fn actix_web::rt::time::timeout"><code>timeout</code></a> and <a href="timeout_at"><code>timeout_at</code></a>.</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.interval.html" title="fn actix_web::rt::time::interval">interval</a></div><div class="desc docblock-short">Creates new <a href="struct.Interval.html" title="struct actix_web::rt::time::Interval"><code>Interval</code></a> that yields with interval of <code>period</code>. The first
tick completes immediately. The default [<code>MissedTickBehavior</code>] is
<a href="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 actix_web::rt::time::Interval::set_missed_tick_behavior"><code>set_missed_tick_behavior</code></a>.</div></li><li><div class="item-name"><a class="fn" href="fn.interval_at.html" title="fn actix_web::rt::time::interval_at">interval_at</a></div><div class="desc docblock-short">Creates new <a href="struct.Interval.html" title="struct actix_web::rt::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 [<code>MissedTickBehavior</code>] is
<a href="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 actix_web::rt::time::Interval::set_missed_tick_behavior"><code>set_missed_tick_behavior</code></a>.</div></li><li><div class="item-name"><a class="fn" href="fn.sleep.html" title="fn actix_web::rt::time::sleep">sleep</a></div><div class="desc docblock-short">Waits until <code>duration</code> has elapsed.</div></li><li><div class="item-name"><a class="fn" href="fn.sleep_until.html" title="fn actix_web::rt::time::sleep_until">sleep_until</a></div><div class="desc docblock-short">Waits until <code>deadline</code> is reached.</div></li><li><div class="item-name"><a class="fn" href="fn.timeout.html" title="fn actix_web::rt::time::timeout">timeout</a></div><div class="desc docblock-short">Requires a <code>Future</code> to complete before the specified duration has elapsed.</div></li></ul></section></div></main></body></html>

View File

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

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