Auto Generated Documentation
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="API documentation for the Rust `Sender` struct in crate `tokio`."><meta name="keywords" content="rust, rustlang, rust-lang, Sender"><title>tokio::sync::mpsc::Sender - Rust</title><link rel="stylesheet" type="text/css" href="../../../normalize.css"><link rel="stylesheet" type="text/css" href="../../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../../../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../../../ayu.css" disabled ><script id="default-settings"></script><script src="../../../storage.js"></script><noscript><link rel="stylesheet" href="../../../noscript.css"></noscript><link rel="icon" type="image/svg+xml" href="../../../favicon.svg">
|
||||
<link rel="alternate icon" type="image/png" href="../../../favicon-16x16.png">
|
||||
<link rel="alternate icon" type="image/png" href="../../../favicon-32x32.png"><style type="text/css">#crate-search{background-image:url("../../../down-arrow.svg");}</style></head><body class="rustdoc struct"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">☰</div><a href='../../../tokio/index.html'><div class='logo-container rust-logo'><img src='../../../rust-logo.png' alt='logo'></div></a><p class="location">Struct Sender</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#implementations">Methods</a><div class="sidebar-links"><a href="#method.blocking_send">blocking_send</a><a href="#method.closed">closed</a><a href="#method.is_closed">is_closed</a><a href="#method.reserve">reserve</a><a href="#method.same_channel">same_channel</a><a href="#method.send">send</a><a href="#method.send_timeout">send_timeout</a><a href="#method.try_reserve">try_reserve</a><a href="#method.try_send">try_send</a></div><a class="sidebar-title" href="#trait-implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-Clone">Clone</a><a href="#impl-Debug">Debug</a></div><a class="sidebar-title" href="#synthetic-implementations">Auto Trait Implementations</a><div class="sidebar-links"><a href="#impl-RefUnwindSafe">!RefUnwindSafe</a><a href="#impl-Send">Send</a><a href="#impl-Sync">Sync</a><a href="#impl-Unpin">Unpin</a><a href="#impl-UnwindSafe">!UnwindSafe</a></div><a class="sidebar-title" href="#blanket-implementations">Blanket Implementations</a><div class="sidebar-links"><a href="#impl-Any">Any</a><a href="#impl-Borrow%3CT%3E">Borrow<T></a><a href="#impl-BorrowMut%3CT%3E">BorrowMut<T></a><a href="#impl-From%3CT%3E">From<T></a><a href="#impl-Into%3CU%3E">Into<U></a><a href="#impl-ToOwned">ToOwned</a><a href="#impl-TryFrom%3CU%3E">TryFrom<U></a><a href="#impl-TryInto%3CU%3E">TryInto<U></a></div></div><p class="location"><a href="../../index.html">tokio</a>::<wbr><a href="../index.html">sync</a>::<wbr><a href="index.html">mpsc</a></p><script>window.sidebarCurrent = {name: "Sender", ty: "struct", relpath: ""};</script><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="../../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><script src="../../../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><button type="button" class="help-button">?</button>
|
||||
<a id="settings-menu" href="../../../settings.html"><img src="../../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="out-of-band"><span id="render-detail"><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span><a class="srclink" href="../../../src/tokio/sync/mpsc/bounded.rs.html#19-21" title="goto source code">[src]</a></span><span class="in-band">Struct <a href="../../index.html">tokio</a>::<wbr><a href="../index.html">sync</a>::<wbr><a href="index.html">mpsc</a>::<wbr><a class="struct" href="">Sender</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust struct">pub struct Sender<T> { /* fields omitted */ }</pre></div><div class="docblock"><p>Send values to the associated <code>Receiver</code>.</p>
|
||||
<a id="settings-menu" href="../../../settings.html"><img src="../../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="out-of-band"><span id="render-detail"><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span><a class="srclink" href="../../../src/tokio/sync/mpsc/bounded.rs.html#21-23" title="goto source code">[src]</a></span><span class="in-band">Struct <a href="../../index.html">tokio</a>::<wbr><a href="../index.html">sync</a>::<wbr><a href="index.html">mpsc</a>::<wbr><a class="struct" href="">Sender</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust struct">pub struct Sender<T> { /* fields omitted */ }</pre></div><div class="docblock"><p>Send values to the associated <code>Receiver</code>.</p>
|
||||
<p>Instances are created by the <a href="../../../tokio/sync/mpsc/fn.channel.html"><code>channel</code></a> function.</p>
|
||||
</div><h2 id="implementations" class="small-section-header">Implementations<a href="#implementations" class="anchor"></a></h2><h3 id="impl" class="impl"><code class="in-band">impl<T> <a class="struct" href="../../../tokio/sync/mpsc/struct.Sender.html" title="struct tokio::sync::mpsc::Sender">Sender</a><T></code><a href="#impl" class="anchor"></a><a class="srclink" href="../../../src/tokio/sync/mpsc/bounded.rs.html#312-717" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.send" class="method"><code>pub async fn <a href="#method.send" class="fnname">send</a>(&self, value: T) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, <a class="struct" href="../../../tokio/sync/mpsc/error/struct.SendError.html" title="struct tokio::sync::mpsc::error::SendError">SendError</a><T>></code><a class="srclink" href="../../../src/tokio/sync/mpsc/bounded.rs.html#362-370" title="goto source code">[src]</a></h4><div class="docblock"><p>Sends a value, waiting until there is capacity.</p>
|
||||
<p>To use the <code>Sender</code> in a poll function, you can use the <a href="https://docs.rs/tokio-util/0.6/tokio_util/sync/struct.PollSender.html"><code>PollSender</code></a>
|
||||
utility.</p>
|
||||
</div><h2 id="implementations" class="small-section-header">Implementations<a href="#implementations" class="anchor"></a></h2><h3 id="impl" class="impl"><code class="in-band">impl<T> <a class="struct" href="../../../tokio/sync/mpsc/struct.Sender.html" title="struct tokio::sync::mpsc::Sender">Sender</a><T></code><a href="#impl" class="anchor"></a><a class="srclink" href="../../../src/tokio/sync/mpsc/bounded.rs.html#297-702" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.send" class="method"><code>pub async fn <a href="#method.send" class="fnname">send</a>(&self, value: T) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, <a class="struct" href="../../../tokio/sync/mpsc/error/struct.SendError.html" title="struct tokio::sync::mpsc::error::SendError">SendError</a><T>></code><a class="srclink" href="../../../src/tokio/sync/mpsc/bounded.rs.html#347-355" title="goto source code">[src]</a></h4><div class="docblock"><p>Sends a value, waiting until there is capacity.</p>
|
||||
<p>A successful send occurs when it is determined that the other end of the
|
||||
channel has not hung up already. An unsuccessful send would be one where
|
||||
the corresponding receiver has already been closed. Note that a return
|
||||
@@ -39,7 +41,7 @@ previously sent value was received.</p>
|
||||
<span class="macro">println</span><span class="macro">!</span>(<span class="string">"got = {}"</span>, <span class="ident">i</span>);
|
||||
}
|
||||
}</pre></div>
|
||||
</div><h4 id="method.closed" class="method"><code>pub async fn <a href="#method.closed" class="fnname">closed</a>(&self)</code><a class="srclink" href="../../../src/tokio/sync/mpsc/bounded.rs.html#403-405" title="goto source code">[src]</a></h4><div class="docblock"><p>Completes when the receiver has dropped.</p>
|
||||
</div><h4 id="method.closed" class="method"><code>pub async fn <a href="#method.closed" class="fnname">closed</a>(&self)</code><a class="srclink" href="../../../src/tokio/sync/mpsc/bounded.rs.html#388-390" title="goto source code">[src]</a></h4><div class="docblock"><p>Completes when the receiver has dropped.</p>
|
||||
<p>This allows the producers to get notified when interest in the produced
|
||||
values is canceled and immediately stop doing work.</p>
|
||||
<h1 id="examples-1" class="section-header"><a href="#examples-1">Examples</a></h1>
|
||||
@@ -66,7 +68,7 @@ values is canceled and immediately stop doing work.</p>
|
||||
);
|
||||
<span class="macro">println</span><span class="macro">!</span>(<span class="string">"Receiver dropped"</span>);
|
||||
}</pre></div>
|
||||
</div><h4 id="method.try_send" class="method"><code>pub fn <a href="#method.try_send" class="fnname">try_send</a>(&self, message: T) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, <a class="enum" href="../../../tokio/sync/mpsc/error/enum.TrySendError.html" title="enum tokio::sync::mpsc::error::TrySendError">TrySendError</a><T>></code><a class="srclink" href="../../../src/tokio/sync/mpsc/bounded.rs.html#465-475" title="goto source code">[src]</a></h4><div class="docblock"><p>Attempts to immediately send a message on this <code>Sender</code></p>
|
||||
</div><h4 id="method.try_send" class="method"><code>pub fn <a href="#method.try_send" class="fnname">try_send</a>(&self, message: T) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, <a class="enum" href="../../../tokio/sync/mpsc/error/enum.TrySendError.html" title="enum tokio::sync::mpsc::error::TrySendError">TrySendError</a><T>></code><a class="srclink" href="../../../src/tokio/sync/mpsc/bounded.rs.html#450-460" title="goto source code">[src]</a></h4><div class="docblock"><p>Attempts to immediately send a message on this <code>Sender</code></p>
|
||||
<p>This method differs from <a href="../../../tokio/sync/mpsc/struct.Sender.html#method.send"><code>send</code></a> by returning immediately if the channel's
|
||||
buffer is full or no receiver is waiting to acquire some data. Compared
|
||||
with <a href="../../../tokio/sync/mpsc/struct.Sender.html#method.send"><code>send</code></a>, this function has two failure cases instead of one (one for
|
||||
@@ -113,7 +115,7 @@ an error. The error includes the value passed to <code>send</code>.</p>
|
||||
<span class="prelude-val">None</span> <span class="op">=</span><span class="op">></span> <span class="macro">println</span><span class="macro">!</span>(<span class="string">"the third message was never sent"</span>),
|
||||
}
|
||||
}</pre></div>
|
||||
</div><h4 id="method.send_timeout" class="method"><code>pub async fn <a href="#method.send_timeout" class="fnname">send_timeout</a>(<br> &self, <br> value: T, <br> timeout: <a class="struct" href="https://doc.rust-lang.org/nightly/core/time/struct.Duration.html" title="struct core::time::Duration">Duration</a><br>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, <a class="enum" href="../../../tokio/sync/mpsc/error/enum.SendTimeoutError.html" title="enum tokio::sync::mpsc::error::SendTimeoutError">SendTimeoutError</a><T>></code><a class="srclink" href="../../../src/tokio/sync/mpsc/bounded.rs.html#524-541" title="goto source code">[src]</a></h4><div class="docblock"><p>Sends a value, waiting until there is capacity, but only for a limited time.</p>
|
||||
</div><h4 id="method.send_timeout" class="method"><code>pub async fn <a href="#method.send_timeout" class="fnname">send_timeout</a>(<br> &self, <br> value: T, <br> timeout: <a class="struct" href="https://doc.rust-lang.org/nightly/core/time/struct.Duration.html" title="struct core::time::Duration">Duration</a><br>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, <a class="enum" href="../../../tokio/sync/mpsc/error/enum.SendTimeoutError.html" title="enum tokio::sync::mpsc::error::SendTimeoutError">SendTimeoutError</a><T>></code><a class="srclink" href="../../../src/tokio/sync/mpsc/bounded.rs.html#509-526" title="goto source code">[src]</a></h4><div class="docblock"><p>Sends a value, waiting until there is capacity, but only for a limited time.</p>
|
||||
<p>Shares the same success and error conditions as <a href="../../../tokio/sync/mpsc/struct.Sender.html#method.send"><code>send</code></a>, adding one more
|
||||
condition for an unsuccessful send, which is when the provided timeout has
|
||||
elapsed, and there is no capacity available.</p>
|
||||
@@ -147,7 +149,7 @@ previously sent value was received, unless the timeout has elapsed.</p>
|
||||
<span class="ident">sleep</span>(<span class="ident">Duration</span>::<span class="ident">from_millis</span>(<span class="number">200</span>)).<span class="kw">await</span>;
|
||||
}
|
||||
}</pre></div>
|
||||
</div><h4 id="method.blocking_send" class="method"><code>pub fn <a href="#method.blocking_send" class="fnname">blocking_send</a>(&self, value: T) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, <a class="struct" href="../../../tokio/sync/mpsc/error/struct.SendError.html" title="struct tokio::sync::mpsc::error::SendError">SendError</a><T>></code><a class="srclink" href="../../../src/tokio/sync/mpsc/bounded.rs.html#577-579" title="goto source code">[src]</a></h4><div class="docblock"><p>Blocking send to call outside of asynchronous contexts.</p>
|
||||
</div><h4 id="method.blocking_send" class="method"><code>pub fn <a href="#method.blocking_send" class="fnname">blocking_send</a>(&self, value: T) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, <a class="struct" href="../../../tokio/sync/mpsc/error/struct.SendError.html" title="struct tokio::sync::mpsc::error::SendError">SendError</a><T>></code><a class="srclink" href="../../../src/tokio/sync/mpsc/bounded.rs.html#562-564" title="goto source code">[src]</a></h4><div class="docblock"><p>Blocking send to call outside of asynchronous contexts.</p>
|
||||
<p>This method is intended for use cases where you are sending from
|
||||
synchronous code to asynchronous code, and will work even if the
|
||||
receiver is not using <a href="../../../tokio/sync/mpsc/struct.Receiver.html#method.blocking_recv"><code>blocking_recv</code></a> to receive the message.</p>
|
||||
@@ -172,7 +174,7 @@ context.</p>
|
||||
});
|
||||
<span class="ident">sync_code</span>.<span class="ident">join</span>().<span class="ident">unwrap</span>()
|
||||
}</pre></div>
|
||||
</div><h4 id="method.is_closed" class="method"><code>pub fn <a href="#method.is_closed" class="fnname">is_closed</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code><a class="srclink" href="../../../src/tokio/sync/mpsc/bounded.rs.html#599-601" title="goto source code">[src]</a></h4><div class="docblock"><p>Checks if the channel has been closed. This happens when the
|
||||
</div><h4 id="method.is_closed" class="method"><code>pub fn <a href="#method.is_closed" class="fnname">is_closed</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code><a class="srclink" href="../../../src/tokio/sync/mpsc/bounded.rs.html#584-586" title="goto source code">[src]</a></h4><div class="docblock"><p>Checks if the channel has been closed. This happens when the
|
||||
<a href="../../../tokio/sync/mpsc/struct.Receiver.html"><code>Receiver</code></a> is dropped, or when the <a href="../../../tokio/sync/mpsc/struct.Receiver.html#method.close"><code>Receiver::close</code></a> method is
|
||||
called.</p>
|
||||
|
||||
@@ -186,7 +188,7 @@ called.</p>
|
||||
<span class="ident">drop</span>(<span class="ident">rx</span>);
|
||||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">tx</span>.<span class="ident">is_closed</span>());
|
||||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">tx2</span>.<span class="ident">is_closed</span>());</pre></div>
|
||||
</div><h4 id="method.reserve" class="method"><code>pub async fn <a href="#method.reserve" class="fnname">reserve</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="struct" href="../../../tokio/sync/mpsc/struct.Permit.html" title="struct tokio::sync::mpsc::Permit">Permit</a><'_, T>, <a class="struct" href="../../../tokio/sync/mpsc/error/struct.SendError.html" title="struct tokio::sync::mpsc::error::SendError">SendError</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>>></code><a class="srclink" href="../../../src/tokio/sync/mpsc/bounded.rs.html#641-648" title="goto source code">[src]</a></h4><div class="docblock"><p>Wait for channel capacity. Once capacity to send one message is
|
||||
</div><h4 id="method.reserve" class="method"><code>pub async fn <a href="#method.reserve" class="fnname">reserve</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="struct" href="../../../tokio/sync/mpsc/struct.Permit.html" title="struct tokio::sync::mpsc::Permit">Permit</a><'_, T>, <a class="struct" href="../../../tokio/sync/mpsc/error/struct.SendError.html" title="struct tokio::sync::mpsc::error::SendError">SendError</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>>></code><a class="srclink" href="../../../src/tokio/sync/mpsc/bounded.rs.html#626-633" title="goto source code">[src]</a></h4><div class="docblock"><p>Wait for channel capacity. Once capacity to send one message is
|
||||
available, it is reserved for the caller.</p>
|
||||
<p>If the channel is full, the function waits for the number of unreceived
|
||||
messages to become less than the channel capacity. Capacity to send one
|
||||
@@ -216,7 +218,7 @@ to the channel.</p>
|
||||
<span class="comment">// The value sent on the permit is received</span>
|
||||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">rx</span>.<span class="ident">recv</span>().<span class="kw">await</span>.<span class="ident">unwrap</span>(), <span class="number">456</span>);
|
||||
}</pre></div>
|
||||
</div><h4 id="method.try_reserve" class="method"><code>pub fn <a href="#method.try_reserve" class="fnname">try_reserve</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="struct" href="../../../tokio/sync/mpsc/struct.Permit.html" title="struct tokio::sync::mpsc::Permit">Permit</a><'_, T>, <a class="enum" href="../../../tokio/sync/mpsc/error/enum.TrySendError.html" title="enum tokio::sync::mpsc::error::TrySendError">TrySendError</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>>></code><a class="srclink" href="../../../src/tokio/sync/mpsc/bounded.rs.html#693-700" title="goto source code">[src]</a></h4><div class="docblock"><p>Try to acquire a slot in the channel without waiting for the slot to become
|
||||
</div><h4 id="method.try_reserve" class="method"><code>pub fn <a href="#method.try_reserve" class="fnname">try_reserve</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="struct" href="../../../tokio/sync/mpsc/struct.Permit.html" title="struct tokio::sync::mpsc::Permit">Permit</a><'_, T>, <a class="enum" href="../../../tokio/sync/mpsc/error/enum.TrySendError.html" title="enum tokio::sync::mpsc::error::TrySendError">TrySendError</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>>></code><a class="srclink" href="../../../src/tokio/sync/mpsc/bounded.rs.html#678-685" title="goto source code">[src]</a></h4><div class="docblock"><p>Try to acquire a slot in the channel without waiting for the slot to become
|
||||
available.</p>
|
||||
<p>If the channel is full this function will return <a href="../../../tokio/sync/mpsc/error/enum.TrySendError.html" title="TrySendError"><code>TrySendError</code></a>, otherwise
|
||||
if there is a slot available it will return a <a href="../../../tokio/sync/mpsc/struct.Permit.html"><code>Permit</code></a> that will then allow you
|
||||
@@ -250,7 +252,7 @@ to the channel.</p>
|
||||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">rx</span>.<span class="ident">recv</span>().<span class="kw">await</span>.<span class="ident">unwrap</span>(), <span class="number">456</span>);
|
||||
|
||||
}</pre></div>
|
||||
</div><h4 id="method.same_channel" class="method"><code>pub fn <a href="#method.same_channel" class="fnname">same_channel</a>(&self, other: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>Self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code><a class="srclink" href="../../../src/tokio/sync/mpsc/bounded.rs.html#714-716" title="goto source code">[src]</a></h4><div class="docblock"><p>Returns <code>true</code> if senders belong to the same channel.</p>
|
||||
</div><h4 id="method.same_channel" class="method"><code>pub fn <a href="#method.same_channel" class="fnname">same_channel</a>(&self, other: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>Self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code><a class="srclink" href="../../../src/tokio/sync/mpsc/bounded.rs.html#699-701" title="goto source code">[src]</a></h4><div class="docblock"><p>Returns <code>true</code> if senders belong to the same channel.</p>
|
||||
<h1 id="examples-7" class="section-header"><a href="#examples-7">Examples</a></h1>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||||
<span class="kw">let</span> (<span class="ident">tx</span>, <span class="ident">rx</span>) <span class="op">=</span> <span class="ident">tokio</span>::<span class="ident">sync</span>::<span class="ident">mpsc</span>::<span class="ident">channel</span>::<span class="op"><</span>()<span class="op">></span>(<span class="number">1</span>);
|
||||
@@ -259,9 +261,9 @@ to the channel.</p>
|
||||
|
||||
<span class="kw">let</span> (<span class="ident">tx3</span>, <span class="ident">rx3</span>) <span class="op">=</span> <span class="ident">tokio</span>::<span class="ident">sync</span>::<span class="ident">mpsc</span>::<span class="ident">channel</span>::<span class="op"><</span>()<span class="op">></span>(<span class="number">1</span>);
|
||||
<span class="macro">assert</span><span class="macro">!</span>(<span class="op">!</span><span class="ident">tx3</span>.<span class="ident">same_channel</span>(<span class="kw-2">&</span><span class="ident">tx2</span>));</pre></div>
|
||||
</div></div><h2 id="trait-implementations" class="small-section-header">Trait Implementations<a href="#trait-implementations" class="anchor"></a></h2><div id="trait-implementations-list"><h3 id="impl-Clone" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> for <a class="struct" href="../../../tokio/sync/mpsc/struct.Sender.html" title="struct tokio::sync::mpsc::Sender">Sender</a><T></code><a href="#impl-Clone" class="anchor"></a><a class="srclink" href="../../../src/tokio/sync/mpsc/bounded.rs.html#719-725" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.clone" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#tymethod.clone" class="fnname">clone</a>(&self) -> Self</code><a class="srclink" href="../../../src/tokio/sync/mpsc/bounded.rs.html#720-724" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Returns a copy of the value. <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#tymethod.clone">Read more</a></p>
|
||||
</div></div><h2 id="trait-implementations" class="small-section-header">Trait Implementations<a href="#trait-implementations" class="anchor"></a></h2><div id="trait-implementations-list"><h3 id="impl-Clone" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> for <a class="struct" href="../../../tokio/sync/mpsc/struct.Sender.html" title="struct tokio::sync::mpsc::Sender">Sender</a><T></code><a href="#impl-Clone" class="anchor"></a><a class="srclink" href="../../../src/tokio/sync/mpsc/bounded.rs.html#704-710" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.clone" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#tymethod.clone" class="fnname">clone</a>(&self) -> Self</code><a class="srclink" href="../../../src/tokio/sync/mpsc/bounded.rs.html#705-709" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Returns a copy of the value. <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#tymethod.clone">Read more</a></p>
|
||||
</div><h4 id="method.clone_from" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#method.clone_from" class="fnname">clone_from</a>(&mut self, source: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>Self)</code><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/clone.rs.html#128-130" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs copy-assignment from <code>source</code>. <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#method.clone_from">Read more</a></p>
|
||||
</div></div><h3 id="impl-Debug" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="../../../tokio/sync/mpsc/struct.Sender.html" title="struct tokio::sync::mpsc::Sender">Sender</a><T></code><a href="#impl-Debug" class="anchor"></a><a class="srclink" href="../../../src/tokio/sync/mpsc/bounded.rs.html#727-733" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.fmt" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt" class="fnname">fmt</a>(&self, fmt: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a><'_>) -> <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code><a class="srclink" href="../../../src/tokio/sync/mpsc/bounded.rs.html#728-732" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></p>
|
||||
</div></div><h3 id="impl-Debug" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="../../../tokio/sync/mpsc/struct.Sender.html" title="struct tokio::sync::mpsc::Sender">Sender</a><T></code><a href="#impl-Debug" class="anchor"></a><a class="srclink" href="../../../src/tokio/sync/mpsc/bounded.rs.html#712-718" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.fmt" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt" class="fnname">fmt</a>(&self, fmt: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a><'_>) -> <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code><a class="srclink" href="../../../src/tokio/sync/mpsc/bounded.rs.html#713-717" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></p>
|
||||
</div></div></div><h2 id="synthetic-implementations" class="small-section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor"></a></h2><div id="synthetic-implementations-list"><h3 id="impl-RefUnwindSafe" class="impl"><code class="in-band">impl<T> !<a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.RefUnwindSafe.html" title="trait std::panic::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="../../../tokio/sync/mpsc/struct.Sender.html" title="struct tokio::sync::mpsc::Sender">Sender</a><T></code><a href="#impl-RefUnwindSafe" class="anchor"></a><a class="srclink" href="../../../src/tokio/lib.rs.html#1" title="goto source code">[src]</a></h3><div class="impl-items"></div><h3 id="impl-Send" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="../../../tokio/sync/mpsc/struct.Sender.html" title="struct tokio::sync::mpsc::Sender">Sender</a><T> <span class="where fmt-newline">where<br> T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a>, </span></code><a href="#impl-Send" class="anchor"></a><a class="srclink" href="../../../src/tokio/lib.rs.html#1" title="goto source code">[src]</a></h3><div class="impl-items"></div><h3 id="impl-Sync" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="../../../tokio/sync/mpsc/struct.Sender.html" title="struct tokio::sync::mpsc::Sender">Sender</a><T> <span class="where fmt-newline">where<br> T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a>, </span></code><a href="#impl-Sync" class="anchor"></a><a class="srclink" href="../../../src/tokio/lib.rs.html#1" title="goto source code">[src]</a></h3><div class="impl-items"></div><h3 id="impl-Unpin" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="../../../tokio/sync/mpsc/struct.Sender.html" title="struct tokio::sync::mpsc::Sender">Sender</a><T></code><a href="#impl-Unpin" class="anchor"></a><a class="srclink" href="../../../src/tokio/lib.rs.html#1" title="goto source code">[src]</a></h3><div class="impl-items"></div><h3 id="impl-UnwindSafe" class="impl"><code class="in-band">impl<T> !<a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.UnwindSafe.html" title="trait std::panic::UnwindSafe">UnwindSafe</a> for <a class="struct" href="../../../tokio/sync/mpsc/struct.Sender.html" title="struct tokio::sync::mpsc::Sender">Sender</a><T></code><a href="#impl-UnwindSafe" class="anchor"></a><a class="srclink" href="../../../src/tokio/lib.rs.html#1" title="goto source code">[src]</a></h3><div class="impl-items"></div></div><h2 id="blanket-implementations" class="small-section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor"></a></h2><div id="blanket-implementations-list"><h3 id="impl-Any" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T <span class="where fmt-newline">where<br> T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-Any" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#108-112" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.type_id" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id" class="fnname">type_id</a>(&self) -> <a class="struct" href="https://doc.rust-lang.org/nightly/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#109-111" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id">Read more</a></p>
|
||||
</div></div><h3 id="impl-Borrow%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a><T> for T <span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-Borrow%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#210-214" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow" class="fnname">borrow</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>T<span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl<'_, F> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#211-213" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></p>
|
||||
</div></div><h3 id="impl-BorrowMut%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a><T> for T <span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-BorrowMut%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#217-221" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow_mut" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fnname">borrow_mut</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>T<span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><h3 class="notable">Notable traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl<'_, F> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="type">Output</a> = <F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#218-220" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></p>
|
||||
|
||||
Reference in New Issue
Block a user