blob: 4516541d523bc7b6034c4beed70ef77e886aa389 [file] [log] [blame]
<!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="Combine many streams into one, indexing each source stream with a unique key."><meta name="keywords" content="rust, rustlang, rust-lang, StreamMap"><title>StreamMap in tokio_stream - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceCodePro-Semibold.ttf.woff2"><link rel="stylesheet" href="../normalize.css"><link rel="stylesheet" href="../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" href="../ayu.css" disabled><link rel="stylesheet" href="../dark.css" disabled><link rel="stylesheet" href="../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../storage.js"></script><script defer src="sidebar-items.js"></script><script defer src="../main.js"></script><noscript><link rel="stylesheet" href="../noscript.css"></noscript><link rel="alternate icon" type="image/png" href="../favicon-16x16.png"><link rel="alternate icon" type="image/png" href="../favicon-32x32.png"><link rel="icon" type="image/svg+xml" href="../favicon.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]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">&#9776;</button><a class="sidebar-logo" href="../tokio_stream/index.html"><div class="logo-container"><img class="rust-logo" src="../rust-logo.svg" alt="logo"></div></a><h2></h2></nav><nav class="sidebar"><a class="sidebar-logo" href="../tokio_stream/index.html"><div class="logo-container"><img class="rust-logo" src="../rust-logo.svg" alt="logo"></div></a><h2 class="location"><a href="#">StreamMap</a></h2><div class="sidebar-elems"><section><h3><a href="#implementations">Methods</a></h3><ul class="block"><li><a href="#method.capacity">capacity</a></li><li><a href="#method.clear">clear</a></li><li><a href="#method.contains_key">contains_key</a></li><li><a href="#method.insert">insert</a></li><li><a href="#method.is_empty">is_empty</a></li><li><a href="#method.iter">iter</a></li><li><a href="#method.iter_mut">iter_mut</a></li><li><a href="#method.keys">keys</a></li><li><a href="#method.len">len</a></li><li><a href="#method.new">new</a></li><li><a href="#method.remove">remove</a></li><li><a href="#method.values">values</a></li><li><a href="#method.values_mut">values_mut</a></li><li><a href="#method.with_capacity">with_capacity</a></li></ul><h3><a href="#trait-implementations">Trait Implementations</a></h3><ul class="block"><li><a href="#impl-Debug-for-StreamMap%3CK%2C%20V%3E">Debug</a></li><li><a href="#impl-Default-for-StreamMap%3CK%2C%20V%3E">Default</a></li><li><a href="#impl-Extend%3C(K%2C%20V)%3E-for-StreamMap%3CK%2C%20V%3E">Extend&lt;(K, V)&gt;</a></li><li><a href="#impl-FromIterator%3C(K%2C%20V)%3E-for-StreamMap%3CK%2C%20V%3E">FromIterator&lt;(K, V)&gt;</a></li><li><a href="#impl-Stream-for-StreamMap%3CK%2C%20V%3E">Stream</a></li></ul><h3><a href="#synthetic-implementations">Auto Trait Implementations</a></h3><ul class="block"><li><a href="#impl-RefUnwindSafe-for-StreamMap%3CK%2C%20V%3E">RefUnwindSafe</a></li><li><a href="#impl-Send-for-StreamMap%3CK%2C%20V%3E">Send</a></li><li><a href="#impl-Sync-for-StreamMap%3CK%2C%20V%3E">Sync</a></li><li><a href="#impl-Unpin-for-StreamMap%3CK%2C%20V%3E">Unpin</a></li><li><a href="#impl-UnwindSafe-for-StreamMap%3CK%2C%20V%3E">UnwindSafe</a></li></ul><h3><a href="#blanket-implementations">Blanket Implementations</a></h3><ul class="block"><li><a href="#impl-Any-for-StreamMap%3CK%2C%20V%3E">Any</a></li><li><a href="#impl-Borrow%3CT%3E-for-StreamMap%3CK%2C%20V%3E">Borrow&lt;T&gt;</a></li><li><a href="#impl-BorrowMut%3CT%3E-for-StreamMap%3CK%2C%20V%3E">BorrowMut&lt;T&gt;</a></li><li><a href="#impl-From%3CT%3E-for-StreamMap%3CK%2C%20V%3E">From&lt;T&gt;</a></li><li><a href="#impl-Into%3CU%3E-for-StreamMap%3CK%2C%20V%3E">Into&lt;U&gt;</a></li><li><a href="#impl-TryFrom%3CU%3E-for-StreamMap%3CK%2C%20V%3E">TryFrom&lt;U&gt;</a></li><li><a href="#impl-TryInto%3CU%3E-for-StreamMap%3CK%2C%20V%3E">TryInto&lt;U&gt;</a></li></ul></section><h2><a href="index.html">In tokio_stream</a></h2></div></nav><main><div class="width-limiter"><nav class="sub"><form class="search-form"><div class="search-container"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../wheel.svg"></a></div></div></form></nav><section id="main-content" class="content"><div class="main-heading"><h1 class="fqn">Struct <a href="index.html">tokio_stream</a>::<wbr><a class="struct" href="#">StreamMap</a><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../clipboard.svg" width="19" height="18" alt="Copy item path"></button></h1><span class="out-of-band"><a class="srclink" href="../src/tokio_stream/stream_map.rs.html#204-207">source</a> · <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">&#x2212;</span>]</a></span></div><div class="item-decl"><pre class="rust struct"><code>pub struct StreamMap&lt;K, V&gt; { /* private fields */ }</code></pre></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Combine many streams into one, indexing each source stream with a unique
key.</p>
<p><code>StreamMap</code> is similar to <a href="trait.StreamExt.html#method.merge"><code>StreamExt::merge</code></a> in that it combines source
streams into a single merged stream that yields values in the order that
they arrive from the source streams. However, <code>StreamMap</code> has a lot more
flexibility in usage patterns.</p>
<p><code>StreamMap</code> can:</p>
<ul>
<li>Merge an arbitrary number of streams.</li>
<li>Track which source stream the value was received from.</li>
<li>Handle inserting and removing streams from the set of managed streams at
any point during iteration.</li>
</ul>
<p>All source streams held by <code>StreamMap</code> are indexed using a key. This key is
included with the value when a source stream yields a value. The key is also
used to remove the stream from the <code>StreamMap</code> before the stream has
completed streaming.</p>
<h2 id="unpin"><a href="#unpin"><code>Unpin</code></a></h2>
<p>Because the <code>StreamMap</code> API moves streams during runtime, both streams and
keys must be <code>Unpin</code>. In order to insert a <code>!Unpin</code> stream into a
<code>StreamMap</code>, use <a href="https://docs.rs/tokio/1.0/tokio/macro.pin.html"><code>pin!</code></a> to pin the stream to the stack or <a href="std::boxed::Box::pin"><code>Box::pin</code></a> to
pin the stream in the heap.</p>
<h2 id="implementation"><a href="#implementation">Implementation</a></h2>
<p><code>StreamMap</code> is backed by a <code>Vec&lt;(K, V)&gt;</code>. There is no guarantee that this
internal implementation detail will persist in future versions, but it is
important to know the runtime implications. In general, <code>StreamMap</code> works
best with a “smallish” number of streams as all entries are scanned on
insert, remove, and polling. In cases where a large number of streams need
to be merged, it may be advisable to use tasks sending values on a shared
<a href="https://docs.rs/tokio/1.0/tokio/sync/mpsc/index.html"><code>mpsc</code></a> channel.</p>
<h2 id="notes"><a href="#notes">Notes</a></h2>
<p><code>StreamMap</code> removes finished streams automatically, without alerting the user.
In some scenarios, the caller would want to know on closed streams.
To do this, use <a href="struct.StreamNotifyClose.html"><code>StreamNotifyClose</code></a> as a wrapper to your stream.
It will return None when the stream is closed.</p>
<h2 id="examples"><a href="#examples">Examples</a></h2>
<p>Merging two streams, then remove them after receiving the first value</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio_stream::{StreamExt, StreamMap, Stream};
<span class="kw">use </span>tokio::sync::mpsc;
<span class="kw">use </span>std::pin::Pin;
<span class="attribute">#[tokio::main]
</span><span class="kw">async fn </span>main() {
<span class="kw">let </span>(tx1, <span class="kw-2">mut </span>rx1) = mpsc::channel::&lt;usize&gt;(<span class="number">10</span>);
<span class="kw">let </span>(tx2, <span class="kw-2">mut </span>rx2) = mpsc::channel::&lt;usize&gt;(<span class="number">10</span>);
<span class="comment">// Convert the channels to a `Stream`.
</span><span class="kw">let </span>rx1 = Box::pin(<span class="macro">async_stream::stream! </span>{
<span class="kw">while let </span><span class="prelude-val">Some</span>(item) = rx1.recv().<span class="kw">await </span>{
<span class="kw">yield </span>item;
}
}) <span class="kw">as </span>Pin&lt;Box&lt;<span class="kw">dyn </span>Stream&lt;Item = usize&gt; + Send&gt;&gt;;
<span class="kw">let </span>rx2 = Box::pin(<span class="macro">async_stream::stream! </span>{
<span class="kw">while let </span><span class="prelude-val">Some</span>(item) = rx2.recv().<span class="kw">await </span>{
<span class="kw">yield </span>item;
}
}) <span class="kw">as </span>Pin&lt;Box&lt;<span class="kw">dyn </span>Stream&lt;Item = usize&gt; + Send&gt;&gt;;
tokio::spawn(<span class="kw">async move </span>{
tx1.send(<span class="number">1</span>).<span class="kw">await</span>.unwrap();
<span class="comment">// This value will never be received. The send may or may not return
// `Err` depending on if the remote end closed first or not.
</span><span class="kw">let _ </span>= tx1.send(<span class="number">2</span>).<span class="kw">await</span>;
});
tokio::spawn(<span class="kw">async move </span>{
tx2.send(<span class="number">3</span>).<span class="kw">await</span>.unwrap();
<span class="kw">let _ </span>= tx2.send(<span class="number">4</span>).<span class="kw">await</span>;
});
<span class="kw">let </span><span class="kw-2">mut </span>map = StreamMap::new();
<span class="comment">// Insert both streams
</span>map.insert(<span class="string">&quot;one&quot;</span>, rx1);
map.insert(<span class="string">&quot;two&quot;</span>, rx2);
<span class="comment">// Read twice
</span><span class="kw">for _ in </span><span class="number">0</span>..<span class="number">2 </span>{
<span class="kw">let </span>(key, val) = map.next().<span class="kw">await</span>.unwrap();
<span class="kw">if </span>key == <span class="string">&quot;one&quot; </span>{
<span class="macro">assert_eq!</span>(val, <span class="number">1</span>);
} <span class="kw">else </span>{
<span class="macro">assert_eq!</span>(val, <span class="number">3</span>);
}
<span class="comment">// Remove the stream to prevent reading the next value
</span>map.remove(key);
}
}</code></pre></div>
<p>This example models a read-only client to a chat system with channels. The
client sends commands to join and leave channels. <code>StreamMap</code> is used to
manage active channel subscriptions.</p>
<p>For simplicity, messages are displayed with <code>println!</code>, but they could be
sent to the client over a socket.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio_stream::{Stream, StreamExt, StreamMap};
<span class="kw">enum </span>Command {
Join(String),
Leave(String),
}
<span class="kw">fn </span>commands() -&gt; <span class="kw">impl </span>Stream&lt;Item = Command&gt; {
<span class="comment">// Streams in user commands by parsing `stdin`.
</span>}
<span class="comment">// Join a channel, returns a stream of messages received on the channel.
</span><span class="kw">fn </span>join(channel: <span class="kw-2">&amp;</span>str) -&gt; <span class="kw">impl </span>Stream&lt;Item = String&gt; + Unpin {
<span class="comment">// left as an exercise to the reader
</span>}
<span class="attribute">#[tokio::main]
</span><span class="kw">async fn </span>main() {
<span class="kw">let </span><span class="kw-2">mut </span>channels = StreamMap::new();
<span class="comment">// Input commands (join / leave channels).
</span><span class="kw">let </span>cmds = commands();
<span class="macro">tokio::pin!</span>(cmds);
<span class="kw">loop </span>{
<span class="macro">tokio::select! </span>{
<span class="prelude-val">Some</span>(cmd) = cmds.next() =&gt; {
<span class="kw">match </span>cmd {
Command::Join(chan) =&gt; {
<span class="comment">// Join the channel and add it to the `channels`
// stream map
</span><span class="kw">let </span>msgs = join(<span class="kw-2">&amp;</span>chan);
channels.insert(chan, msgs);
}
Command::Leave(chan) =&gt; {
channels.remove(<span class="kw-2">&amp;</span>chan);
}
}
}
<span class="prelude-val">Some</span>((chan, msg)) = channels.next() =&gt; {
<span class="comment">// Received a message, display it on stdout with the channel
// it originated from.
</span><span class="macro">println!</span>(<span class="string">&quot;{}: {}&quot;</span>, chan, msg);
}
<span class="comment">// Both the `commands` stream and the `channels` stream are
// complete. There is no more work to do, so leave the loop.
</span><span class="kw">else </span>=&gt; <span class="kw">break</span>,
}
}
}</code></pre></div>
<p>Using <code>StreamNotifyClose</code> to handle closed streams with <code>StreamMap</code>.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio_stream::{StreamExt, StreamMap, StreamNotifyClose};
<span class="attribute">#[tokio::main]
</span><span class="kw">async fn </span>main() {
<span class="kw">let </span><span class="kw-2">mut </span>map = StreamMap::new();
<span class="kw">let </span>stream = StreamNotifyClose::new(tokio_stream::iter(<span class="macro">vec!</span>[<span class="number">0</span>, <span class="number">1</span>]));
<span class="kw">let </span>stream2 = StreamNotifyClose::new(tokio_stream::iter(<span class="macro">vec!</span>[<span class="number">0</span>, <span class="number">1</span>]));
map.insert(<span class="number">0</span>, stream);
map.insert(<span class="number">1</span>, stream2);
<span class="kw">while let </span><span class="prelude-val">Some</span>((key, val)) = map.next().<span class="kw">await </span>{
<span class="kw">match </span>val {
<span class="prelude-val">Some</span>(val) =&gt; <span class="macro">println!</span>(<span class="string">&quot;got {val:?} from stream {key:?}&quot;</span>),
<span class="prelude-val">None </span>=&gt; <span class="macro">println!</span>(<span class="string">&quot;stream {key:?} closed&quot;</span>),
}
}
}</code></pre></div>
</div></details><h2 id="implementations" class="small-section-header">Implementations<a href="#implementations" class="anchor"></a></h2><div id="implementations-list"><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-StreamMap%3CK%2C%20V%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/tokio_stream/stream_map.rs.html#209-512">source</a><a href="#impl-StreamMap%3CK%2C%20V%3E" class="anchor"></a><h3 class="code-header">impl&lt;K, V&gt; <a class="struct" href="struct.StreamMap.html" title="struct tokio_stream::StreamMap">StreamMap</a>&lt;K, V&gt;</h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.iter" class="method has-srclink"><a class="srclink rightside" href="../src/tokio_stream/stream_map.rs.html#229-231">source</a><h4 class="code-header">pub fn <a href="#method.iter" class="fnname">iter</a>(&amp;self) -&gt; impl Iterator&lt;Item = &amp;(K, V)&gt;</h4></section></summary><div class="docblock"><p>An iterator visiting all key-value pairs in arbitrary order.</p>
<p>The iterator element type is &amp;’a (K, V).</p>
<h5 id="examples-1"><a href="#examples-1">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio_stream::{StreamMap, pending};
<span class="kw">let </span><span class="kw-2">mut </span>map = StreamMap::new();
map.insert(<span class="string">&quot;a&quot;</span>, pending::&lt;i32&gt;());
map.insert(<span class="string">&quot;b&quot;</span>, pending());
map.insert(<span class="string">&quot;c&quot;</span>, pending());
<span class="kw">for </span>(key, stream) <span class="kw">in </span>map.iter() {
<span class="macro">println!</span>(<span class="string">&quot;({}, {:?})&quot;</span>, key, stream);
}</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.iter_mut" class="method has-srclink"><a class="srclink rightside" href="../src/tokio_stream/stream_map.rs.html#252-254">source</a><h4 class="code-header">pub fn <a href="#method.iter_mut" class="fnname">iter_mut</a>(&amp;mut self) -&gt; impl Iterator&lt;Item = &amp;mut (K, V)&gt;</h4></section></summary><div class="docblock"><p>An iterator visiting all key-value pairs mutably in arbitrary order.</p>
<p>The iterator element type is &amp;’a mut (K, V).</p>
<h5 id="examples-2"><a href="#examples-2">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio_stream::{StreamMap, pending};
<span class="kw">let </span><span class="kw-2">mut </span>map = StreamMap::new();
map.insert(<span class="string">&quot;a&quot;</span>, pending::&lt;i32&gt;());
map.insert(<span class="string">&quot;b&quot;</span>, pending());
map.insert(<span class="string">&quot;c&quot;</span>, pending());
<span class="kw">for </span>(key, stream) <span class="kw">in </span>map.iter_mut() {
<span class="macro">println!</span>(<span class="string">&quot;({}, {:?})&quot;</span>, key, stream);
}</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.new" class="method has-srclink"><a class="srclink rightside" href="../src/tokio_stream/stream_map.rs.html#268-270">source</a><h4 class="code-header">pub fn <a href="#method.new" class="fnname">new</a>() -&gt; <a class="struct" href="struct.StreamMap.html" title="struct tokio_stream::StreamMap">StreamMap</a>&lt;K, V&gt;</h4></section></summary><div class="docblock"><p>Creates an empty <code>StreamMap</code>.</p>
<p>The stream map is initially created with a capacity of <code>0</code>, so it will
not allocate until it is first inserted into.</p>
<h5 id="examples-3"><a href="#examples-3">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio_stream::{StreamMap, Pending};
<span class="kw">let </span>map: StreamMap&lt;<span class="kw-2">&amp;</span>str, Pending&lt;()&gt;&gt; = StreamMap::new();</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.with_capacity" class="method has-srclink"><a class="srclink rightside" href="../src/tokio_stream/stream_map.rs.html#284-288">source</a><h4 class="code-header">pub fn <a href="#method.with_capacity" class="fnname">with_capacity</a>(capacity: usize) -&gt; <a class="struct" href="struct.StreamMap.html" title="struct tokio_stream::StreamMap">StreamMap</a>&lt;K, V&gt;</h4></section></summary><div class="docblock"><p>Creates an empty <code>StreamMap</code> with the specified capacity.</p>
<p>The stream map will be able to hold at least <code>capacity</code> elements without
reallocating. If <code>capacity</code> is 0, the stream map will not allocate.</p>
<h5 id="examples-4"><a href="#examples-4">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio_stream::{StreamMap, Pending};
<span class="kw">let </span>map: StreamMap&lt;<span class="kw-2">&amp;</span>str, Pending&lt;()&gt;&gt; = StreamMap::with_capacity(<span class="number">10</span>);</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.keys" class="method has-srclink"><a class="srclink rightside" href="../src/tokio_stream/stream_map.rs.html#309-311">source</a><h4 class="code-header">pub fn <a href="#method.keys" class="fnname">keys</a>(&amp;self) -&gt; impl Iterator&lt;Item = &amp;K&gt;</h4></section></summary><div class="docblock"><p>Returns an iterator visiting all keys in arbitrary order.</p>
<p>The iterator element type is &amp;’a K.</p>
<h5 id="examples-5"><a href="#examples-5">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio_stream::{StreamMap, pending};
<span class="kw">let </span><span class="kw-2">mut </span>map = StreamMap::new();
map.insert(<span class="string">&quot;a&quot;</span>, pending::&lt;i32&gt;());
map.insert(<span class="string">&quot;b&quot;</span>, pending());
map.insert(<span class="string">&quot;c&quot;</span>, pending());
<span class="kw">for </span>key <span class="kw">in </span>map.keys() {
<span class="macro">println!</span>(<span class="string">&quot;{}&quot;</span>, key);
}</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.values" class="method has-srclink"><a class="srclink rightside" href="../src/tokio_stream/stream_map.rs.html#332-334">source</a><h4 class="code-header">pub fn <a href="#method.values" class="fnname">values</a>(&amp;self) -&gt; impl Iterator&lt;Item = &amp;V&gt;</h4></section></summary><div class="docblock"><p>An iterator visiting all values in arbitrary order.</p>
<p>The iterator element type is &amp;’a V.</p>
<h5 id="examples-6"><a href="#examples-6">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio_stream::{StreamMap, pending};
<span class="kw">let </span><span class="kw-2">mut </span>map = StreamMap::new();
map.insert(<span class="string">&quot;a&quot;</span>, pending::&lt;i32&gt;());
map.insert(<span class="string">&quot;b&quot;</span>, pending());
map.insert(<span class="string">&quot;c&quot;</span>, pending());
<span class="kw">for </span>stream <span class="kw">in </span>map.values() {
<span class="macro">println!</span>(<span class="string">&quot;{:?}&quot;</span>, stream);
}</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.values_mut" class="method has-srclink"><a class="srclink rightside" href="../src/tokio_stream/stream_map.rs.html#355-357">source</a><h4 class="code-header">pub fn <a href="#method.values_mut" class="fnname">values_mut</a>(&amp;mut self) -&gt; impl Iterator&lt;Item = &amp;mut V&gt;</h4></section></summary><div class="docblock"><p>An iterator visiting all values mutably in arbitrary order.</p>
<p>The iterator element type is &amp;’a mut V.</p>
<h5 id="examples-7"><a href="#examples-7">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio_stream::{StreamMap, pending};
<span class="kw">let </span><span class="kw-2">mut </span>map = StreamMap::new();
map.insert(<span class="string">&quot;a&quot;</span>, pending::&lt;i32&gt;());
map.insert(<span class="string">&quot;b&quot;</span>, pending());
map.insert(<span class="string">&quot;c&quot;</span>, pending());
<span class="kw">for </span>stream <span class="kw">in </span>map.values_mut() {
<span class="macro">println!</span>(<span class="string">&quot;{:?}&quot;</span>, stream);
}</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.capacity" class="method has-srclink"><a class="srclink rightside" href="../src/tokio_stream/stream_map.rs.html#372-374">source</a><h4 class="code-header">pub fn <a href="#method.capacity" class="fnname">capacity</a>(&amp;self) -&gt; usize</h4></section></summary><div class="docblock"><p>Returns the number of streams the map can hold without reallocating.</p>
<p>This number is a lower bound; the <code>StreamMap</code> might be able to hold
more, but is guaranteed to be able to hold at least this many.</p>
<h5 id="examples-8"><a href="#examples-8">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio_stream::{StreamMap, Pending};
<span class="kw">let </span>map: StreamMap&lt;i32, Pending&lt;()&gt;&gt; = StreamMap::with_capacity(<span class="number">100</span>);
<span class="macro">assert!</span>(map.capacity() &gt;= <span class="number">100</span>);</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.len" class="method has-srclink"><a class="srclink rightside" href="../src/tokio_stream/stream_map.rs.html#388-390">source</a><h4 class="code-header">pub fn <a href="#method.len" class="fnname">len</a>(&amp;self) -&gt; usize</h4></section></summary><div class="docblock"><p>Returns the number of streams in the map.</p>
<h5 id="examples-9"><a href="#examples-9">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio_stream::{StreamMap, pending};
<span class="kw">let </span><span class="kw-2">mut </span>a = StreamMap::new();
<span class="macro">assert_eq!</span>(a.len(), <span class="number">0</span>);
a.insert(<span class="number">1</span>, pending::&lt;i32&gt;());
<span class="macro">assert_eq!</span>(a.len(), <span class="number">1</span>);</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.is_empty" class="method has-srclink"><a class="srclink rightside" href="../src/tokio_stream/stream_map.rs.html#404-406">source</a><h4 class="code-header">pub fn <a href="#method.is_empty" class="fnname">is_empty</a>(&amp;self) -&gt; bool</h4></section></summary><div class="docblock"><p>Returns <code>true</code> if the map contains no elements.</p>
<h5 id="examples-10"><a href="#examples-10">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio_stream::{StreamMap, pending};
<span class="kw">let </span><span class="kw-2">mut </span>a = StreamMap::new();
<span class="macro">assert!</span>(a.is_empty());
a.insert(<span class="number">1</span>, pending::&lt;i32&gt;());
<span class="macro">assert!</span>(!a.is_empty());</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.clear" class="method has-srclink"><a class="srclink rightside" href="../src/tokio_stream/stream_map.rs.html#421-423">source</a><h4 class="code-header">pub fn <a href="#method.clear" class="fnname">clear</a>(&amp;mut self)</h4></section></summary><div class="docblock"><p>Clears the map, removing all key-stream pairs. Keeps the allocated
memory for reuse.</p>
<h5 id="examples-11"><a href="#examples-11">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio_stream::{StreamMap, pending};
<span class="kw">let </span><span class="kw-2">mut </span>a = StreamMap::new();
a.insert(<span class="number">1</span>, pending::&lt;i32&gt;());
a.clear();
<span class="macro">assert!</span>(a.is_empty());</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.insert" class="method has-srclink"><a class="srclink rightside" href="../src/tokio_stream/stream_map.rs.html#445-453">source</a><h4 class="code-header">pub fn <a href="#method.insert" class="fnname">insert</a>(&amp;mut self, k: K, stream: V) -&gt; Option&lt;V&gt;<span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;K: Hash + Eq,</span></h4></section></summary><div class="docblock"><p>Insert a key-stream pair into the map.</p>
<p>If the map did not have this key present, <code>None</code> is returned.</p>
<p>If the map did have this key present, the new <code>stream</code> replaces the old
one and the old stream is returned.</p>
<h5 id="examples-12"><a href="#examples-12">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio_stream::{StreamMap, pending};
<span class="kw">let </span><span class="kw-2">mut </span>map = StreamMap::new();
<span class="macro">assert!</span>(map.insert(<span class="number">37</span>, pending::&lt;i32&gt;()).is_none());
<span class="macro">assert!</span>(!map.is_empty());
map.insert(<span class="number">37</span>, pending());
<span class="macro">assert!</span>(map.insert(<span class="number">37</span>, pending()).is_some());</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.remove" class="method has-srclink"><a class="srclink rightside" href="../src/tokio_stream/stream_map.rs.html#470-482">source</a><h4 class="code-header">pub fn <a href="#method.remove" class="fnname">remove</a>&lt;Q:&nbsp;?Sized&gt;(&amp;mut self, k: &amp;Q) -&gt; Option&lt;V&gt;<span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;K: Borrow&lt;Q&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;Q: Hash + Eq,</span></h4></section></summary><div class="docblock"><p>Removes a key from the map, returning the stream at the key if the key was previously in the map.</p>
<p>The key may be any borrowed form of the map’s key type, but <code>Hash</code> and
<code>Eq</code> on the borrowed form must match those for the key type.</p>
<h5 id="examples-13"><a href="#examples-13">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio_stream::{StreamMap, pending};
<span class="kw">let </span><span class="kw-2">mut </span>map = StreamMap::new();
map.insert(<span class="number">1</span>, pending::&lt;i32&gt;());
<span class="macro">assert!</span>(map.remove(<span class="kw-2">&amp;</span><span class="number">1</span>).is_some());
<span class="macro">assert!</span>(map.remove(<span class="kw-2">&amp;</span><span class="number">1</span>).is_none());</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.contains_key" class="method has-srclink"><a class="srclink rightside" href="../src/tokio_stream/stream_map.rs.html#499-511">source</a><h4 class="code-header">pub fn <a href="#method.contains_key" class="fnname">contains_key</a>&lt;Q:&nbsp;?Sized&gt;(&amp;self, k: &amp;Q) -&gt; bool<span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;K: Borrow&lt;Q&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;Q: Hash + Eq,</span></h4></section></summary><div class="docblock"><p>Returns <code>true</code> if the map contains a stream for the specified key.</p>
<p>The key may be any borrowed form of the map’s key type, but <code>Hash</code> and
<code>Eq</code> on the borrowed form must match those for the key type.</p>
<h5 id="examples-14"><a href="#examples-14">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio_stream::{StreamMap, pending};
<span class="kw">let </span><span class="kw-2">mut </span>map = StreamMap::new();
map.insert(<span class="number">1</span>, pending::&lt;i32&gt;());
<span class="macro">assert_eq!</span>(map.contains_key(<span class="kw-2">&amp;</span><span class="number">1</span>), <span class="bool-val">true</span>);
<span class="macro">assert_eq!</span>(map.contains_key(<span class="kw-2">&amp;</span><span class="number">2</span>), <span class="bool-val">false</span>);</code></pre></div>
</div></details></div></details></div><h2 id="trait-implementations" class="small-section-header">Trait Implementations<a href="#trait-implementations" class="anchor"></a></h2><div id="trait-implementations-list"><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Debug-for-StreamMap%3CK%2C%20V%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/tokio_stream/stream_map.rs.html#203">source</a><a href="#impl-Debug-for-StreamMap%3CK%2C%20V%3E" class="anchor"></a><h3 class="code-header">impl&lt;K:&nbsp;Debug, V:&nbsp;Debug&gt; Debug for <a class="struct" href="struct.StreamMap.html" title="struct tokio_stream::StreamMap">StreamMap</a>&lt;K, V&gt;</h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.fmt" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/tokio_stream/stream_map.rs.html#203">source</a><a href="#method.fmt" class="anchor"></a><h4 class="code-header">fn <a class="fnname">fmt</a>(&amp;self, f: &amp;mut Formatter&lt;'_&gt;) -&gt; Result</h4></section></summary><div class='docblock'>Formats the value using the given formatter. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Default-for-StreamMap%3CK%2C%20V%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/tokio_stream/stream_map.rs.html#560-564">source</a><a href="#impl-Default-for-StreamMap%3CK%2C%20V%3E" class="anchor"></a><h3 class="code-header">impl&lt;K, V&gt; Default for <a class="struct" href="struct.StreamMap.html" title="struct tokio_stream::StreamMap">StreamMap</a>&lt;K, V&gt;</h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.default" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/tokio_stream/stream_map.rs.html#561-563">source</a><a href="#method.default" class="anchor"></a><h4 class="code-header">fn <a class="fnname">default</a>() -&gt; Self</h4></section></summary><div class='docblock'>Returns the “default value” for a type. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Extend%3C(K%2C%20V)%3E-for-StreamMap%3CK%2C%20V%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/tokio_stream/stream_map.rs.html#618-625">source</a><a href="#impl-Extend%3C(K%2C%20V)%3E-for-StreamMap%3CK%2C%20V%3E" class="anchor"></a><h3 class="code-header">impl&lt;K, V&gt; Extend&lt;(K, V)&gt; for <a class="struct" href="struct.StreamMap.html" title="struct tokio_stream::StreamMap">StreamMap</a>&lt;K, V&gt;</h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.extend" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/tokio_stream/stream_map.rs.html#619-624">source</a><a href="#method.extend" class="anchor"></a><h4 class="code-header">fn <a class="fnname">extend</a>&lt;T&gt;(&amp;mut self, iter: T)<span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: IntoIterator&lt;Item = (K, V)&gt;,</span></h4></section></summary><div class='docblock'>Extends a collection with the contents of an iterator. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.extend_one" class="method trait-impl has-srclink"><a href="#method.extend_one" class="anchor"></a><h4 class="code-header">fn <a class="fnname">extend_one</a>(&amp;mut self, item: A)</h4></section></summary><span class="item-info"><div class="stab unstable"><span class="emoji">🔬</span><span>This is a nightly-only experimental API. (<code>extend_one</code>)</span></div></span><div class='docblock'>Extends a collection with exactly one element.</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.extend_reserve" class="method trait-impl has-srclink"><a href="#method.extend_reserve" class="anchor"></a><h4 class="code-header">fn <a class="fnname">extend_reserve</a>(&amp;mut self, additional: usize)</h4></section></summary><span class="item-info"><div class="stab unstable"><span class="emoji">🔬</span><span>This is a nightly-only experimental API. (<code>extend_one</code>)</span></div></span><div class='docblock'>Reserves capacity in a collection for the given number of additional elements. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-FromIterator%3C(K%2C%20V)%3E-for-StreamMap%3CK%2C%20V%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/tokio_stream/stream_map.rs.html#601-616">source</a><a href="#impl-FromIterator%3C(K%2C%20V)%3E-for-StreamMap%3CK%2C%20V%3E" class="anchor"></a><h3 class="code-header">impl&lt;K, V&gt; FromIterator&lt;(K, V)&gt; for <a class="struct" href="struct.StreamMap.html" title="struct tokio_stream::StreamMap">StreamMap</a>&lt;K, V&gt;<span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;K: Hash + Eq,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.from_iter" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/tokio_stream/stream_map.rs.html#605-615">source</a><a href="#method.from_iter" class="anchor"></a><h4 class="code-header">fn <a class="fnname">from_iter</a>&lt;T:&nbsp;IntoIterator&lt;Item = (K, V)&gt;&gt;(iter: T) -&gt; Self</h4></section></summary><div class='docblock'>Creates a value from an iterator. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Stream-for-StreamMap%3CK%2C%20V%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/tokio_stream/stream_map.rs.html#566-599">source</a><a href="#impl-Stream-for-StreamMap%3CK%2C%20V%3E" class="anchor"></a><h3 class="code-header">impl&lt;K, V&gt; <a class="trait" href="../futures_core/stream/trait.Stream.html" title="trait futures_core::stream::Stream">Stream</a> for <a class="struct" href="struct.StreamMap.html" title="struct tokio_stream::StreamMap">StreamMap</a>&lt;K, V&gt;<span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;K: Clone + Unpin,<br>&nbsp;&nbsp;&nbsp;&nbsp;V: <a class="trait" href="../futures_core/stream/trait.Stream.html" title="trait futures_core::stream::Stream">Stream</a> + Unpin,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Item" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Item" class="anchor"></a><h4 class="code-header">type <a href="../futures_core/stream/trait.Stream.html#associatedtype.Item" class="associatedtype">Item</a> = (K, &lt;V as <a class="trait" href="../futures_core/stream/trait.Stream.html" title="trait futures_core::stream::Stream">Stream</a>&gt;::<a class="associatedtype" href="../futures_core/stream/trait.Stream.html#associatedtype.Item" title="type futures_core::stream::Stream::Item">Item</a>)</h4></section></summary><div class='docblock'>Values yielded by the stream.</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.poll_next" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/tokio_stream/stream_map.rs.html#573-580">source</a><a href="#method.poll_next" class="anchor"></a><h4 class="code-header">fn <a href="../futures_core/stream/trait.Stream.html#tymethod.poll_next" class="fnname">poll_next</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;self: Pin&lt;&amp;mut Self&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;cx: &amp;mut Context&lt;'_&gt;<br>) -&gt; Poll&lt;Option&lt;Self::<a class="associatedtype" href="../futures_core/stream/trait.Stream.html#associatedtype.Item" title="type futures_core::stream::Stream::Item">Item</a>&gt;&gt;</h4></section></summary><div class='docblock'>Attempt to pull out the next value of this stream, registering the
current task for wakeup if the value is not yet available, and returning
<code>None</code> if the stream is exhausted. <a href="../futures_core/stream/trait.Stream.html#tymethod.poll_next">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.size_hint" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/tokio_stream/stream_map.rs.html#582-598">source</a><a href="#method.size_hint" class="anchor"></a><h4 class="code-header">fn <a href="../futures_core/stream/trait.Stream.html#method.size_hint" class="fnname">size_hint</a>(&amp;self) -&gt; (usize, Option&lt;usize&gt;)</h4></section></summary><div class='docblock'>Returns the bounds on the remaining length of the stream. <a href="../futures_core/stream/trait.Stream.html#method.size_hint">Read more</a></div></details></div></details></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"><section id="impl-RefUnwindSafe-for-StreamMap%3CK%2C%20V%3E" class="impl has-srclink"><a href="#impl-RefUnwindSafe-for-StreamMap%3CK%2C%20V%3E" class="anchor"></a><h3 class="code-header">impl&lt;K, V&gt; RefUnwindSafe for <a class="struct" href="struct.StreamMap.html" title="struct tokio_stream::StreamMap">StreamMap</a>&lt;K, V&gt;<span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;K: RefUnwindSafe,<br>&nbsp;&nbsp;&nbsp;&nbsp;V: RefUnwindSafe,</span></h3></section><section id="impl-Send-for-StreamMap%3CK%2C%20V%3E" class="impl has-srclink"><a href="#impl-Send-for-StreamMap%3CK%2C%20V%3E" class="anchor"></a><h3 class="code-header">impl&lt;K, V&gt; Send for <a class="struct" href="struct.StreamMap.html" title="struct tokio_stream::StreamMap">StreamMap</a>&lt;K, V&gt;<span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;K: Send,<br>&nbsp;&nbsp;&nbsp;&nbsp;V: Send,</span></h3></section><section id="impl-Sync-for-StreamMap%3CK%2C%20V%3E" class="impl has-srclink"><a href="#impl-Sync-for-StreamMap%3CK%2C%20V%3E" class="anchor"></a><h3 class="code-header">impl&lt;K, V&gt; Sync for <a class="struct" href="struct.StreamMap.html" title="struct tokio_stream::StreamMap">StreamMap</a>&lt;K, V&gt;<span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;K: Sync,<br>&nbsp;&nbsp;&nbsp;&nbsp;V: Sync,</span></h3></section><section id="impl-Unpin-for-StreamMap%3CK%2C%20V%3E" class="impl has-srclink"><a href="#impl-Unpin-for-StreamMap%3CK%2C%20V%3E" class="anchor"></a><h3 class="code-header">impl&lt;K, V&gt; Unpin for <a class="struct" href="struct.StreamMap.html" title="struct tokio_stream::StreamMap">StreamMap</a>&lt;K, V&gt;<span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;K: Unpin,<br>&nbsp;&nbsp;&nbsp;&nbsp;V: Unpin,</span></h3></section><section id="impl-UnwindSafe-for-StreamMap%3CK%2C%20V%3E" class="impl has-srclink"><a href="#impl-UnwindSafe-for-StreamMap%3CK%2C%20V%3E" class="anchor"></a><h3 class="code-header">impl&lt;K, V&gt; UnwindSafe for <a class="struct" href="struct.StreamMap.html" title="struct tokio_stream::StreamMap">StreamMap</a>&lt;K, V&gt;<span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;K: UnwindSafe,<br>&nbsp;&nbsp;&nbsp;&nbsp;V: UnwindSafe,</span></h3></section></div><h2 id="blanket-implementations" class="small-section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor"></a></h2><div id="blanket-implementations-list"><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-Any-for-StreamMap%3CK%2C%20V%3E" class="impl has-srclink"><a href="#impl-Any-for-StreamMap%3CK%2C%20V%3E" class="anchor"></a><h3 class="code-header">impl&lt;T&gt; Any for T<span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: 'static + ?Sized,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.type_id" class="method trait-impl has-srclink"><a href="#method.type_id" class="anchor"></a><h4 class="code-header">fn <a class="fnname">type_id</a>(&amp;self) -&gt; TypeId</h4></section></summary><div class='docblock'>Gets the <code>TypeId</code> of <code>self</code>. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-Borrow%3CT%3E-for-StreamMap%3CK%2C%20V%3E" class="impl has-srclink"><a href="#impl-Borrow%3CT%3E-for-StreamMap%3CK%2C%20V%3E" class="anchor"></a><h3 class="code-header">impl&lt;T&gt; Borrow&lt;T&gt; for T<span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: ?Sized,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.borrow" class="method trait-impl has-srclink"><span class="since rightside" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/91522" title="Tracking issue for const_borrow">unstable</a></span><a href="#method.borrow" class="anchor"></a><h4 class="code-header">fn <a class="fnname">borrow</a>(&amp;self) -&gt; &amp;T</h4></section></summary><div class='docblock'>Immutably borrows from an owned value. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-BorrowMut%3CT%3E-for-StreamMap%3CK%2C%20V%3E" class="impl has-srclink"><a href="#impl-BorrowMut%3CT%3E-for-StreamMap%3CK%2C%20V%3E" class="anchor"></a><h3 class="code-header">impl&lt;T&gt; BorrowMut&lt;T&gt; for T<span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: ?Sized,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.borrow_mut" class="method trait-impl has-srclink"><span class="since rightside" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/91522" title="Tracking issue for const_borrow">unstable</a></span><a href="#method.borrow_mut" class="anchor"></a><h4 class="code-header">fn <a class="fnname">borrow_mut</a>(&amp;mut self) -&gt; &amp;mut T</h4></section></summary><div class='docblock'>Mutably borrows from an owned value. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-From%3CT%3E-for-StreamMap%3CK%2C%20V%3E" class="impl has-srclink"><a href="#impl-From%3CT%3E-for-StreamMap%3CK%2C%20V%3E" class="anchor"></a><h3 class="code-header">impl&lt;T&gt; From&lt;T&gt; for T</h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.from" class="method trait-impl has-srclink"><span class="since rightside" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/88674" title="Tracking issue for const_convert">unstable</a></span><a href="#method.from" class="anchor"></a><h4 class="code-header">fn <a class="fnname">from</a>(t: T) -&gt; T</h4></section></summary><div class="docblock"><p>Returns the argument unchanged.</p>
</div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-Into%3CU%3E-for-StreamMap%3CK%2C%20V%3E" class="impl has-srclink"><a href="#impl-Into%3CU%3E-for-StreamMap%3CK%2C%20V%3E" class="anchor"></a><h3 class="code-header">impl&lt;T, U&gt; Into&lt;U&gt; for T<span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;U: From&lt;T&gt;,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.into" class="method trait-impl has-srclink"><span class="since rightside" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/88674" title="Tracking issue for const_convert">unstable</a></span><a href="#method.into" class="anchor"></a><h4 class="code-header">fn <a class="fnname">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>[From]&lt;T&gt; for U</code> chooses to do.</p>
</div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-TryFrom%3CU%3E-for-StreamMap%3CK%2C%20V%3E" class="impl has-srclink"><a href="#impl-TryFrom%3CU%3E-for-StreamMap%3CK%2C%20V%3E" class="anchor"></a><h3 class="code-header">impl&lt;T, U&gt; TryFrom&lt;U&gt; for T<span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;U: Into&lt;T&gt;,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Error-1" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Error-1" class="anchor"></a><h4 class="code-header">type <a class="associatedtype">Error</a> = Infallible</h4></section></summary><div class='docblock'>The type returned in the event of a conversion error.</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.try_from" class="method trait-impl has-srclink"><span class="since rightside" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/88674" title="Tracking issue for const_convert">unstable</a></span><a href="#method.try_from" class="anchor"></a><h4 class="code-header">fn <a class="fnname">try_from</a>(value: U) -&gt; Result&lt;T, &lt;T as TryFrom&lt;U&gt;&gt;::Error&gt;</h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-TryInto%3CU%3E-for-StreamMap%3CK%2C%20V%3E" class="impl has-srclink"><a href="#impl-TryInto%3CU%3E-for-StreamMap%3CK%2C%20V%3E" class="anchor"></a><h3 class="code-header">impl&lt;T, U&gt; TryInto&lt;U&gt; for T<span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;U: TryFrom&lt;T&gt;,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Error" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Error" class="anchor"></a><h4 class="code-header">type <a class="associatedtype">Error</a> = &lt;U as TryFrom&lt;T&gt;&gt;::Error</h4></section></summary><div class='docblock'>The type returned in the event of a conversion error.</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.try_into" class="method trait-impl has-srclink"><span class="since rightside" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/88674" title="Tracking issue for const_convert">unstable</a></span><a href="#method.try_into" class="anchor"></a><h4 class="code-header">fn <a class="fnname">try_into</a>(self) -&gt; Result&lt;U, &lt;U as TryFrom&lt;T&gt;&gt;::Error&gt;</h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details></div></section></div></main><div id="rustdoc-vars" data-root-path="../" data-current-crate="tokio_stream" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.66.0-nightly (5c8bff74b 2022-10-21)" ></div></body></html>