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

View File

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

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="Broadcast error types"><title>tokio::sync::broadcast::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><li><a href="#enums" title="Enums">Enums</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="../index.html">In tokio::<wbr>sync::<wbr>broadcast</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">sync</a>::<wbr><a href="../index.html">broadcast</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/sync/broadcast.rs.html#247">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Broadcast 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.SendError.html" title="struct tokio::sync::broadcast::error::SendError">Send<wbr>Error</a></dt><dd>Error returned by the <a href="../struct.Sender.html#method.send" title="method tokio::sync::broadcast::Sender::send"><code>send</code></a> function on a <a href="../struct.Sender.html" title="struct tokio::sync::broadcast::Sender"><code>Sender</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.RecvError.html" title="enum tokio::sync::broadcast::error::RecvError">Recv<wbr>Error</a></dt><dd>An error returned from the <a href="../struct.Receiver.html#method.recv" title="method tokio::sync::broadcast::Receiver::recv"><code>recv</code></a> function on a <a href="../struct.Receiver.html" title="struct tokio::sync::broadcast::Receiver"><code>Receiver</code></a>.</dd><dt><a class="enum" href="enum.TryRecvError.html" title="enum tokio::sync::broadcast::error::TryRecvError">TryRecv<wbr>Error</a></dt><dd>An error returned from the <a href="../struct.Receiver.html#method.try_recv" title="method tokio::sync::broadcast::Receiver::try_recv"><code>try_recv</code></a> function on a <a href="../struct.Receiver.html" title="struct tokio::sync::broadcast::Receiver"><code>Receiver</code></a>.</dd></dl></section></div></main></body></html>

View File

@@ -0,0 +1 @@
window.SIDEBAR_ITEMS = {"enum":["RecvError","TryRecvError"],"struct":["SendError"]};

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,33 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Create a bounded, multi-producer, multi-consumer channel where each sent value is broadcasted to all active receivers."><title>channel in tokio::sync::broadcast - 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="#">channel</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="#">channel</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><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>sync::<wbr>broadcast</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">sync</a>::<wbr><a href="index.html">broadcast</a></div><h1>Function <span class="fn">channel</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/sync/broadcast.rs.html#508-516">Source</a> </span></div><pre class="rust item-decl"><code>pub fn channel&lt;T: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>&gt;(capacity: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.usize.html">usize</a>) -&gt; (<a class="struct" href="struct.Sender.html" title="struct tokio::sync::broadcast::Sender">Sender</a>&lt;T&gt;, <a class="struct" href="struct.Receiver.html" title="struct tokio::sync::broadcast::Receiver">Receiver</a>&lt;T&gt;)</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Create a bounded, multi-producer, multi-consumer channel where each sent
value is broadcasted to all active receivers.</p>
<p><strong>Note:</strong> The actual capacity may be greater than the provided <code>capacity</code>.</p>
<p>All data sent on <a href="struct.Sender.html" title="struct tokio::sync::broadcast::Sender"><code>Sender</code></a> will become available on every active
<a href="struct.Receiver.html" title="struct tokio::sync::broadcast::Receiver"><code>Receiver</code></a> in the same order as it was sent.</p>
<p>The <code>Sender</code> can be cloned to <code>send</code> to the same channel from multiple
points in the process or it can be used concurrently from an <code>Arc</code>. New
<code>Receiver</code> handles are created by calling <a href="struct.Sender.html#method.subscribe" title="method tokio::sync::broadcast::Sender::subscribe"><code>Sender::subscribe</code></a>.</p>
<p>If all <a href="struct.Receiver.html" title="struct tokio::sync::broadcast::Receiver"><code>Receiver</code></a> handles are dropped, the <code>send</code> method will return a
<a href="error/struct.SendError.html" title="struct tokio::sync::broadcast::error::SendError"><code>SendError</code></a>. Similarly, if all <a href="struct.Sender.html" title="struct tokio::sync::broadcast::Sender"><code>Sender</code></a> handles are dropped, the <a href="struct.Receiver.html#method.recv" title="method tokio::sync::broadcast::Receiver::recv"><code>recv</code></a>
method will return a <a href="error/enum.RecvError.html" title="enum tokio::sync::broadcast::error::RecvError"><code>RecvError</code></a>.</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::sync::broadcast;
<span class="kw">let </span>(tx, <span class="kw-2">mut </span>rx1) = broadcast::channel(<span class="number">16</span>);
<span class="kw">let </span><span class="kw-2">mut </span>rx2 = tx.subscribe();
tokio::spawn(<span class="kw">async move </span>{
<span class="macro">assert_eq!</span>(rx1.recv().<span class="kw">await</span>.unwrap(), <span class="number">10</span>);
<span class="macro">assert_eq!</span>(rx1.recv().<span class="kw">await</span>.unwrap(), <span class="number">20</span>);
});
tokio::spawn(<span class="kw">async move </span>{
<span class="macro">assert_eq!</span>(rx2.recv().<span class="kw">await</span>.unwrap(), <span class="number">10</span>);
<span class="macro">assert_eq!</span>(rx2.recv().<span class="kw">await</span>.unwrap(), <span class="number">20</span>);
});
tx.send(<span class="number">10</span>).unwrap();
tx.send(<span class="number">20</span>).unwrap();</code></pre></div><h2 id="panics"><a class="doc-anchor" href="#panics">§</a>Panics</h2>
<p>This will panic if <code>capacity</code> is equal to <code>0</code>.</p>
<p>This pre-allocates space for <code>capacity</code> messages. Allocation failure may result in a panic or
<a href="https://doc.rust-lang.org/1.93.1/alloc/alloc/fn.handle_alloc_error.html" title="fn alloc::alloc::handle_alloc_error">an allocation error</a>.</p>
</div></details></section></div></main></body></html>

View File

@@ -0,0 +1,83 @@
<!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="A multi-producer, multi-consumer broadcast queue. Each sent value is seen by all consumers."><title>tokio::sync::broadcast - 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 broadcast</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 broadcast</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#lagging" title="Lagging">Lagging</a></li><li><a href="#closing" title="Closing">Closing</a></li><li><a href="#examples" title="Examples">Examples</a></li></ul><h3><a href="#modules">Module Items</a></h3><ul class="block"><li><a href="#modules" title="Modules">Modules</a></li><li><a href="#structs" title="Structs">Structs</a></li><li><a href="#functions" title="Functions">Functions</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="../index.html">In tokio::<wbr>sync</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">sync</a></div><h1>Module <span>broadcast</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/sync/broadcast.rs.html#1-1759">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>A multi-producer, multi-consumer broadcast queue. Each sent value is seen by
all consumers.</p>
<p>A <a href="struct.Sender.html" title="struct tokio::sync::broadcast::Sender"><code>Sender</code></a> is used to broadcast values to <strong>all</strong> connected <a href="struct.Receiver.html" title="struct tokio::sync::broadcast::Receiver"><code>Receiver</code></a>
values. <a href="struct.Sender.html" title="struct tokio::sync::broadcast::Sender"><code>Sender</code></a> handles are clone-able, allowing concurrent send and
receive actions. <a href="struct.Sender.html" title="struct tokio::sync::broadcast::Sender"><code>Sender</code></a> and <a href="struct.Receiver.html" title="struct tokio::sync::broadcast::Receiver"><code>Receiver</code></a> are both <code>Send</code> and <code>Sync</code> as
long as <code>T</code> is <code>Send</code>.</p>
<p>When a value is sent, <strong>all</strong> <a href="struct.Receiver.html" title="struct tokio::sync::broadcast::Receiver"><code>Receiver</code></a> handles are notified and will
receive the value. The value is stored once inside the channel and cloned on
demand for each receiver. Once all receivers have received a clone of the
value, the value is released from the channel.</p>
<p>A channel is created by calling <a href="fn.channel.html" title="fn tokio::sync::broadcast::channel"><code>channel</code></a>, specifying the maximum number
of messages the channel can retain at any given time.</p>
<p>New <a href="struct.Receiver.html" title="struct tokio::sync::broadcast::Receiver"><code>Receiver</code></a> handles are created by calling <a href="struct.Sender.html#method.subscribe" title="method tokio::sync::broadcast::Sender::subscribe"><code>Sender::subscribe</code></a>. The
returned <a href="struct.Receiver.html" title="struct tokio::sync::broadcast::Receiver"><code>Receiver</code></a> will receive values sent <strong>after</strong> the call to
<code>subscribe</code>.</p>
<p>This channel is also suitable for the single-producer multi-consumer
use-case, where a single sender broadcasts values to many receivers.</p>
<h3 id="lagging"><a class="doc-anchor" href="#lagging">§</a>Lagging</h3>
<p>As sent messages must be retained until <strong>all</strong> <a href="struct.Receiver.html" title="struct tokio::sync::broadcast::Receiver"><code>Receiver</code></a> handles receive
a clone, broadcast channels are susceptible to the “slow receiver” problem.
In this case, all but one receiver are able to receive values at the rate
they are sent. Because one receiver is stalled, the channel starts to fill
up.</p>
<p>This broadcast channel implementation handles this case by setting a hard
upper bound on the number of values the channel may retain at any given
time. This upper bound is passed to the <a href="fn.channel.html" title="fn tokio::sync::broadcast::channel"><code>channel</code></a> function as an argument.</p>
<p>If a value is sent when the channel is at capacity, the oldest value
currently held by the channel is released. This frees up space for the new
value. Any receiver that has not yet seen the released value will return
<a href="error/enum.RecvError.html#variant.Lagged" title="variant tokio::sync::broadcast::error::RecvError::Lagged"><code>RecvError::Lagged</code></a> the next time <a href="struct.Receiver.html#method.recv" title="method tokio::sync::broadcast::Receiver::recv"><code>recv</code></a> is called.</p>
<p>Once <a href="error/enum.RecvError.html#variant.Lagged" title="variant tokio::sync::broadcast::error::RecvError::Lagged"><code>RecvError::Lagged</code></a> is returned, the lagging receivers position is
updated to the oldest value contained by the channel. The next call to
<a href="struct.Receiver.html#method.recv" title="method tokio::sync::broadcast::Receiver::recv"><code>recv</code></a> will return this value.</p>
<p>This behavior enables a receiver to detect when it has lagged so far behind
that data has been dropped. The caller may decide how to respond to this:
either by aborting its task or by tolerating lost messages and resuming
consumption of the channel.</p>
<h3 id="closing"><a class="doc-anchor" href="#closing">§</a>Closing</h3>
<p>When <strong>all</strong> <a href="struct.Sender.html" title="struct tokio::sync::broadcast::Sender"><code>Sender</code></a> handles have been dropped, no new values may be
sent. At this point, the channel is “closed”. Once a receiver has received
all values retained by the channel, the next call to <a href="struct.Receiver.html#method.recv" title="method tokio::sync::broadcast::Receiver::recv"><code>recv</code></a> will return
with <a href="error/enum.RecvError.html#variant.Closed" title="variant tokio::sync::broadcast::error::RecvError::Closed"><code>RecvError::Closed</code></a>.</p>
<p>When a <a href="struct.Receiver.html" title="struct tokio::sync::broadcast::Receiver"><code>Receiver</code></a> handle is dropped, any messages not read by the receiver
will be marked as read. If this receiver was the only one not to have read
that message, the message will be dropped at this point.</p>
<h2 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h2>
<p>Basic usage</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio::sync::broadcast;
<span class="kw">let </span>(tx, <span class="kw-2">mut </span>rx1) = broadcast::channel(<span class="number">16</span>);
<span class="kw">let </span><span class="kw-2">mut </span>rx2 = tx.subscribe();
tokio::spawn(<span class="kw">async move </span>{
<span class="macro">assert_eq!</span>(rx1.recv().<span class="kw">await</span>.unwrap(), <span class="number">10</span>);
<span class="macro">assert_eq!</span>(rx1.recv().<span class="kw">await</span>.unwrap(), <span class="number">20</span>);
});
tokio::spawn(<span class="kw">async move </span>{
<span class="macro">assert_eq!</span>(rx2.recv().<span class="kw">await</span>.unwrap(), <span class="number">10</span>);
<span class="macro">assert_eq!</span>(rx2.recv().<span class="kw">await</span>.unwrap(), <span class="number">20</span>);
});
tx.send(<span class="number">10</span>).unwrap();
tx.send(<span class="number">20</span>).unwrap();</code></pre></div>
<p>Handling lag</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio::sync::broadcast;
<span class="kw">let </span>(tx, <span class="kw-2">mut </span>rx) = broadcast::channel(<span class="number">2</span>);
tx.send(<span class="number">10</span>).unwrap();
tx.send(<span class="number">20</span>).unwrap();
tx.send(<span class="number">30</span>).unwrap();
<span class="comment">// The receiver lagged behind
</span><span class="macro">assert!</span>(rx.recv().<span class="kw">await</span>.is_err());
<span class="comment">// At this point, we can abort or continue with lost messages
</span><span class="macro">assert_eq!</span>(<span class="number">20</span>, rx.recv().<span class="kw">await</span>.unwrap());
<span class="macro">assert_eq!</span>(<span class="number">30</span>, rx.recv().<span class="kw">await</span>.unwrap());</code></pre></div></div></details><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::sync::broadcast::error">error</a></dt><dd>Broadcast 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.Receiver.html" title="struct tokio::sync::broadcast::Receiver">Receiver</a></dt><dd>Receiving-half of the <a href="index.html" title="mod tokio::sync::broadcast"><code>broadcast</code></a> channel.</dd><dt><a class="struct" href="struct.Sender.html" title="struct tokio::sync::broadcast::Sender">Sender</a></dt><dd>Sending-half of the <a href="index.html" title="mod tokio::sync::broadcast"><code>broadcast</code></a> channel.</dd><dt><a class="struct" href="struct.WeakSender.html" title="struct tokio::sync::broadcast::WeakSender">Weak<wbr>Sender</a></dt><dd>A sender that does not prevent the channel from being closed.</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.channel.html" title="fn tokio::sync::broadcast::channel">channel</a></dt><dd>Create a bounded, multi-producer, multi-consumer channel where each sent
value is broadcasted to all active receivers.</dd></dl></section></div></main></body></html>

View File

@@ -0,0 +1 @@
window.SIDEBAR_ITEMS = {"fn":["channel"],"mod":["error"],"struct":["Receiver","Sender","WeakSender"]};

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

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="Named future types."><title>tokio::sync::futures - 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 futures</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 futures</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>sync</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">sync</a></div><h1>Module <span>futures</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/sync/mod.rs.html#454">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Named future 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.Notified.html" title="struct tokio::sync::futures::Notified">Notified</a></dt><dd>Future returned from <a href="../struct.Notify.html#method.notified" title="method tokio::sync::Notify::notified"><code>Notify::notified()</code></a>.</dd><dt><a class="struct" href="struct.OwnedNotified.html" title="struct tokio::sync::futures::OwnedNotified">Owned<wbr>Notified</a></dt><dd>Future returned from <a href="../struct.Notify.html#method.notified_owned" title="method tokio::sync::Notify::notified_owned"><code>Notify::notified_owned()</code></a>.</dd></dl></section></div></main></body></html>

View File

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

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,386 @@
<!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="Synchronization primitives for use in asynchronous contexts."><title>tokio::sync - 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 sync</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 sync</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#message-passing" title="Message passing">Message passing</a><ul><li><a href="#oneshot-channel" title="`oneshot` channel"><code>oneshot</code> channel</a></li><li><a href="#mpsc-channel" title="`mpsc` channel"><code>mpsc</code> channel</a></li><li><a href="#broadcast-channel" title="`broadcast` channel"><code>broadcast</code> channel</a></li><li><a href="#watch-channel" title="`watch` channel"><code>watch</code> channel</a></li></ul></li><li><a href="#state-synchronization" title="State synchronization">State synchronization</a></li><li><a href="#runtime-compatibility" title="Runtime compatibility">Runtime compatibility</a></li></ul><h3><a href="#modules">Module Items</a></h3><ul class="block"><li><a href="#modules" title="Modules">Modules</a></li><li><a href="#structs" title="Structs">Structs</a></li><li><a href="#enums" title="Enums">Enums</a></li></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>sync</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/sync/mod.rs.html#1-524">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Synchronization primitives for use in asynchronous contexts.</p>
<p>Tokio programs tend to be organized as a set of <a href="../task/index.html" title="mod tokio::task">tasks</a> where each task
operates independently and may be executed on separate physical threads. The
synchronization primitives provided in this module permit these independent
tasks to communicate together.</p>
<h2 id="message-passing"><a class="doc-anchor" href="#message-passing">§</a>Message passing</h2>
<p>The most common form of synchronization in a Tokio program is message
passing. Two tasks operate independently and send messages to each other to
synchronize. Doing so has the advantage of avoiding shared state.</p>
<p>Message passing is implemented using channels. A channel supports sending a
message from one producer task to one or more consumer tasks. There are a
few flavors of channels provided by Tokio. Each channel flavor supports
different message passing patterns. When a channel supports multiple
producers, many separate tasks may <strong>send</strong> messages. When a channel
supports multiple consumers, many different separate tasks may <strong>receive</strong>
messages.</p>
<p>Tokio provides many different channel flavors as different message passing
patterns are best handled with different implementations.</p>
<h3 id="oneshot-channel"><a class="doc-anchor" href="#oneshot-channel">§</a><code>oneshot</code> channel</h3>
<p>The <a href="oneshot/index.html" title="mod tokio::sync::oneshot"><code>oneshot</code> channel</a> supports sending a <strong>single</strong> value from a
single producer to a single consumer. This channel is usually used to send
the result of a computation to a waiter.</p>
<p><strong>Example:</strong> using a <a href="oneshot/index.html" title="mod tokio::sync::oneshot"><code>oneshot</code> channel</a> to receive the result of a
computation.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio::sync::oneshot;
<span class="kw">async fn </span>some_computation() -&gt; String {
<span class="string">"represents the result of the computation"</span>.to_string()
}
<span class="kw">let </span>(tx, rx) = oneshot::channel();
tokio::spawn(<span class="kw">async move </span>{
<span class="kw">let </span>res = some_computation().<span class="kw">await</span>;
tx.send(res).unwrap();
});
<span class="comment">// Do other work while the computation is happening in the background
// Wait for the computation result
</span><span class="kw">let </span>res = rx.<span class="kw">await</span>.unwrap();</code></pre></div>
<p>Note, if the task produces a computation result as its final
action before terminating, the <a href="../task/struct.JoinHandle.html" title="struct tokio::task::JoinHandle"><code>JoinHandle</code></a> can be used to
receive that value instead of allocating resources for the
<code>oneshot</code> channel. Awaiting on <a href="../task/struct.JoinHandle.html" title="struct tokio::task::JoinHandle"><code>JoinHandle</code></a> returns <code>Result</code>. If
the task panics, the <code>Joinhandle</code> yields <code>Err</code> with the panic
cause.</p>
<p><strong>Example:</strong></p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">async fn </span>some_computation() -&gt; String {
<span class="string">"the result of the computation"</span>.to_string()
}
<span class="kw">let </span>join_handle = tokio::spawn(<span class="kw">async move </span>{
some_computation().<span class="kw">await
</span>});
<span class="comment">// Do other work while the computation is happening in the background
// Wait for the computation result
</span><span class="kw">let </span>res = join_handle.<span class="kw">await</span>.unwrap();</code></pre></div><h3 id="mpsc-channel"><a class="doc-anchor" href="#mpsc-channel">§</a><code>mpsc</code> channel</h3>
<p>The <a href="mpsc/index.html" title="mod tokio::sync::mpsc"><code>mpsc</code> channel</a> supports sending <strong>many</strong> values from <strong>many</strong>
producers to a single consumer. This channel is often used to send work to a
task or to receive the result of many computations.</p>
<p>This is also the channel you should use if you want to send many messages
from a single producer to a single consumer. There is no dedicated spsc
channel.</p>
<p><strong>Example:</strong> using an mpsc to incrementally stream the results of a series
of computations.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio::sync::mpsc;
<span class="kw">async fn </span>some_computation(input: u32) -&gt; String {
<span class="macro">format!</span>(<span class="string">"the result of computation {}"</span>, input)
}
<span class="kw">let </span>(tx, <span class="kw-2">mut </span>rx) = mpsc::channel(<span class="number">100</span>);
tokio::spawn(<span class="kw">async move </span>{
<span class="kw">for </span>i <span class="kw">in </span><span class="number">0</span>..<span class="number">10 </span>{
<span class="kw">let </span>res = some_computation(i).<span class="kw">await</span>;
tx.send(res).<span class="kw">await</span>.unwrap();
}
});
<span class="kw">while let </span><span class="prelude-val">Some</span>(res) = rx.recv().<span class="kw">await </span>{
<span class="macro">println!</span>(<span class="string">"got = {}"</span>, res);
}</code></pre></div>
<p>The argument to <code>mpsc::channel</code> is the channel capacity. This is the maximum
number of values that can be stored in the channel pending receipt at any
given time. Properly setting this value is key in implementing robust
programs as the channel capacity plays a critical part in handling back
pressure.</p>
<p>A common concurrency pattern for resource management is to spawn a task
dedicated to managing that resource and using message passing between other
tasks to interact with the resource. The resource may be anything that may
not be concurrently used. Some examples include a socket and program state.
For example, if multiple tasks need to send data over a single socket, spawn
a task to manage the socket and use a channel to synchronize.</p>
<p><strong>Example:</strong> sending data from many tasks over a single socket using message
passing.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio::io::{<span class="self">self</span>, AsyncWriteExt};
<span class="kw">use </span>tokio::net::TcpStream;
<span class="kw">use </span>tokio::sync::mpsc;
<span class="attr">#[tokio::main]
</span><span class="kw">async fn </span>main() -&gt; io::Result&lt;()&gt; {
<span class="kw">let </span><span class="kw-2">mut </span>socket = TcpStream::connect(<span class="string">"www.example.com:1234"</span>).<span class="kw">await</span><span class="question-mark">?</span>;
<span class="kw">let </span>(tx, <span class="kw-2">mut </span>rx) = mpsc::channel(<span class="number">100</span>);
<span class="kw">for _ in </span><span class="number">0</span>..<span class="number">10 </span>{
<span class="comment">// Each task needs its own `tx` handle. This is done by cloning the
// original handle.
</span><span class="kw">let </span>tx = tx.clone();
tokio::spawn(<span class="kw">async move </span>{
tx.send(<span class="kw-2">&amp;</span><span class="string">b"data to write"</span>[..]).<span class="kw">await</span>.unwrap();
});
}
<span class="comment">// The `rx` half of the channel returns `None` once **all** `tx` clones
// drop. To ensure `None` is returned, drop the handle owned by the
// current task. If this `tx` handle is not dropped, there will always
// be a single outstanding `tx` handle.
</span>drop(tx);
<span class="kw">while let </span><span class="prelude-val">Some</span>(res) = rx.recv().<span class="kw">await </span>{
socket.write_all(res).<span class="kw">await</span><span class="question-mark">?</span>;
}
<span class="prelude-val">Ok</span>(())
}</code></pre></div>
<p>The <a href="mpsc/index.html" title="mod tokio::sync::mpsc"><code>mpsc</code></a> and <a href="oneshot/index.html" title="mod tokio::sync::oneshot"><code>oneshot</code></a> channels can be combined to provide a request /
response type synchronization pattern with a shared resource. A task is
spawned to synchronize a resource and waits on commands received on a
<a href="mpsc/index.html" title="mod tokio::sync::mpsc"><code>mpsc</code></a> channel. Each command includes a <a href="oneshot/index.html" title="mod tokio::sync::oneshot"><code>oneshot</code></a> <code>Sender</code> on which the
result of the command is sent.</p>
<p><strong>Example:</strong> use a task to synchronize a <code>u64</code> counter. Each task sends an
“fetch and increment” command. The counter value <strong>before</strong> the increment is
sent over the provided <code>oneshot</code> channel.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio::sync::{oneshot, mpsc};
<span class="kw">use </span>Command::Increment;
<span class="kw">enum </span>Command {
Increment,
<span class="comment">// Other commands can be added here
</span>}
<span class="kw">let </span>(cmd_tx, <span class="kw-2">mut </span>cmd_rx) = mpsc::channel::&lt;(Command, oneshot::Sender&lt;u64&gt;)&gt;(<span class="number">100</span>);
<span class="comment">// Spawn a task to manage the counter
</span>tokio::spawn(<span class="kw">async move </span>{
<span class="kw">let </span><span class="kw-2">mut </span>counter: u64 = <span class="number">0</span>;
<span class="kw">while let </span><span class="prelude-val">Some</span>((cmd, response)) = cmd_rx.recv().<span class="kw">await </span>{
<span class="kw">match </span>cmd {
Increment =&gt; {
<span class="kw">let </span>prev = counter;
counter += <span class="number">1</span>;
response.send(prev).unwrap();
}
}
}
});
<span class="kw">let </span><span class="kw-2">mut </span>join_handles = <span class="macro">vec!</span>[];
<span class="comment">// Spawn tasks that will send the increment command.
</span><span class="kw">for _ in </span><span class="number">0</span>..<span class="number">10 </span>{
<span class="kw">let </span>cmd_tx = cmd_tx.clone();
join_handles.push(tokio::spawn(<span class="kw">async move </span>{
<span class="kw">let </span>(resp_tx, resp_rx) = oneshot::channel();
cmd_tx.send((Increment, resp_tx)).<span class="kw">await</span>.ok().unwrap();
<span class="kw">let </span>res = resp_rx.<span class="kw">await</span>.unwrap();
<span class="macro">println!</span>(<span class="string">"previous value = {}"</span>, res);
}));
}
<span class="comment">// Wait for all tasks to complete
</span><span class="kw">for </span>join_handle <span class="kw">in </span>join_handles.drain(..) {
join_handle.<span class="kw">await</span>.unwrap();
}</code></pre></div><h3 id="broadcast-channel"><a class="doc-anchor" href="#broadcast-channel">§</a><code>broadcast</code> channel</h3>
<p>The <a href="broadcast/index.html" title="mod tokio::sync::broadcast"><code>broadcast</code> channel</a> supports sending <strong>many</strong> values from
<strong>many</strong> producers to <strong>many</strong> consumers. Each consumer will receive
<strong>each</strong> value. This channel can be used to implement “fan out” style
patterns common with pub / sub or “chat” systems.</p>
<p>This channel tends to be used less often than <code>oneshot</code> and <code>mpsc</code> but still
has its use cases.</p>
<p>This is also the channel you should use if you want to broadcast values from
a single producer to many consumers. There is no dedicated spmc broadcast
channel.</p>
<p>Basic usage</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio::sync::broadcast;
<span class="kw">let </span>(tx, <span class="kw-2">mut </span>rx1) = broadcast::channel(<span class="number">16</span>);
<span class="kw">let </span><span class="kw-2">mut </span>rx2 = tx.subscribe();
tokio::spawn(<span class="kw">async move </span>{
<span class="macro">assert_eq!</span>(rx1.recv().<span class="kw">await</span>.unwrap(), <span class="number">10</span>);
<span class="macro">assert_eq!</span>(rx1.recv().<span class="kw">await</span>.unwrap(), <span class="number">20</span>);
});
tokio::spawn(<span class="kw">async move </span>{
<span class="macro">assert_eq!</span>(rx2.recv().<span class="kw">await</span>.unwrap(), <span class="number">10</span>);
<span class="macro">assert_eq!</span>(rx2.recv().<span class="kw">await</span>.unwrap(), <span class="number">20</span>);
});
tx.send(<span class="number">10</span>).unwrap();
tx.send(<span class="number">20</span>).unwrap();</code></pre></div><h3 id="watch-channel"><a class="doc-anchor" href="#watch-channel">§</a><code>watch</code> channel</h3>
<p>The <a href="watch/index.html" title="mod tokio::sync::watch"><code>watch</code> channel</a> supports sending <strong>many</strong> values from <strong>many</strong>
producers to <strong>many</strong> consumers. However, only the <strong>most recent</strong> value is
stored in the channel. Consumers are notified when a new value is sent, but
there is no guarantee that consumers will see <strong>all</strong> values.</p>
<p>The <a href="watch/index.html" title="mod tokio::sync::watch"><code>watch</code> channel</a> is similar to a <a href="broadcast/index.html" title="mod tokio::sync::broadcast"><code>broadcast</code> channel</a> with capacity 1.</p>
<p>Use cases for the <a href="watch/index.html" title="mod tokio::sync::watch"><code>watch</code> channel</a> include broadcasting configuration
changes or signalling program state changes, such as transitioning to
shutdown.</p>
<p><strong>Example:</strong> use a <a href="watch/index.html" title="mod tokio::sync::watch"><code>watch</code> channel</a> to notify tasks of configuration
changes. In this example, a configuration file is checked periodically. When
the file changes, the configuration changes are signalled to consumers.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio::sync::watch;
<span class="kw">use </span>tokio::time::{<span class="self">self</span>, Duration, Instant};
<span class="kw">use </span>std::io;
<span class="attr">#[derive(Debug, Clone, Eq, PartialEq)]
</span><span class="kw">struct </span>Config {
timeout: Duration,
}
<span class="kw">impl </span>Config {
<span class="kw">async fn </span>load_from_file() -&gt; io::Result&lt;Config&gt; {
<span class="comment">// file loading and deserialization logic here
</span>}
}
<span class="kw">async fn </span>my_async_operation() {
<span class="comment">// Do something here
</span>}
<span class="comment">// Load initial configuration value
</span><span class="kw">let </span><span class="kw-2">mut </span>config = Config::load_from_file().<span class="kw">await</span>.unwrap();
<span class="comment">// Create the watch channel, initialized with the loaded configuration
</span><span class="kw">let </span>(tx, rx) = watch::channel(config.clone());
<span class="comment">// Spawn a task to monitor the file.
</span>tokio::spawn(<span class="kw">async move </span>{
<span class="kw">loop </span>{
<span class="comment">// Wait 10 seconds between checks
</span>time::sleep(Duration::from_secs(<span class="number">10</span>)).<span class="kw">await</span>;
<span class="comment">// Load the configuration file
</span><span class="kw">let </span>new_config = Config::load_from_file().<span class="kw">await</span>.unwrap();
<span class="comment">// If the configuration changed, send the new config value
// on the watch channel.
</span><span class="kw">if </span><span class="macro">new_config !</span>= config {
tx.send(new_config.clone()).unwrap();
config = new_config;
}
}
});
<span class="kw">let </span><span class="kw-2">mut </span>handles = <span class="macro">vec!</span>[];
<span class="comment">// Spawn tasks that runs the async operation for at most `timeout`. If
// the timeout elapses, restart the operation.
//
// The task simultaneously watches the `Config` for changes. When the
// timeout duration changes, the timeout is updated without restarting
// the in-flight operation.
</span><span class="kw">for _ in </span><span class="number">0</span>..<span class="number">5 </span>{
<span class="comment">// Clone a config watch handle for use in this task
</span><span class="kw">let </span><span class="kw-2">mut </span>rx = rx.clone();
<span class="kw">let </span>handle = tokio::spawn(<span class="kw">async move </span>{
<span class="comment">// Start the initial operation and pin the future to the stack.
// Pinning to the stack is required to resume the operation
// across multiple calls to `select!`
</span><span class="kw">let </span>op = my_async_operation();
<span class="macro">tokio::pin!</span>(op);
<span class="comment">// Get the initial config value
</span><span class="kw">let </span><span class="kw-2">mut </span>conf = rx.borrow().clone();
<span class="kw">let </span><span class="kw-2">mut </span>op_start = Instant::now();
<span class="kw">let </span>sleep = time::sleep_until(op_start + conf.timeout);
<span class="macro">tokio::pin!</span>(sleep);
<span class="kw">loop </span>{
<span class="macro">tokio::select!</span> {
<span class="kw">_ </span>= <span class="kw-2">&amp;mut </span>sleep =&gt; {
<span class="comment">// The operation elapsed. Restart it
</span>op.set(my_async_operation());
<span class="comment">// Track the new start time
</span>op_start = Instant::now();
<span class="comment">// Restart the timeout
</span>sleep.set(time::sleep_until(op_start + conf.timeout));
}
<span class="kw">_ </span>= rx.changed() =&gt; {
conf = rx.borrow_and_update().clone();
<span class="comment">// The configuration has been updated. Update the
// `sleep` using the new `timeout` value.
</span>sleep.as_mut().reset(op_start + conf.timeout);
}
<span class="kw">_ </span>= <span class="kw-2">&amp;mut </span>op =&gt; {
<span class="comment">// The operation completed!
</span><span class="kw">return
</span>}
}
}
});
handles.push(handle);
}
<span class="kw">for </span>handle <span class="kw">in </span>handles.drain(..) {
handle.<span class="kw">await</span>.unwrap();
}</code></pre></div><h2 id="state-synchronization"><a class="doc-anchor" href="#state-synchronization">§</a>State synchronization</h2>
<p>The remaining synchronization primitives focus on synchronizing state.
These are asynchronous equivalents to versions provided by <code>std</code>. They
operate in a similar way as their <code>std</code> counterparts but will wait
asynchronously instead of blocking the thread.</p>
<ul>
<li>
<p><a href="struct.Barrier.html" title="struct tokio::sync::Barrier"><code>Barrier</code></a> Ensures multiple tasks will wait for each other to reach a
point in the program, before continuing execution all together.</p>
</li>
<li>
<p><a href="struct.Mutex.html" title="struct tokio::sync::Mutex"><code>Mutex</code></a> Mutual Exclusion mechanism, which ensures that at most one
thread at a time is able to access some data.</p>
</li>
<li>
<p><a href="struct.Notify.html" title="struct tokio::sync::Notify"><code>Notify</code></a> Basic task notification. <code>Notify</code> supports notifying a
receiving task without sending data. In this case, the task wakes up and
resumes processing.</p>
</li>
<li>
<p><a href="struct.RwLock.html" title="struct tokio::sync::RwLock"><code>RwLock</code></a> Provides a mutual exclusion mechanism which allows multiple
readers at the same time, while allowing only one writer at a time. In
some cases, this can be more efficient than a mutex.</p>
</li>
<li>
<p><a href="struct.Semaphore.html" title="struct tokio::sync::Semaphore"><code>Semaphore</code></a> Limits the amount of concurrency. A semaphore holds a
number of permits, which tasks may request in order to enter a critical
section. Semaphores are useful for implementing limiting or bounding of
any kind.</p>
</li>
</ul>
<h2 id="runtime-compatibility"><a class="doc-anchor" href="#runtime-compatibility">§</a>Runtime compatibility</h2>
<p>All synchronization primitives provided in this module are runtime agnostic.
You can freely move them between different instances of the Tokio runtime
or even use them from non-Tokio runtimes.</p>
<p>When used in a Tokio runtime, the synchronization primitives participate in
<a href="../task/coop/index.html#cooperative-scheduling" title="mod tokio::task::coop">cooperative scheduling</a> to avoid
starvation. This feature does not apply when used from non-Tokio runtimes.</p>
<p>As an exception, methods ending in <code>_timeout</code> are not runtime agnostic
because they require access to the Tokio timer. See the documentation of
each <code>*_timeout</code> method for more information on its use.</p>
</div></details><h2 id="modules" class="section-header">Modules<a href="#modules" class="anchor">§</a></h2><dl class="item-table"><dt><a class="mod" href="broadcast/index.html" title="mod tokio::sync::broadcast">broadcast</a></dt><dd>A multi-producer, multi-consumer broadcast queue. Each sent value is seen by
all consumers.</dd><dt><a class="mod" href="futures/index.html" title="mod tokio::sync::futures">futures</a></dt><dd>Named future types.</dd><dt><a class="mod" href="mpsc/index.html" title="mod tokio::sync::mpsc">mpsc</a></dt><dd>A multi-producer, single-consumer queue for sending values between
asynchronous tasks.</dd><dt><a class="mod" href="oneshot/index.html" title="mod tokio::sync::oneshot">oneshot</a></dt><dd>A one-shot channel is used for sending a single message between
asynchronous tasks. The <a href="oneshot/fn.channel.html" title="fn tokio::sync::oneshot::channel"><code>channel</code></a> function is used to create a
<a href="oneshot/struct.Sender.html" title="struct tokio::sync::oneshot::Sender"><code>Sender</code></a> and <a href="oneshot/struct.Receiver.html" title="struct tokio::sync::oneshot::Receiver"><code>Receiver</code></a> handle pair that form the channel.</dd><dt><a class="mod" href="watch/index.html" title="mod tokio::sync::watch">watch</a></dt><dd>A multi-producer, multi-consumer channel that only retains the <em>last</em> sent
value.</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.AcquireError.html" title="struct tokio::sync::AcquireError">Acquire<wbr>Error</a></dt><dd>Error returned from the <a href="struct.Semaphore.html#method.acquire" title="method tokio::sync::Semaphore::acquire"><code>Semaphore::acquire</code></a> function.</dd><dt><a class="struct" href="struct.Barrier.html" title="struct tokio::sync::Barrier">Barrier</a></dt><dd>A barrier enables multiple tasks to synchronize the beginning of some computation.</dd><dt><a class="struct" href="struct.BarrierWaitResult.html" title="struct tokio::sync::BarrierWaitResult">Barrier<wbr>Wait<wbr>Result</a></dt><dd>A <code>BarrierWaitResult</code> is returned by <code>wait</code> when all tasks in the <code>Barrier</code> have rendezvoused.</dd><dt><a class="struct" href="struct.MappedMutexGuard.html" title="struct tokio::sync::MappedMutexGuard">Mapped<wbr>Mutex<wbr>Guard</a></dt><dd>A handle to a held <code>Mutex</code> that has had a function applied to it via <a href="struct.MutexGuard.html#method.map" title="associated function tokio::sync::MutexGuard::map"><code>MutexGuard::map</code></a>.</dd><dt><a class="struct" href="struct.Mutex.html" title="struct tokio::sync::Mutex">Mutex</a></dt><dd>An asynchronous <code>Mutex</code>-like type.</dd><dt><a class="struct" href="struct.MutexGuard.html" title="struct tokio::sync::MutexGuard">Mutex<wbr>Guard</a></dt><dd>A handle to a held <code>Mutex</code>. The guard can be held across any <code>.await</code> point
as it is <a href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Send.html" title="trait core::marker::Send"><code>Send</code></a>.</dd><dt><a class="struct" href="struct.Notify.html" title="struct tokio::sync::Notify">Notify</a></dt><dd>Notifies a single task to wake up.</dd><dt><a class="struct" href="struct.OnceCell.html" title="struct tokio::sync::OnceCell">Once<wbr>Cell</a></dt><dd>A thread-safe cell that can be written to only once.</dd><dt><a class="struct" href="struct.OwnedMappedMutexGuard.html" title="struct tokio::sync::OwnedMappedMutexGuard">Owned<wbr>Mapped<wbr>Mutex<wbr>Guard</a></dt><dd>A owned handle to a held <code>Mutex</code> that has had a function applied to it via
<a href="struct.OwnedMutexGuard.html#method.map" title="associated function tokio::sync::OwnedMutexGuard::map"><code>OwnedMutexGuard::map</code></a>.</dd><dt><a class="struct" href="struct.OwnedMutexGuard.html" title="struct tokio::sync::OwnedMutexGuard">Owned<wbr>Mutex<wbr>Guard</a></dt><dd>An owned handle to a held <code>Mutex</code>.</dd><dt><a class="struct" href="struct.OwnedRwLockMappedWriteGuard.html" title="struct tokio::sync::OwnedRwLockMappedWriteGuard">Owned<wbr>RwLock<wbr>Mapped<wbr>Write<wbr>Guard</a></dt><dd>Owned RAII structure used to release the exclusive write access of a lock when
dropped.</dd><dt><a class="struct" href="struct.OwnedRwLockReadGuard.html" title="struct tokio::sync::OwnedRwLockReadGuard">Owned<wbr>RwLock<wbr>Read<wbr>Guard</a></dt><dd>Owned RAII structure used to release the shared read access of a lock when
dropped.</dd><dt><a class="struct" href="struct.OwnedRwLockWriteGuard.html" title="struct tokio::sync::OwnedRwLockWriteGuard">Owned<wbr>RwLock<wbr>Write<wbr>Guard</a></dt><dd>Owned RAII structure used to release the exclusive write access of a lock when
dropped.</dd><dt><a class="struct" href="struct.OwnedSemaphorePermit.html" title="struct tokio::sync::OwnedSemaphorePermit">Owned<wbr>Semaphore<wbr>Permit</a></dt><dd>An owned permit from the semaphore.</dd><dt><a class="struct" href="struct.RwLock.html" title="struct tokio::sync::RwLock">RwLock</a></dt><dd>An asynchronous reader-writer lock.</dd><dt><a class="struct" href="struct.RwLockMappedWriteGuard.html" title="struct tokio::sync::RwLockMappedWriteGuard">RwLock<wbr>Mapped<wbr>Write<wbr>Guard</a></dt><dd>RAII structure used to release the exclusive write access of a lock when
dropped.</dd><dt><a class="struct" href="struct.RwLockReadGuard.html" title="struct tokio::sync::RwLockReadGuard">RwLock<wbr>Read<wbr>Guard</a></dt><dd>RAII structure used to release the shared read access of a lock when
dropped.</dd><dt><a class="struct" href="struct.RwLockWriteGuard.html" title="struct tokio::sync::RwLockWriteGuard">RwLock<wbr>Write<wbr>Guard</a></dt><dd>RAII structure used to release the exclusive write access of a lock when
dropped.</dd><dt><a class="struct" href="struct.Semaphore.html" title="struct tokio::sync::Semaphore">Semaphore</a></dt><dd>Counting semaphore performing asynchronous permit acquisition.</dd><dt><a class="struct" href="struct.SemaphorePermit.html" title="struct tokio::sync::SemaphorePermit">Semaphore<wbr>Permit</a></dt><dd>A permit from the semaphore.</dd><dt><a class="struct" href="struct.SetOnce.html" title="struct tokio::sync::SetOnce">SetOnce</a></dt><dd>A thread-safe cell that can be written to only once.</dd><dt><a class="struct" href="struct.SetOnceError.html" title="struct tokio::sync::SetOnceError">SetOnce<wbr>Error</a></dt><dd>Error that can be returned from <a href="struct.SetOnce.html#method.set" title="method tokio::sync::SetOnce::set"><code>SetOnce::set</code></a>.</dd><dt><a class="struct" href="struct.TryLockError.html" title="struct tokio::sync::TryLockError">TryLock<wbr>Error</a></dt><dd>Error returned from the <a href="struct.Mutex.html#method.try_lock" title="method tokio::sync::Mutex::try_lock"><code>Mutex::try_lock</code></a>, <a href="struct.RwLock.html#method.try_read" title="method tokio::sync::RwLock::try_read"><code>RwLock::try_read</code></a> and
<a href="struct.RwLock.html#method.try_write" title="method tokio::sync::RwLock::try_write"><code>RwLock::try_write</code></a> functions.</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.SetError.html" title="enum tokio::sync::SetError">SetError</a></dt><dd>Errors that can be returned from <a href="struct.OnceCell.html#method.set" title="method tokio::sync::OnceCell::set"><code>OnceCell::set</code></a>.</dd><dt><a class="enum" href="enum.TryAcquireError.html" title="enum tokio::sync::TryAcquireError">TryAcquire<wbr>Error</a></dt><dd>Error returned from the <a href="struct.Semaphore.html#method.try_acquire" title="method tokio::sync::Semaphore::try_acquire"><code>Semaphore::try_acquire</code></a> function.</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/sync/mpsc/fn.channel.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="../../../../tokio/sync/mpsc/fn.channel.html">../../../../tokio/sync/mpsc/fn.channel.html</a>...</p>
<script>location.replace("../../../../tokio/sync/mpsc/fn.channel.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/sync/mpsc/struct.OwnedPermit.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="../../../../tokio/sync/mpsc/struct.OwnedPermit.html">../../../../tokio/sync/mpsc/struct.OwnedPermit.html</a>...</p>
<script>location.replace("../../../../tokio/sync/mpsc/struct.OwnedPermit.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/sync/mpsc/struct.Permit.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="../../../../tokio/sync/mpsc/struct.Permit.html">../../../../tokio/sync/mpsc/struct.Permit.html</a>...</p>
<script>location.replace("../../../../tokio/sync/mpsc/struct.Permit.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/sync/mpsc/struct.PermitIterator.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="../../../../tokio/sync/mpsc/struct.PermitIterator.html">../../../../tokio/sync/mpsc/struct.PermitIterator.html</a>...</p>
<script>location.replace("../../../../tokio/sync/mpsc/struct.PermitIterator.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/sync/mpsc/struct.Receiver.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="../../../../tokio/sync/mpsc/struct.Receiver.html">../../../../tokio/sync/mpsc/struct.Receiver.html</a>...</p>
<script>location.replace("../../../../tokio/sync/mpsc/struct.Receiver.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/sync/mpsc/struct.Sender.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="../../../../tokio/sync/mpsc/struct.Sender.html">../../../../tokio/sync/mpsc/struct.Sender.html</a>...</p>
<script>location.replace("../../../../tokio/sync/mpsc/struct.Sender.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/sync/mpsc/struct.WeakSender.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="../../../../tokio/sync/mpsc/struct.WeakSender.html">../../../../tokio/sync/mpsc/struct.WeakSender.html</a>...</p>
<script>location.replace("../../../../tokio/sync/mpsc/struct.WeakSender.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

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="Channel error types."><title>tokio::sync::mpsc::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><li><a href="#enums" title="Enums">Enums</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="../index.html">In tokio::<wbr>sync::<wbr>mpsc</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">sync</a>::<wbr><a href="../index.html">mpsc</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/sync/mpsc/error.rs.html#1-168">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Channel 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.SendError.html" title="struct tokio::sync::mpsc::error::SendError">Send<wbr>Error</a></dt><dd>Error returned by <a href="../struct.Sender.html#method.send" title="method tokio::sync::mpsc::Sender::send"><code>Sender::send</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.SendTimeoutError.html" title="enum tokio::sync::mpsc::error::SendTimeoutError">Send<wbr>Timeout<wbr>Error</a></dt><dd>Error returned by <a href="../struct.Sender.html#method.send_timeout" title="method tokio::sync::mpsc::Sender::send_timeout"><code>Sender::send_timeout</code></a>.</dd><dt><a class="enum" href="enum.TryRecvError.html" title="enum tokio::sync::mpsc::error::TryRecvError">TryRecv<wbr>Error</a></dt><dd>Error returned by <a href="../struct.Receiver.html#method.try_recv" title="method tokio::sync::mpsc::Receiver::try_recv"><code>Receiver::try_recv</code></a>.</dd><dt><a class="enum" href="enum.TrySendError.html" title="enum tokio::sync::mpsc::error::TrySendError">TrySend<wbr>Error</a></dt><dd>Error returned by <a href="../struct.Sender.html#method.try_send" title="method tokio::sync::mpsc::Sender::try_send"><code>Sender::try_send</code></a>.</dd></dl></section></div></main></body></html>

View File

@@ -0,0 +1 @@
window.SIDEBAR_ITEMS = {"enum":["SendTimeoutError","TryRecvError","TrySendError"],"struct":["SendError"]};

File diff suppressed because one or more lines are too long

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="Creates a bounded mpsc channel for communicating between asynchronous tasks with backpressure."><title>channel in tokio::sync::mpsc - 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="#">channel</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="#">channel</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>sync::<wbr>mpsc</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">sync</a>::<wbr><a href="index.html">mpsc</a></div><h1>Function <span class="fn">channel</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/sync/mpsc/bounded.rs.html#159-171">Source</a> </span></div><pre class="rust item-decl"><code>pub fn channel&lt;T&gt;(buffer: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.usize.html">usize</a>) -&gt; (<a class="struct" href="struct.Sender.html" title="struct tokio::sync::mpsc::Sender">Sender</a>&lt;T&gt;, <a class="struct" href="struct.Receiver.html" title="struct tokio::sync::mpsc::Receiver">Receiver</a>&lt;T&gt;)</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Creates a bounded mpsc channel for communicating between asynchronous tasks
with backpressure.</p>
<p>The channel will buffer up to the provided number of messages. Once the
buffer is full, attempts to send new messages will wait until a message is
received from the channel. The provided buffer capacity must be at least 1.</p>
<p>All data sent on <code>Sender</code> will become available on <code>Receiver</code> in the same
order as it was sent.</p>
<p>The <code>Sender</code> can be cloned to <code>send</code> to the same channel from multiple code
locations. Only one <code>Receiver</code> is supported.</p>
<p>If the <code>Receiver</code> is disconnected while trying to <code>send</code>, the <code>send</code> method
will return a <code>SendError</code>. Similarly, if <code>Sender</code> is disconnected while
trying to <code>recv</code>, the <code>recv</code> method will return <code>None</code>.</p>
<h2 id="panics"><a class="doc-anchor" href="#panics">§</a>Panics</h2>
<p>Panics if the buffer capacity is 0, or too large. Currently the maximum
capacity is <a href="../struct.Semaphore.html#associatedconstant.MAX_PERMITS" title="associated constant tokio::sync::Semaphore::MAX_PERMITS"><code>Semaphore::MAX_PERMITS</code></a>.</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::sync::mpsc;
<span class="kw">let </span>(tx, <span class="kw-2">mut </span>rx) = mpsc::channel(<span class="number">100</span>);
tokio::spawn(<span class="kw">async move </span>{
<span class="kw">for </span>i <span class="kw">in </span><span class="number">0</span>..<span class="number">10 </span>{
<span class="kw">if let </span><span class="prelude-val">Err</span>(<span class="kw">_</span>) = tx.send(i).<span class="kw">await </span>{
<span class="macro">println!</span>(<span class="string">"receiver dropped"</span>);
<span class="kw">return</span>;
}
}
});
<span class="kw">while let </span><span class="prelude-val">Some</span>(i) = rx.recv().<span class="kw">await </span>{
<span class="macro">println!</span>(<span class="string">"got = {}"</span>, i);
}</code></pre></div></div></details></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="Creates an unbounded mpsc channel for communicating between asynchronous tasks without backpressure."><title>unbounded_channel in tokio::sync::mpsc - 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="#">unbounded_channel</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"><div id="rustdoc-modnav"><h2><a href="index.html">In tokio::<wbr>sync::<wbr>mpsc</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">sync</a>::<wbr><a href="index.html">mpsc</a></div><h1>Function <span class="fn">unbounded_<wbr>channel</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/sync/mpsc/unbounded.rs.html#95-102">Source</a> </span></div><pre class="rust item-decl"><code>pub fn unbounded_channel&lt;T&gt;() -&gt; (<a class="struct" href="struct.UnboundedSender.html" title="struct tokio::sync::mpsc::UnboundedSender">UnboundedSender</a>&lt;T&gt;, <a class="struct" href="struct.UnboundedReceiver.html" title="struct tokio::sync::mpsc::UnboundedReceiver">UnboundedReceiver</a>&lt;T&gt;)</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Creates an unbounded mpsc channel for communicating between asynchronous
tasks without backpressure.</p>
<p>A <code>send</code> on this channel will always succeed as long as the receive half has
not been closed. If the receiver falls behind, messages will be arbitrarily
buffered.</p>
<p><strong>Note</strong> that the amount of available system memory is an implicit bound to
the channel. Using an <code>unbounded</code> channel has the ability of causing the
process to run out of memory. In this case, the process will be aborted.</p>
</div></details></section></div></main></body></html>

View File

@@ -0,0 +1,78 @@
<!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="A multi-producer, single-consumer queue for sending values between asynchronous tasks."><title>tokio::sync::mpsc - 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 mpsc</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 mpsc</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#disconnection" title="Disconnection">Disconnection</a></li><li><a href="#clean-shutdown" title="Clean Shutdown">Clean Shutdown</a></li><li><a href="#communicating-between-sync-and-async-code" title="Communicating between sync and async code">Communicating between sync and async code</a></li><li><a href="#multiple-runtimes" title="Multiple runtimes">Multiple runtimes</a></li><li><a href="#allocation-behavior" title="Allocation behavior">Allocation behavior</a></li></ul><h3><a href="#modules">Module Items</a></h3><ul class="block"><li><a href="#modules" title="Modules">Modules</a></li><li><a href="#structs" title="Structs">Structs</a></li><li><a href="#functions" title="Functions">Functions</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="../index.html">In tokio::<wbr>sync</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">sync</a></div><h1>Module <span>mpsc</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/sync/mpsc/mod.rs.html#1-144">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>A multi-producer, single-consumer queue for sending values between
asynchronous tasks.</p>
<p>This module provides two variants of the channel: bounded and unbounded. The
bounded variant has a limit on the number of messages that the channel can
store, and if this limit is reached, trying to send another message will
wait until a message is received from the channel. An unbounded channel has
an infinite capacity, so the <code>send</code> method will always complete immediately.
This makes the <a href="struct.UnboundedSender.html" title="struct tokio::sync::mpsc::UnboundedSender"><code>UnboundedSender</code></a> usable from both synchronous and
asynchronous code.</p>
<p>Similar to the <code>mpsc</code> channels provided by <code>std</code>, the channel constructor
functions provide separate send and receive handles, <a href="struct.Sender.html" title="struct tokio::sync::mpsc::Sender"><code>Sender</code></a> and
<a href="struct.Receiver.html" title="struct tokio::sync::mpsc::Receiver"><code>Receiver</code></a> for the bounded channel, <a href="struct.UnboundedSender.html" title="struct tokio::sync::mpsc::UnboundedSender"><code>UnboundedSender</code></a> and
<a href="struct.UnboundedReceiver.html" title="struct tokio::sync::mpsc::UnboundedReceiver"><code>UnboundedReceiver</code></a> for the unbounded channel. If there is no message to read,
the current task will be notified when a new value is sent. <a href="struct.Sender.html" title="struct tokio::sync::mpsc::Sender"><code>Sender</code></a> and
<a href="struct.UnboundedSender.html" title="struct tokio::sync::mpsc::UnboundedSender"><code>UnboundedSender</code></a> allow sending values into the channel. If the bounded
channel is at capacity, the send is rejected and the task will be notified
when additional capacity is available. In other words, the channel provides
backpressure.</p>
<p>This channel is also suitable for the single-producer single-consumer
use-case. (Unless you only need to send one message, in which case you
should use the <a href="../oneshot/index.html" title="mod tokio::sync::oneshot">oneshot</a> channel.)</p>
<h2 id="disconnection"><a class="doc-anchor" href="#disconnection">§</a>Disconnection</h2>
<p>When all <a href="struct.Sender.html" title="struct tokio::sync::mpsc::Sender"><code>Sender</code></a> handles have been dropped, it is no longer
possible to send values into the channel. This is considered the termination
event of the stream. As such, <code>Receiver::poll</code> returns <code>Ok(Ready(None))</code>.</p>
<p>If the <a href="struct.Receiver.html" title="struct tokio::sync::mpsc::Receiver"><code>Receiver</code></a> handle is dropped, then messages can no longer
be read out of the channel. In this case, all further attempts to send will
result in an error. Additionally, all unread messages will be drained from the
channel and dropped.</p>
<h2 id="clean-shutdown"><a class="doc-anchor" href="#clean-shutdown">§</a>Clean Shutdown</h2>
<p>When the <a href="struct.Receiver.html" title="struct tokio::sync::mpsc::Receiver"><code>Receiver</code></a> is dropped, it is possible for unprocessed messages to
remain in the channel. Instead, it is usually desirable to perform a “clean”
shutdown. To do this, the receiver first calls <code>close</code>, which will prevent
any further messages to be sent into the channel. Then, the receiver
consumes the channel to completion, at which point the receiver can be
dropped.</p>
<h2 id="communicating-between-sync-and-async-code"><a class="doc-anchor" href="#communicating-between-sync-and-async-code">§</a>Communicating between sync and async code</h2>
<p>When you want to communicate between synchronous and asynchronous code, there
are two situations to consider:</p>
<p><strong>Bounded channel</strong>: If you need a bounded channel, you should use a bounded
Tokio <code>mpsc</code> channel for both directions of communication. Instead of calling
the async <a href="struct.Sender.html#method.send" title="method tokio::sync::mpsc::Sender::send"><code>send</code></a> or <a href="struct.Receiver.html#method.recv" title="method tokio::sync::mpsc::Receiver::recv"><code>recv</code></a> methods, in
synchronous code you will need to use the <a href="struct.Sender.html#method.blocking_send" title="method tokio::sync::mpsc::Sender::blocking_send"><code>blocking_send</code></a> or
<a href="struct.Receiver.html#method.blocking_recv" title="method tokio::sync::mpsc::Receiver::blocking_recv"><code>blocking_recv</code></a> methods.</p>
<p><strong>Unbounded channel</strong>: You should use the kind of channel that matches where
the receiver is. So for sending a message <em>from async to sync</em>, you should
use <a href="https://doc.rust-lang.org/1.93.1/std/sync/mpsc/fn.channel.html" title="fn std::sync::mpsc::channel">the standard library unbounded channel</a> or
<a href="https://docs.rs/crossbeam/*/crossbeam/channel/fn.unbounded.html">crossbeam</a>. Similarly, for sending a message <em>from sync
to async</em>, you should use an unbounded Tokio <code>mpsc</code> channel.</p>
<p>Please be aware that the above remarks were written with the <code>mpsc</code> channel
in mind, but they can also be generalized to other kinds of channels. In
general, any channel method that isnt marked async can be called anywhere,
including outside of the runtime. For example, sending a message on a
<a href="../oneshot/index.html" title="mod tokio::sync::oneshot">oneshot</a> channel from outside the runtime is perfectly fine.</p>
<h2 id="multiple-runtimes"><a class="doc-anchor" href="#multiple-runtimes">§</a>Multiple runtimes</h2>
<p>The <code>mpsc</code> channel is runtime agnostic. You can freely move it between
different instances of the Tokio runtime or even use it from non-Tokio
runtimes.</p>
<p>When used in a Tokio runtime, it participates in
<a href="../../task/coop/index.html#cooperative-scheduling" title="mod tokio::task::coop">cooperative scheduling</a> to avoid
starvation. This feature does not apply when used from non-Tokio runtimes.</p>
<p>As an exception, methods ending in <code>_timeout</code> are not runtime agnostic
because they require access to the Tokio timer. See the documentation of
each <code>*_timeout</code> method for more information on its use.</p>
<h2 id="allocation-behavior"><a class="doc-anchor" href="#allocation-behavior">§</a>Allocation behavior</h2><div class="warning">The implementation details described in this section may change in future
Tokio releases.</div>
<p>The mpsc channel stores elements in blocks. Blocks are organized in a linked list. Sending
pushes new elements onto the block at the front of the list, and receiving pops them off the
one at the back. A block can hold 32 messages on a 64-bit target and 16 messages on a 32-bit
target. This number is independent of channel and message size. Each block also stores 4
pointer-sized values for bookkeeping (so on a 64-bit machine, each message has 1 byte of
overhead).</p>
<p>When all values in a block have been received, it becomes empty. It will then be freed, unless
the channels first block (where newly-sent elements are being stored) has no next block. In
that case, the empty block is reused as the next block.</p>
</div></details><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::sync::mpsc::error">error</a></dt><dd>Channel 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.OwnedPermit.html" title="struct tokio::sync::mpsc::OwnedPermit">Owned<wbr>Permit</a></dt><dd>Owned permit to send one value into the channel.</dd><dt><a class="struct" href="struct.Permit.html" title="struct tokio::sync::mpsc::Permit">Permit</a></dt><dd>Permits to send one value into the channel.</dd><dt><a class="struct" href="struct.PermitIterator.html" title="struct tokio::sync::mpsc::PermitIterator">Permit<wbr>Iterator</a></dt><dd>An <a href="https://doc.rust-lang.org/1.93.1/core/iter/traits/iterator/trait.Iterator.html" title="trait core::iter::traits::iterator::Iterator"><code>Iterator</code></a> of <a href="struct.Permit.html" title="struct tokio::sync::mpsc::Permit"><code>Permit</code></a> that can be used to hold <code>n</code> slots in the channel.</dd><dt><a class="struct" href="struct.Receiver.html" title="struct tokio::sync::mpsc::Receiver">Receiver</a></dt><dd>Receives values from the associated <code>Sender</code>.</dd><dt><a class="struct" href="struct.Sender.html" title="struct tokio::sync::mpsc::Sender">Sender</a></dt><dd>Sends values to the associated <code>Receiver</code>.</dd><dt><a class="struct" href="struct.UnboundedReceiver.html" title="struct tokio::sync::mpsc::UnboundedReceiver">Unbounded<wbr>Receiver</a></dt><dd>Receive values from the associated <code>UnboundedSender</code>.</dd><dt><a class="struct" href="struct.UnboundedSender.html" title="struct tokio::sync::mpsc::UnboundedSender">Unbounded<wbr>Sender</a></dt><dd>Send values to the associated <code>UnboundedReceiver</code>.</dd><dt><a class="struct" href="struct.WeakSender.html" title="struct tokio::sync::mpsc::WeakSender">Weak<wbr>Sender</a></dt><dd>A sender that does not prevent the channel from being closed.</dd><dt><a class="struct" href="struct.WeakUnboundedSender.html" title="struct tokio::sync::mpsc::WeakUnboundedSender">Weak<wbr>Unbounded<wbr>Sender</a></dt><dd>An unbounded sender that does not prevent the channel from being closed.</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.channel.html" title="fn tokio::sync::mpsc::channel">channel</a></dt><dd>Creates a bounded mpsc channel for communicating between asynchronous tasks
with backpressure.</dd><dt><a class="fn" href="fn.unbounded_channel.html" title="fn tokio::sync::mpsc::unbounded_channel">unbounded_<wbr>channel</a></dt><dd>Creates an unbounded mpsc channel for communicating between asynchronous
tasks without backpressure.</dd></dl></section></div></main></body></html>

View File

@@ -0,0 +1 @@
window.SIDEBAR_ITEMS = {"fn":["channel","unbounded_channel"],"mod":["error"],"struct":["OwnedPermit","Permit","PermitIterator","Receiver","Sender","UnboundedReceiver","UnboundedSender","WeakSender","WeakUnboundedSender"]};

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

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/sync/mpsc/fn.unbounded_channel.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="../../../../tokio/sync/mpsc/fn.unbounded_channel.html">../../../../tokio/sync/mpsc/fn.unbounded_channel.html</a>...</p>
<script>location.replace("../../../../tokio/sync/mpsc/fn.unbounded_channel.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/sync/mpsc/struct.UnboundedReceiver.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="../../../../tokio/sync/mpsc/struct.UnboundedReceiver.html">../../../../tokio/sync/mpsc/struct.UnboundedReceiver.html</a>...</p>
<script>location.replace("../../../../tokio/sync/mpsc/struct.UnboundedReceiver.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/sync/mpsc/struct.UnboundedSender.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="../../../../tokio/sync/mpsc/struct.UnboundedSender.html">../../../../tokio/sync/mpsc/struct.UnboundedSender.html</a>...</p>
<script>location.replace("../../../../tokio/sync/mpsc/struct.UnboundedSender.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/sync/mpsc/struct.WeakUnboundedSender.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="../../../../tokio/sync/mpsc/struct.WeakUnboundedSender.html">../../../../tokio/sync/mpsc/struct.WeakUnboundedSender.html</a>...</p>
<script>location.replace("../../../../tokio/sync/mpsc/struct.WeakUnboundedSender.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/sync/struct.MappedMutexGuard.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="../../../tokio/sync/struct.MappedMutexGuard.html">../../../tokio/sync/struct.MappedMutexGuard.html</a>...</p>
<script>location.replace("../../../tokio/sync/struct.MappedMutexGuard.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/sync/struct.Mutex.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="../../../tokio/sync/struct.Mutex.html">../../../tokio/sync/struct.Mutex.html</a>...</p>
<script>location.replace("../../../tokio/sync/struct.Mutex.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/sync/struct.MutexGuard.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="../../../tokio/sync/struct.MutexGuard.html">../../../tokio/sync/struct.MutexGuard.html</a>...</p>
<script>location.replace("../../../tokio/sync/struct.MutexGuard.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/sync/struct.OwnedMappedMutexGuard.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="../../../tokio/sync/struct.OwnedMappedMutexGuard.html">../../../tokio/sync/struct.OwnedMappedMutexGuard.html</a>...</p>
<script>location.replace("../../../tokio/sync/struct.OwnedMappedMutexGuard.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/sync/struct.OwnedMutexGuard.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="../../../tokio/sync/struct.OwnedMutexGuard.html">../../../tokio/sync/struct.OwnedMutexGuard.html</a>...</p>
<script>location.replace("../../../tokio/sync/struct.OwnedMutexGuard.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/sync/struct.TryLockError.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="../../../tokio/sync/struct.TryLockError.html">../../../tokio/sync/struct.TryLockError.html</a>...</p>
<script>location.replace("../../../tokio/sync/struct.TryLockError.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/sync/futures/struct.Notified.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="../../../tokio/sync/futures/struct.Notified.html">../../../tokio/sync/futures/struct.Notified.html</a>...</p>
<script>location.replace("../../../tokio/sync/futures/struct.Notified.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/sync/struct.Notify.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="../../../tokio/sync/struct.Notify.html">../../../tokio/sync/struct.Notify.html</a>...</p>
<script>location.replace("../../../tokio/sync/struct.Notify.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/sync/futures/struct.OwnedNotified.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="../../../tokio/sync/futures/struct.OwnedNotified.html">../../../tokio/sync/futures/struct.OwnedNotified.html</a>...</p>
<script>location.replace("../../../tokio/sync/futures/struct.OwnedNotified.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/sync/enum.SetError.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="../../../tokio/sync/enum.SetError.html">../../../tokio/sync/enum.SetError.html</a>...</p>
<script>location.replace("../../../tokio/sync/enum.SetError.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/sync/struct.OnceCell.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="../../../tokio/sync/struct.OnceCell.html">../../../tokio/sync/struct.OnceCell.html</a>...</p>
<script>location.replace("../../../tokio/sync/struct.OnceCell.html" + location.search + location.hash);</script>
</body>
</html>

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="`Oneshot` error types."><title>tokio::sync::oneshot::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><li><a href="#enums" title="Enums">Enums</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="../index.html">In tokio::<wbr>sync::<wbr>oneshot</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">sync</a>::<wbr><a href="../index.html">oneshot</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/sync/oneshot.rs.html#339">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p><code>Oneshot</code> 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.RecvError.html" title="struct tokio::sync::oneshot::error::RecvError">Recv<wbr>Error</a></dt><dd>Error returned by the <code>Future</code> implementation for <code>Receiver</code>.</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.TryRecvError.html" title="enum tokio::sync::oneshot::error::TryRecvError">TryRecv<wbr>Error</a></dt><dd>Error returned by the <code>try_recv</code> function on <code>Receiver</code>.</dd></dl></section></div></main></body></html>

View File

@@ -0,0 +1 @@
window.SIDEBAR_ITEMS = {"enum":["TryRecvError"],"struct":["RecvError"]};

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,21 @@
<!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 a new one-shot channel for sending single values across asynchronous tasks."><title>channel in tokio::sync::oneshot - 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="#">channel</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="#">channel</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#examples" title="Examples">Examples</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="index.html">In tokio::<wbr>sync::<wbr>oneshot</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">sync</a>::<wbr><a href="index.html">oneshot</a></div><h1>Function <span class="fn">channel</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/sync/oneshot.rs.html#497-579">Source</a> </span></div><pre class="rust item-decl"><code>pub fn channel&lt;T&gt;() -&gt; (<a class="struct" href="struct.Sender.html" title="struct tokio::sync::oneshot::Sender">Sender</a>&lt;T&gt;, <a class="struct" href="struct.Receiver.html" title="struct tokio::sync::oneshot::Receiver">Receiver</a>&lt;T&gt;)</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Creates a new one-shot channel for sending single values across asynchronous
tasks.</p>
<p>The function returns separate “send” and “receive” handles. The <code>Sender</code>
handle is used by the producer to send the value. The <code>Receiver</code> handle is
used by the consumer to receive the value.</p>
<p>Each handle can be used on separate tasks.</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::sync::oneshot;
<span class="kw">let </span>(tx, rx) = oneshot::channel();
tokio::spawn(<span class="kw">async move </span>{
<span class="kw">if let </span><span class="prelude-val">Err</span>(<span class="kw">_</span>) = tx.send(<span class="number">3</span>) {
<span class="macro">println!</span>(<span class="string">"the receiver dropped"</span>);
}
});
<span class="kw">match </span>rx.<span class="kw">await </span>{
<span class="prelude-val">Ok</span>(v) =&gt; <span class="macro">println!</span>(<span class="string">"got = {:?}"</span>, v),
<span class="prelude-val">Err</span>(<span class="kw">_</span>) =&gt; <span class="macro">println!</span>(<span class="string">"the sender dropped"</span>),
}</code></pre></div></div></details></section></div></main></body></html>

View File

@@ -0,0 +1,88 @@
<!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="A one-shot channel is used for sending a single message between asynchronous tasks. The `channel` function is used to create a `Sender` and `Receiver` handle pair that form the channel."><title>tokio::sync::oneshot - 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 oneshot</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 oneshot</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="#modules">Module Items</a></h3><ul class="block"><li><a href="#modules" title="Modules">Modules</a></li><li><a href="#structs" title="Structs">Structs</a></li><li><a href="#functions" title="Functions">Functions</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="../index.html">In tokio::<wbr>sync</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">sync</a></div><h1>Module <span>oneshot</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/sync/oneshot.rs.html#1-1594">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>A one-shot channel is used for sending a single message between
asynchronous tasks. The <a href="fn.channel.html" title="fn tokio::sync::oneshot::channel"><code>channel</code></a> function is used to create a
<a href="struct.Sender.html" title="struct tokio::sync::oneshot::Sender"><code>Sender</code></a> and <a href="struct.Receiver.html" title="struct tokio::sync::oneshot::Receiver"><code>Receiver</code></a> handle pair that form the channel.</p>
<p>The <code>Sender</code> handle is used by the producer to send the value.
The <code>Receiver</code> handle is used by the consumer to receive the value.</p>
<p>Each handle can be used on separate tasks.</p>
<p>Since the <code>send</code> method is not async, it can be used anywhere. This includes
sending between two runtimes, and using it from non-async code.</p>
<p>If the <a href="struct.Receiver.html" title="struct tokio::sync::oneshot::Receiver"><code>Receiver</code></a> is closed before receiving a message which has already
been sent, the message will remain in the channel until the receiver is
dropped, at which point the message will be dropped immediately.</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::sync::oneshot;
<span class="kw">let </span>(tx, rx) = oneshot::channel();
tokio::spawn(<span class="kw">async move </span>{
<span class="kw">if let </span><span class="prelude-val">Err</span>(<span class="kw">_</span>) = tx.send(<span class="number">3</span>) {
<span class="macro">println!</span>(<span class="string">"the receiver dropped"</span>);
}
});
<span class="kw">match </span>rx.<span class="kw">await </span>{
<span class="prelude-val">Ok</span>(v) =&gt; <span class="macro">println!</span>(<span class="string">"got = {:?}"</span>, v),
<span class="prelude-val">Err</span>(<span class="kw">_</span>) =&gt; <span class="macro">println!</span>(<span class="string">"the sender dropped"</span>),
}</code></pre></div>
<p>If the sender is dropped without sending, the receiver will fail with
<a href="error/struct.RecvError.html" title="struct tokio::sync::oneshot::error::RecvError"><code>error::RecvError</code></a>:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio::sync::oneshot;
<span class="kw">let </span>(tx, rx) = oneshot::channel::&lt;u32&gt;();
tokio::spawn(<span class="kw">async move </span>{
drop(tx);
});
<span class="kw">match </span>rx.<span class="kw">await </span>{
<span class="prelude-val">Ok</span>(<span class="kw">_</span>) =&gt; <span class="macro">panic!</span>(<span class="string">"This doesn't happen"</span>),
<span class="prelude-val">Err</span>(<span class="kw">_</span>) =&gt; <span class="macro">println!</span>(<span class="string">"the sender dropped"</span>),
}</code></pre></div>
<p>To use a <code>oneshot</code> channel in a <code>tokio::select!</code> loop, add <code>&amp;mut</code> in front of
the channel.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio::sync::oneshot;
<span class="kw">use </span>tokio::time::{interval, sleep, Duration};
<span class="kw">let </span>(send, <span class="kw-2">mut </span>recv) = oneshot::channel();
<span class="kw">let </span><span class="kw-2">mut </span>interval = interval(Duration::from_millis(<span class="number">100</span>));
tokio::spawn(<span class="kw">async move </span>{
sleep(Duration::from_secs(<span class="number">1</span>)).<span class="kw">await</span>;
send.send(<span class="string">"shut down"</span>).unwrap();
});
<span class="kw">loop </span>{
<span class="macro">tokio::select!</span> {
<span class="kw">_ </span>= interval.tick() =&gt; <span class="macro">println!</span>(<span class="string">"Another 100ms"</span>),
msg = <span class="kw-2">&amp;mut </span>recv =&gt; {
<span class="macro">println!</span>(<span class="string">"Got message: {}"</span>, msg.unwrap());
<span class="kw">break</span>;
}
}
}</code></pre></div>
<p>To use a <code>Sender</code> from a destructor, put it in an <a href="https://doc.rust-lang.org/1.93.1/core/option/enum.Option.html" title="enum core::option::Option"><code>Option</code></a> and call
<a href="https://doc.rust-lang.org/1.93.1/core/option/enum.Option.html#method.take" title="method core::option::Option::take"><code>Option::take</code></a>.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio::sync::oneshot;
<span class="kw">struct </span>SendOnDrop {
sender: <span class="prelude-ty">Option</span>&lt;oneshot::Sender&lt;<span class="kw-2">&amp;</span><span class="lifetime">'static </span>str&gt;&gt;,
}
<span class="kw">impl </span>Drop <span class="kw">for </span>SendOnDrop {
<span class="kw">fn </span>drop(<span class="kw-2">&amp;mut </span><span class="self">self</span>) {
<span class="kw">if let </span><span class="prelude-val">Some</span>(sender) = <span class="self">self</span>.sender.take() {
<span class="comment">// Using `let _ =` to ignore send errors.
</span><span class="kw">let _ </span>= sender.send(<span class="string">"I got dropped!"</span>);
}
}
}
<span class="kw">let </span>(send, recv) = oneshot::channel();
<span class="kw">let </span>send_on_drop = SendOnDrop { sender: <span class="prelude-val">Some</span>(send) };
drop(send_on_drop);
<span class="macro">assert_eq!</span>(recv.<span class="kw">await</span>, <span class="prelude-val">Ok</span>(<span class="string">"I got dropped!"</span>));</code></pre></div></div></details><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::sync::oneshot::error">error</a></dt><dd><code>Oneshot</code> 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.Receiver.html" title="struct tokio::sync::oneshot::Receiver">Receiver</a></dt><dd>Receives a value from the associated <a href="struct.Sender.html" title="struct tokio::sync::oneshot::Sender"><code>Sender</code></a>.</dd><dt><a class="struct" href="struct.Sender.html" title="struct tokio::sync::oneshot::Sender">Sender</a></dt><dd>Sends a value to the associated <a href="struct.Receiver.html" title="struct tokio::sync::oneshot::Receiver"><code>Receiver</code></a>.</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.channel.html" title="fn tokio::sync::oneshot::channel">channel</a></dt><dd>Creates a new one-shot channel for sending single values across asynchronous
tasks.</dd></dl></section></div></main></body></html>

View File

@@ -0,0 +1 @@
window.SIDEBAR_ITEMS = {"fn":["channel"],"mod":["error"],"struct":["Receiver","Sender"]};

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/sync/struct.OwnedRwLockReadGuard.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="../../../../tokio/sync/struct.OwnedRwLockReadGuard.html">../../../../tokio/sync/struct.OwnedRwLockReadGuard.html</a>...</p>
<script>location.replace("../../../../tokio/sync/struct.OwnedRwLockReadGuard.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/sync/struct.OwnedRwLockWriteGuard.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="../../../../tokio/sync/struct.OwnedRwLockWriteGuard.html">../../../../tokio/sync/struct.OwnedRwLockWriteGuard.html</a>...</p>
<script>location.replace("../../../../tokio/sync/struct.OwnedRwLockWriteGuard.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/sync/struct.OwnedRwLockMappedWriteGuard.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="../../../../tokio/sync/struct.OwnedRwLockMappedWriteGuard.html">../../../../tokio/sync/struct.OwnedRwLockMappedWriteGuard.html</a>...</p>
<script>location.replace("../../../../tokio/sync/struct.OwnedRwLockMappedWriteGuard.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/sync/struct.RwLockReadGuard.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="../../../../tokio/sync/struct.RwLockReadGuard.html">../../../../tokio/sync/struct.RwLockReadGuard.html</a>...</p>
<script>location.replace("../../../../tokio/sync/struct.RwLockReadGuard.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/sync/struct.RwLock.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="../../../tokio/sync/struct.RwLock.html">../../../tokio/sync/struct.RwLock.html</a>...</p>
<script>location.replace("../../../tokio/sync/struct.RwLock.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/sync/struct.RwLockWriteGuard.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="../../../../tokio/sync/struct.RwLockWriteGuard.html">../../../../tokio/sync/struct.RwLockWriteGuard.html</a>...</p>
<script>location.replace("../../../../tokio/sync/struct.RwLockWriteGuard.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/sync/struct.RwLockMappedWriteGuard.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="../../../../tokio/sync/struct.RwLockMappedWriteGuard.html">../../../../tokio/sync/struct.RwLockMappedWriteGuard.html</a>...</p>
<script>location.replace("../../../../tokio/sync/struct.RwLockMappedWriteGuard.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/sync/struct.OwnedSemaphorePermit.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="../../../tokio/sync/struct.OwnedSemaphorePermit.html">../../../tokio/sync/struct.OwnedSemaphorePermit.html</a>...</p>
<script>location.replace("../../../tokio/sync/struct.OwnedSemaphorePermit.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/sync/struct.Semaphore.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="../../../tokio/sync/struct.Semaphore.html">../../../tokio/sync/struct.Semaphore.html</a>...</p>
<script>location.replace("../../../tokio/sync/struct.Semaphore.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/sync/struct.SemaphorePermit.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="../../../tokio/sync/struct.SemaphorePermit.html">../../../tokio/sync/struct.SemaphorePermit.html</a>...</p>
<script>location.replace("../../../tokio/sync/struct.SemaphorePermit.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/sync/struct.SetOnce.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="../../../tokio/sync/struct.SetOnce.html">../../../tokio/sync/struct.SetOnce.html</a>...</p>
<script>location.replace("../../../tokio/sync/struct.SetOnce.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/sync/struct.SetOnceError.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="../../../tokio/sync/struct.SetOnceError.html">../../../tokio/sync/struct.SetOnceError.html</a>...</p>
<script>location.replace("../../../tokio/sync/struct.SetOnceError.html" + location.search + location.hash);</script>
</body>
</html>

View File

@@ -0,0 +1 @@
window.SIDEBAR_ITEMS = {"enum":["SetError","TryAcquireError"],"mod":["broadcast","futures","mpsc","oneshot","watch"],"struct":["AcquireError","Barrier","BarrierWaitResult","MappedMutexGuard","Mutex","MutexGuard","Notify","OnceCell","OwnedMappedMutexGuard","OwnedMutexGuard","OwnedRwLockMappedWriteGuard","OwnedRwLockReadGuard","OwnedRwLockWriteGuard","OwnedSemaphorePermit","RwLock","RwLockMappedWriteGuard","RwLockReadGuard","RwLockWriteGuard","Semaphore","SemaphorePermit","SetOnce","SetOnceError","TryLockError"]};

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,51 @@
<!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="A barrier enables multiple tasks to synchronize the beginning of some computation."><title>Barrier in tokio::sync - 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 struct"><!--[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="#">Barrier</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="#">Barrier</a></h2><h3><a href="#implementations">Methods</a></h3><ul class="block method"><li><a href="#method.new" title="new">new</a></li><li><a href="#method.wait" title="wait">wait</a></li></ul><h3><a href="#trait-implementations">Trait Implementations</a></h3><ul class="block trait-implementation"><li><a href="#impl-Debug-for-Barrier" title="Debug">Debug</a></li></ul><h3><a href="#synthetic-implementations">Auto Trait Implementations</a></h3><ul class="block synthetic-implementation"><li><a href="#impl-Freeze-for-Barrier" title="!Freeze">!Freeze</a></li><li><a href="#impl-RefUnwindSafe-for-Barrier" title="!RefUnwindSafe">!RefUnwindSafe</a></li><li><a href="#impl-UnwindSafe-for-Barrier" title="!UnwindSafe">!UnwindSafe</a></li><li><a href="#impl-Send-for-Barrier" title="Send">Send</a></li><li><a href="#impl-Sync-for-Barrier" title="Sync">Sync</a></li><li><a href="#impl-Unpin-for-Barrier" title="Unpin">Unpin</a></li></ul><h3><a href="#blanket-implementations">Blanket Implementations</a></h3><ul class="block blanket-implementation"><li><a href="#impl-Any-for-T" title="Any">Any</a></li><li><a href="#impl-Borrow%3CT%3E-for-T" title="Borrow&#60;T&#62;">Borrow&#60;T&#62;</a></li><li><a href="#impl-BorrowMut%3CT%3E-for-T" title="BorrowMut&#60;T&#62;">BorrowMut&#60;T&#62;</a></li><li><a href="#impl-From%3CT%3E-for-T" title="From&#60;T&#62;">From&#60;T&#62;</a></li><li><a href="#impl-Into%3CU%3E-for-T" title="Into&#60;U&#62;">Into&#60;U&#62;</a></li><li><a href="#impl-TryFrom%3CU%3E-for-T" title="TryFrom&#60;U&#62;">TryFrom&#60;U&#62;</a></li><li><a href="#impl-TryInto%3CU%3E-for-T" title="TryInto&#60;U&#62;">TryInto&#60;U&#62;</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="index.html">In tokio::<wbr>sync</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">sync</a></div><h1>Struct <span class="struct">Barrier</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/sync/barrier.rs.html#42-48">Source</a> </span></div><pre class="rust item-decl"><code>pub struct Barrier { <span class="comment">/* private fields */</span> }</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>A barrier enables multiple tasks to synchronize the beginning of some computation.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio::sync::Barrier;
<span class="kw">use </span>std::sync::Arc;
<span class="kw">let </span><span class="kw-2">mut </span>handles = Vec::with_capacity(<span class="number">10</span>);
<span class="kw">let </span>barrier = Arc::new(Barrier::new(<span class="number">10</span>));
<span class="kw">for _ in </span><span class="number">0</span>..<span class="number">10 </span>{
<span class="kw">let </span>c = barrier.clone();
<span class="comment">// The same messages will be printed together.
// You will NOT see any interleaving.
</span>handles.push(tokio::spawn(<span class="kw">async move </span>{
<span class="macro">println!</span>(<span class="string">"before wait"</span>);
<span class="kw">let </span>wait_result = c.wait().<span class="kw">await</span>;
<span class="macro">println!</span>(<span class="string">"after wait"</span>);
wait_result
}));
}
<span class="comment">// Will not resolve until all "after wait" messages have been printed
</span><span class="kw">let </span><span class="kw-2">mut </span>num_leaders = <span class="number">0</span>;
<span class="kw">for </span>handle <span class="kw">in </span>handles {
<span class="kw">let </span>wait_result = handle.<span class="kw">await</span>.unwrap();
<span class="kw">if </span>wait_result.is_leader() {
num_leaders += <span class="number">1</span>;
}
}
<span class="comment">// Exactly one barrier will resolve as the "leader"
</span><span class="macro">assert_eq!</span>(num_leaders, <span class="number">1</span>);</code></pre></div></div></details><h2 id="implementations" class="section-header">Implementations<a href="#implementations" class="anchor">§</a></h2><div id="implementations-list"><details class="toggle implementors-toggle" open><summary><section id="impl-Barrier" class="impl"><a class="src rightside" href="../../src/tokio/sync/barrier.rs.html#57-199">Source</a><a href="#impl-Barrier" class="anchor">§</a><h3 class="code-header">impl <a class="struct" href="struct.Barrier.html" title="struct tokio::sync::Barrier">Barrier</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.new" class="method"><a class="src rightside" href="../../src/tokio/sync/barrier.rs.html#63-111">Source</a><h4 class="code-header">pub fn <a href="#method.new" class="fn">new</a>(n: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.usize.html">usize</a>) -&gt; <a class="struct" href="struct.Barrier.html" title="struct tokio::sync::Barrier">Barrier</a></h4></section></summary><div class="docblock"><p>Creates a new barrier that can block a given number of tasks.</p>
<p>A barrier will block <code>n</code>-1 tasks which call <a href="struct.Barrier.html#method.wait" title="method tokio::sync::Barrier::wait"><code>Barrier::wait</code></a> and then wake up all
tasks at once when the <code>n</code>th task calls <code>wait</code>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.wait" class="method"><a class="src rightside" href="../../src/tokio/sync/barrier.rs.html#125-138">Source</a><h4 class="code-header">pub async fn <a href="#method.wait" class="fn">wait</a>(&amp;self) -&gt; <a class="struct" href="struct.BarrierWaitResult.html" title="struct tokio::sync::BarrierWaitResult">BarrierWaitResult</a></h4></section></summary><div class="docblock"><p>Does not resolve until all tasks have rendezvoused here.</p>
<p>Barriers are re-usable after all tasks have rendezvoused once, and can
be used continuously.</p>
<p>A single (arbitrary) future will receive a <a href="struct.BarrierWaitResult.html" title="struct tokio::sync::BarrierWaitResult"><code>BarrierWaitResult</code></a> that returns <code>true</code> from
<a href="struct.BarrierWaitResult.html#method.is_leader" title="method tokio::sync::BarrierWaitResult::is_leader"><code>BarrierWaitResult::is_leader</code></a> when returning from this function, and all other tasks
will receive a result that will return <code>false</code> from <code>is_leader</code>.</p>
<h5 id="cancel-safety"><a class="doc-anchor" href="#cancel-safety">§</a>Cancel safety</h5>
<p>This method is not cancel safe.</p>
</div></details></div></details></div><h2 id="trait-implementations" class="section-header">Trait Implementations<a href="#trait-implementations" class="anchor">§</a></h2><div id="trait-implementations-list"><details class="toggle implementors-toggle" open><summary><section id="impl-Debug-for-Barrier" class="impl"><a class="src rightside" href="../../src/tokio/sync/barrier.rs.html#41">Source</a><a href="#impl-Debug-for-Barrier" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="struct.Barrier.html" title="struct tokio::sync::Barrier">Barrier</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.fmt" class="method trait-impl"><a class="src rightside" href="../../src/tokio/sync/barrier.rs.html#41">Source</a><a href="#method.fmt" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/core/fmt/trait.Debug.html#tymethod.fmt" class="fn">fmt</a>(&amp;self, f: &amp;mut <a class="struct" href="https://doc.rust-lang.org/1.93.1/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a>&lt;'_&gt;) -&gt; <a class="type" href="https://doc.rust-lang.org/1.93.1/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></h4></section></summary><div class='docblock'>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/1.93.1/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></div></details></div></details></div><h2 id="synthetic-implementations" class="section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor">§</a></h2><div id="synthetic-implementations-list"><section id="impl-Freeze-for-Barrier" class="impl"><a href="#impl-Freeze-for-Barrier" class="anchor">§</a><h3 class="code-header">impl !<a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Freeze.html" title="trait core::marker::Freeze">Freeze</a> for <a class="struct" href="struct.Barrier.html" title="struct tokio::sync::Barrier">Barrier</a></h3></section><section id="impl-RefUnwindSafe-for-Barrier" class="impl"><a href="#impl-RefUnwindSafe-for-Barrier" class="anchor">§</a><h3 class="code-header">impl !<a class="trait" href="https://doc.rust-lang.org/1.93.1/core/panic/unwind_safe/trait.RefUnwindSafe.html" title="trait core::panic::unwind_safe::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="struct.Barrier.html" title="struct tokio::sync::Barrier">Barrier</a></h3></section><section id="impl-Send-for-Barrier" class="impl"><a href="#impl-Send-for-Barrier" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="struct.Barrier.html" title="struct tokio::sync::Barrier">Barrier</a></h3></section><section id="impl-Sync-for-Barrier" class="impl"><a href="#impl-Sync-for-Barrier" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="struct.Barrier.html" title="struct tokio::sync::Barrier">Barrier</a></h3></section><section id="impl-Unpin-for-Barrier" class="impl"><a href="#impl-Unpin-for-Barrier" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="struct.Barrier.html" title="struct tokio::sync::Barrier">Barrier</a></h3></section><section id="impl-UnwindSafe-for-Barrier" class="impl"><a href="#impl-UnwindSafe-for-Barrier" class="anchor">§</a><h3 class="code-header">impl !<a class="trait" href="https://doc.rust-lang.org/1.93.1/core/panic/unwind_safe/trait.UnwindSafe.html" title="trait core::panic::unwind_safe::UnwindSafe">UnwindSafe</a> for <a class="struct" href="struct.Barrier.html" title="struct tokio::sync::Barrier">Barrier</a></h3></section></div><h2 id="blanket-implementations" class="section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor">§</a></h2><div id="blanket-implementations-list"><details class="toggle implementors-toggle"><summary><section id="impl-Any-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/core/any.rs.html#138">Source</a><a href="#impl-Any-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T<div class="where">where
T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.type_id" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/core/any.rs.html#139">Source</a><a href="#method.type_id" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/core/any/trait.Any.html#tymethod.type_id" class="fn">type_id</a>(&amp;self) -&gt; <a class="struct" href="https://doc.rust-lang.org/1.93.1/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></h4></section></summary><div class='docblock'>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/1.93.1/core/any/trait.Any.html#tymethod.type_id">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Borrow%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/core/borrow.rs.html#212">Source</a><a href="#impl-Borrow%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a>&lt;T&gt; for T<div class="where">where
T: ?<a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.borrow" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/core/borrow.rs.html#214">Source</a><a href="#method.borrow" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/core/borrow/trait.Borrow.html#tymethod.borrow" class="fn">borrow</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.reference.html">&amp;T</a></h4></section></summary><div class='docblock'>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/1.93.1/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-BorrowMut%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/core/borrow.rs.html#221">Source</a><a href="#impl-BorrowMut%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a>&lt;T&gt; for T<div class="where">where
T: ?<a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.borrow_mut" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/core/borrow.rs.html#222">Source</a><a href="#method.borrow_mut" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fn">borrow_mut</a>(&amp;mut self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.reference.html">&amp;mut T</a></h4></section></summary><div class='docblock'>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/1.93.1/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-From%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/core/convert/mod.rs.html#785">Source</a><a href="#impl-From%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;T&gt; for T</h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.from" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/core/convert/mod.rs.html#788">Source</a><a href="#method.from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/core/convert/trait.From.html#tymethod.from" class="fn">from</a>(t: T) -&gt; T</h4></section></summary><div class="docblock"><p>Returns the argument unchanged.</p>
</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Into%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/core/convert/mod.rs.html#767-769">Source</a><a href="#impl-Into%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T, U&gt; <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;U&gt; for T<div class="where">where
U: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;T&gt;,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.into" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/core/convert/mod.rs.html#777">Source</a><a href="#method.into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/core/convert/trait.Into.html#tymethod.into" class="fn">into</a>(self) -&gt; U</h4></section></summary><div class="docblock"><p>Calls <code>U::from(self)</code>.</p>
<p>That is, this conversion is whatever the implementation of
<code><a href="https://doc.rust-lang.org/1.93.1/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;T&gt; for U</code> chooses to do.</p>
</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-TryFrom%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/core/convert/mod.rs.html#827-829">Source</a><a href="#impl-TryFrom%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T, U&gt; <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;U&gt; for T<div class="where">where
U: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;T&gt;,</div></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Error-1" class="associatedtype trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/core/convert/mod.rs.html#831">Source</a><a href="#associatedtype.Error-1" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.93.1/core/convert/trait.TryFrom.html#associatedtype.Error" class="associatedtype">Error</a> = <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a></h4></section></summary><div class='docblock'>The type returned in the event of a conversion error.</div></details><details class="toggle method-toggle" open><summary><section id="method.try_from" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/core/convert/mod.rs.html#834">Source</a><a href="#method.try_from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/core/convert/trait.TryFrom.html#tymethod.try_from" class="fn">try_from</a>(value: U) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;T, &lt;T as <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;U&gt;&gt;::<a class="associatedtype" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>&gt;</h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-TryInto%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/core/convert/mod.rs.html#811-813">Source</a><a href="#impl-TryInto%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T, U&gt; <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a>&lt;U&gt; for T<div class="where">where
U: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;T&gt;,</div></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Error" class="associatedtype trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/core/convert/mod.rs.html#815">Source</a><a href="#associatedtype.Error" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.93.1/core/convert/trait.TryInto.html#associatedtype.Error" class="associatedtype">Error</a> = &lt;U as <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;T&gt;&gt;::<a class="associatedtype" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a></h4></section></summary><div class='docblock'>The type returned in the event of a conversion error.</div></details><details class="toggle method-toggle" open><summary><section id="method.try_into" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/core/convert/mod.rs.html#818">Source</a><a href="#method.try_into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/core/convert/trait.TryInto.html#tymethod.try_into" class="fn">try_into</a>(self) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;U, &lt;U as <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;T&gt;&gt;::<a class="associatedtype" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>&gt;</h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details></div></section></div></main></body></html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Some files were not shown because too many files have changed in this diff Show More