blob: 0b1de1487bd40abb2120fffca0feda6964f59ce7 [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="Drives readiness over a set of services."><meta name="keywords" content="rust, rustlang, rust-lang, ReadyCache"><title>ReadyCache in tower::ready_cache::cache - 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="../../../tower/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="../../../tower/index.html"><div class="logo-container"><img class="rust-logo" src="../../../rust-logo.svg" alt="logo"></div></a><h2 class="location"><a href="#">ReadyCache</a></h2><div class="sidebar-elems"><section><h3><a href="#implementations">Methods</a></h3><ul class="block"><li><a href="#method.call_ready">call_ready</a></li><li><a href="#method.call_ready_index">call_ready_index</a></li><li><a href="#method.check_ready">check_ready</a></li><li><a href="#method.check_ready_index">check_ready_index</a></li><li><a href="#method.evict">evict</a></li><li><a href="#method.get_ready">get_ready</a></li><li><a href="#method.get_ready_index">get_ready_index</a></li><li><a href="#method.get_ready_index_mut">get_ready_index_mut</a></li><li><a href="#method.get_ready_mut">get_ready_mut</a></li><li><a href="#method.is_empty">is_empty</a></li><li><a href="#method.len">len</a></li><li><a href="#method.pending_contains">pending_contains</a></li><li><a href="#method.pending_len">pending_len</a></li><li><a href="#method.poll_pending">poll_pending</a></li><li><a href="#method.push">push</a></li><li><a href="#method.ready_len">ready_len</a></li></ul><h3><a href="#trait-implementations">Trait Implementations</a></h3><ul class="block"><li><a href="#impl-Debug-for-ReadyCache%3CK%2C%20S%2C%20Req%3E">Debug</a></li><li><a href="#impl-Default-for-ReadyCache%3CK%2C%20S%2C%20Req%3E">Default</a></li><li><a href="#impl-Unpin-for-ReadyCache%3CK%2C%20S%2C%20Req%3E">Unpin</a></li></ul><h3><a href="#synthetic-implementations">Auto Trait Implementations</a></h3><ul class="block"><li><a href="#impl-RefUnwindSafe-for-ReadyCache%3CK%2C%20S%2C%20Req%3E">!RefUnwindSafe</a></li><li><a href="#impl-Send-for-ReadyCache%3CK%2C%20S%2C%20Req%3E">Send</a></li><li><a href="#impl-Sync-for-ReadyCache%3CK%2C%20S%2C%20Req%3E">Sync</a></li><li><a href="#impl-UnwindSafe-for-ReadyCache%3CK%2C%20S%2C%20Req%3E">!UnwindSafe</a></li></ul><h3><a href="#blanket-implementations">Blanket Implementations</a></h3><ul class="block"><li><a href="#impl-Any-for-ReadyCache%3CK%2C%20S%2C%20Req%3E">Any</a></li><li><a href="#impl-Borrow%3CT%3E-for-ReadyCache%3CK%2C%20S%2C%20Req%3E">Borrow&lt;T&gt;</a></li><li><a href="#impl-BorrowMut%3CT%3E-for-ReadyCache%3CK%2C%20S%2C%20Req%3E">BorrowMut&lt;T&gt;</a></li><li><a href="#impl-From%3CT%3E-for-ReadyCache%3CK%2C%20S%2C%20Req%3E">From&lt;T&gt;</a></li><li><a href="#impl-Instrument-for-ReadyCache%3CK%2C%20S%2C%20Req%3E">Instrument</a></li><li><a href="#impl-Into%3CU%3E-for-ReadyCache%3CK%2C%20S%2C%20Req%3E">Into&lt;U&gt;</a></li><li><a href="#impl-TryFrom%3CU%3E-for-ReadyCache%3CK%2C%20S%2C%20Req%3E">TryFrom&lt;U&gt;</a></li><li><a href="#impl-TryInto%3CU%3E-for-ReadyCache%3CK%2C%20S%2C%20Req%3E">TryInto&lt;U&gt;</a></li><li><a href="#impl-VZip%3CV%3E-for-ReadyCache%3CK%2C%20S%2C%20Req%3E">VZip&lt;V&gt;</a></li><li><a href="#impl-WithSubscriber-for-ReadyCache%3CK%2C%20S%2C%20Req%3E">WithSubscriber</a></li></ul></section><h2><a href="index.html">In tower::ready_cache::cache</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">tower</a>::<wbr><a href="../index.html">ready_cache</a>::<wbr><a href="index.html">cache</a>::<wbr><a class="struct" href="#">ReadyCache</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/tower/ready_cache/cache.rs.html#58-74">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 ReadyCache&lt;K, S, Req&gt;<span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;K: Eq + Hash,</span>{ /* private fields */ }</code></pre></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Drives readiness over a set of services.</p>
<p>The cache maintains two internal data structures:</p>
<ul>
<li>a set of <em>pending</em> services that have not yet become ready; and</li>
<li>a set of <em>ready</em> services that have previously polled ready.</li>
</ul>
<p>As each <code>S</code> typed <a href="../../trait.Service.html" title="Service"><code>Service</code></a> is added to the cache via <a href="struct.ReadyCache.html#method.push" title="ReadyCache::push"><code>ReadyCache::push</code></a>, it
is added to the <em>pending set</em>. As <a href="struct.ReadyCache.html#method.poll_pending" title="ReadyCache::poll_pending"><code>ReadyCache::poll_pending</code></a> is invoked,
pending services are polled and added to the <em>ready set</em>.</p>
<p><a href="struct.ReadyCache.html#method.call_ready" title="ReadyCache::call_ready"><code>ReadyCache::call_ready</code></a> (or <a href="struct.ReadyCache.html#method.call_ready_index" title="ReadyCache::call_ready_index"><code>ReadyCache::call_ready_index</code></a>) dispatches a
request to the specified service, but panics if the specified service is not
in the ready set. The <code>ReadyCache::check_*</code> functions can be used to ensure
that a service is ready before dispatching a request.</p>
<p>The ready set can hold services for an abitrarily long time. During this
time, the runtime may process events that invalidate that ready state (for
instance, if a keepalive detects a lost connection). In such cases, callers
should use <a href="struct.ReadyCache.html#method.check_ready" title="ReadyCache::check_ready"><code>ReadyCache::check_ready</code></a> (or <a href="struct.ReadyCache.html#method.check_ready_index" title="ReadyCache::check_ready_index"><code>ReadyCache::check_ready_index</code></a>)
immediately before dispatching a request to ensure that the service has not
become unavailable.</p>
<p>Once <code>ReadyCache::call_ready*</code> is invoked, the service is placed back into
the <em>pending</em> set to be driven to readiness again.</p>
<p>When <code>ReadyCache::check_ready*</code> returns <code>false</code>, it indicates that the
specified service is <em>not</em> ready. If an error is returned, this indicats that
the server failed and has been removed from the cache entirely.</p>
<p><a href="struct.ReadyCache.html#method.evict" title="ReadyCache::evict"><code>ReadyCache::evict</code></a> can be used to remove a service from the cache (by key),
though the service may not be dropped (if it is currently pending) until
<a href="struct.ReadyCache.html#method.poll_pending" title="ReadyCache::poll_pending"><code>ReadyCache::poll_pending</code></a> is invoked.</p>
<p>Note that the by-index accessors are provided to support use cases (like
power-of-two-choices load balancing) where the caller does not care to keep
track of each service’s key. Instead, it needs only to access <em>some</em> ready
service. In such a case, it should be noted that calls to
<a href="struct.ReadyCache.html#method.poll_pending" title="ReadyCache::poll_pending"><code>ReadyCache::poll_pending</code></a> and <a href="struct.ReadyCache.html#method.evict" title="ReadyCache::evict"><code>ReadyCache::evict</code></a> may perturb the order of
the ready set, so any cached indexes should be discarded after such a call.</p>
</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-ReadyCache%3CK%2C%20S%2C%20Req%3E" class="impl has-srclink"><a class="srclink rightside" href="../../../src/tower/ready_cache/cache.rs.html#146-220">source</a><a href="#impl-ReadyCache%3CK%2C%20S%2C%20Req%3E" class="anchor"></a><h3 class="code-header">impl&lt;K, S, Req&gt; <a class="struct" href="struct.ReadyCache.html" title="struct tower::ready_cache::cache::ReadyCache">ReadyCache</a>&lt;K, S, Req&gt;<span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;K: Eq + Hash,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.len" class="method has-srclink"><a class="srclink rightside" href="../../../src/tower/ready_cache/cache.rs.html#151-153">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 total number of services in the cache.</p>
</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/tower/ready_cache/cache.rs.html#156-158">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 whether or not there are any services in the cache.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.ready_len" class="method has-srclink"><a class="srclink rightside" href="../../../src/tower/ready_cache/cache.rs.html#161-163">source</a><h4 class="code-header">pub fn <a href="#method.ready_len" class="fnname">ready_len</a>(&amp;self) -&gt; usize</h4></section></summary><div class="docblock"><p>Returns the number of services in the ready set.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.pending_len" class="method has-srclink"><a class="srclink rightside" href="../../../src/tower/ready_cache/cache.rs.html#166-168">source</a><h4 class="code-header">pub fn <a href="#method.pending_len" class="fnname">pending_len</a>(&amp;self) -&gt; usize</h4></section></summary><div class="docblock"><p>Returns the number of services in the unready set.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.pending_contains" class="method has-srclink"><a class="srclink rightside" href="../../../src/tower/ready_cache/cache.rs.html#171-173">source</a><h4 class="code-header">pub fn <a href="#method.pending_contains" class="fnname">pending_contains</a>&lt;Q:&nbsp;Hash + <a class="trait" href="trait.Equivalent.html" title="trait tower::ready_cache::cache::Equivalent">Equivalent</a>&lt;K&gt;&gt;(&amp;self, key: &amp;Q) -&gt; bool</h4></section></summary><div class="docblock"><p>Returns true iff the given key is in the unready set.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.get_ready" class="method has-srclink"><a class="srclink rightside" href="../../../src/tower/ready_cache/cache.rs.html#176-178">source</a><h4 class="code-header">pub fn <a href="#method.get_ready" class="fnname">get_ready</a>&lt;Q:&nbsp;Hash + <a class="trait" href="trait.Equivalent.html" title="trait tower::ready_cache::cache::Equivalent">Equivalent</a>&lt;K&gt;&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self,<br>&nbsp;&nbsp;&nbsp;&nbsp;key: &amp;Q<br>) -&gt; Option&lt;(usize, &amp;K, &amp;S)&gt;</h4></section></summary><div class="docblock"><p>Obtains a reference to a service in the ready set by key.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.get_ready_mut" class="method has-srclink"><a class="srclink rightside" href="../../../src/tower/ready_cache/cache.rs.html#181-188">source</a><h4 class="code-header">pub fn <a href="#method.get_ready_mut" class="fnname">get_ready_mut</a>&lt;Q:&nbsp;Hash + <a class="trait" href="trait.Equivalent.html" title="trait tower::ready_cache::cache::Equivalent">Equivalent</a>&lt;K&gt;&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;mut self,<br>&nbsp;&nbsp;&nbsp;&nbsp;key: &amp;Q<br>) -&gt; Option&lt;(usize, &amp;K, &amp;mut S)&gt;</h4></section></summary><div class="docblock"><p>Obtains a mutable reference to a service in the ready set by key.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.get_ready_index" class="method has-srclink"><a class="srclink rightside" href="../../../src/tower/ready_cache/cache.rs.html#191-193">source</a><h4 class="code-header">pub fn <a href="#method.get_ready_index" class="fnname">get_ready_index</a>(&amp;self, idx: usize) -&gt; Option&lt;(&amp;K, &amp;S)&gt;</h4></section></summary><div class="docblock"><p>Obtains a reference to a service in the ready set by index.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.get_ready_index_mut" class="method has-srclink"><a class="srclink rightside" href="../../../src/tower/ready_cache/cache.rs.html#196-198">source</a><h4 class="code-header">pub fn <a href="#method.get_ready_index_mut" class="fnname">get_ready_index_mut</a>(&amp;mut self, idx: usize) -&gt; Option&lt;(&amp;mut K, &amp;mut S)&gt;</h4></section></summary><div class="docblock"><p>Obtains a mutable reference to a service in the ready set by index.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.evict" class="method has-srclink"><a class="srclink rightside" href="../../../src/tower/ready_cache/cache.rs.html#207-219">source</a><h4 class="code-header">pub fn <a href="#method.evict" class="fnname">evict</a>&lt;Q:&nbsp;Hash + <a class="trait" href="trait.Equivalent.html" title="trait tower::ready_cache::cache::Equivalent">Equivalent</a>&lt;K&gt;&gt;(&amp;mut self, key: &amp;Q) -&gt; bool</h4></section></summary><div class="docblock"><p>Evicts an item from the cache.</p>
<p>Returns true if a service was marked for eviction.</p>
<p>Services are dropped from the ready set immediately. Services in the
pending set are marked for cancellation, but <a href="struct.ReadyCache.html#method.poll_pending" title="ReadyCache::poll_pending"><code>ReadyCache::poll_pending</code></a>
must be called to cause the service to be dropped.</p>
</div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-ReadyCache%3CK%2C%20S%2C%20Req%3E-1" class="impl has-srclink"><a class="srclink rightside" href="../../../src/tower/ready_cache/cache.rs.html#222-399">source</a><a href="#impl-ReadyCache%3CK%2C%20S%2C%20Req%3E-1" class="anchor"></a><h3 class="code-header">impl&lt;K, S, Req&gt; <a class="struct" href="struct.ReadyCache.html" title="struct tower::ready_cache::cache::ReadyCache">ReadyCache</a>&lt;K, S, Req&gt;<span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;K: Clone + Eq + Hash,<br>&nbsp;&nbsp;&nbsp;&nbsp;S: <a class="trait" href="../../trait.Service.html" title="trait tower::Service">Service</a>&lt;Req&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;S as <a class="trait" href="../../trait.Service.html" title="trait tower::Service">Service</a>&lt;Req&gt;&gt;::<a class="associatedtype" href="../../trait.Service.html#associatedtype.Error" title="type tower::Service::Error">Error</a>: Into&lt;<a class="type" href="../../type.BoxError.html" title="type tower::BoxError">BoxError</a>&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;S::<a class="associatedtype" href="../../trait.Service.html#associatedtype.Error" title="type tower::Service::Error">Error</a>: Into&lt;<a class="type" href="../../type.BoxError.html" title="type tower::BoxError">BoxError</a>&gt;,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.push" class="method has-srclink"><a class="srclink rightside" href="../../../src/tower/ready_cache/cache.rs.html#239-242">source</a><h4 class="code-header">pub fn <a href="#method.push" class="fnname">push</a>(&amp;mut self, key: K, svc: S)</h4></section></summary><div class="docblock"><p>Pushes a new service onto the pending set.</p>
<p>The service will be promoted to the ready set as <a href="struct.ReadyCache.html#method.poll_pending"><code>poll_pending</code></a> is invoked.</p>
<p>Note that this does <strong>not</strong> remove services from the ready set. Once the
old service is used, it will be dropped instead of being added back to
the pending set; OR, when the new service becomes ready, it will replace
the prior service in the ready set.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.poll_pending" class="method has-srclink"><a class="srclink rightside" href="../../../src/tower/ready_cache/cache.rs.html#271-305">source</a><h4 class="code-header">pub fn <a href="#method.poll_pending" class="fnname">poll_pending</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;mut self,<br>&nbsp;&nbsp;&nbsp;&nbsp;cx: &amp;mut Context&lt;'_&gt;<br>) -&gt; Poll&lt;Result&lt;(), <a class="struct" href="../error/struct.Failed.html" title="struct tower::ready_cache::error::Failed">Failed</a>&lt;K&gt;&gt;&gt;</h4></section></summary><div class="docblock"><p>Polls services pending readiness, adding ready services to the ready set.</p>
<p>Returns [<code>Poll::Ready</code>] when there are no remaining unready services.
<a href="struct.ReadyCache.html#method.poll_pending"><code>poll_pending</code></a> should be called again after <a href="struct.ReadyCache.html#method.push"><code>push</code></a> or
<a href="struct.ReadyCache.html#method.call_ready_index"><code>call_ready_index</code></a> are invoked.</p>
<p>Failures indicate that an individual pending service failed to become
ready (and has been removed from the cache). In such a case,
<a href="struct.ReadyCache.html#method.poll_pending"><code>poll_pending</code></a> should typically be called again to continue driving
pending services to readiness.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.check_ready" class="method has-srclink"><a class="srclink rightside" href="../../../src/tower/ready_cache/cache.rs.html#311-320">source</a><h4 class="code-header">pub fn <a href="#method.check_ready" class="fnname">check_ready</a>&lt;Q:&nbsp;Hash + <a class="trait" href="trait.Equivalent.html" title="trait tower::ready_cache::cache::Equivalent">Equivalent</a>&lt;K&gt;&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;mut self,<br>&nbsp;&nbsp;&nbsp;&nbsp;cx: &amp;mut Context&lt;'_&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;key: &amp;Q<br>) -&gt; Result&lt;bool, <a class="struct" href="../error/struct.Failed.html" title="struct tower::ready_cache::error::Failed">Failed</a>&lt;K&gt;&gt;</h4></section></summary><div class="docblock"><p>Checks whether the referenced endpoint is ready.</p>
<p>Returns true if the endpoint is ready and false if it is not. An error is
returned if the endpoint fails.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.check_ready_index" class="method has-srclink"><a class="srclink rightside" href="../../../src/tower/ready_cache/cache.rs.html#328-363">source</a><h4 class="code-header">pub fn <a href="#method.check_ready_index" class="fnname">check_ready_index</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;mut self,<br>&nbsp;&nbsp;&nbsp;&nbsp;cx: &amp;mut Context&lt;'_&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;index: usize<br>) -&gt; Result&lt;bool, <a class="struct" href="../error/struct.Failed.html" title="struct tower::ready_cache::error::Failed">Failed</a>&lt;K&gt;&gt;</h4></section></summary><div class="docblock"><p>Checks whether the referenced endpoint is ready.</p>
<p>If the service is no longer ready, it is moved back into the pending set
and <code>false</code> is returned.</p>
<p>If the service errors, it is removed and dropped and the error is returned.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.call_ready" class="method has-srclink"><a class="srclink rightside" href="../../../src/tower/ready_cache/cache.rs.html#370-376">source</a><h4 class="code-header">pub fn <a href="#method.call_ready" class="fnname">call_ready</a>&lt;Q:&nbsp;Hash + <a class="trait" href="trait.Equivalent.html" title="trait tower::ready_cache::cache::Equivalent">Equivalent</a>&lt;K&gt;&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;mut self,<br>&nbsp;&nbsp;&nbsp;&nbsp;key: &amp;Q,<br>&nbsp;&nbsp;&nbsp;&nbsp;req: Req<br>) -&gt; S::<a class="associatedtype" href="../../trait.Service.html#associatedtype.Future" title="type tower::Service::Future">Future</a></h4></section></summary><div class="docblock"><p>Calls a ready service by key.</p>
<h5 id="panics"><a href="#panics">Panics</a></h5>
<p>If the specified key does not exist in the ready</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.call_ready_index" class="method has-srclink"><a class="srclink rightside" href="../../../src/tower/ready_cache/cache.rs.html#383-398">source</a><h4 class="code-header">pub fn <a href="#method.call_ready_index" class="fnname">call_ready_index</a>(&amp;mut self, index: usize, req: Req) -&gt; S::<a class="associatedtype" href="../../trait.Service.html#associatedtype.Future" title="type tower::Service::Future">Future</a></h4></section></summary><div class="docblock"><p>Calls a ready service by index.</p>
<h5 id="panics-1"><a href="#panics-1">Panics</a></h5>
<p>If the specified index is out of range.</p>
</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-ReadyCache%3CK%2C%20S%2C%20Req%3E" class="impl has-srclink"><a class="srclink rightside" href="../../../src/tower/ready_cache/cache.rs.html#127-144">source</a><a href="#impl-Debug-for-ReadyCache%3CK%2C%20S%2C%20Req%3E" class="anchor"></a><h3 class="code-header">impl&lt;K, S, Req&gt; Debug for <a class="struct" href="struct.ReadyCache.html" title="struct tower::ready_cache::cache::ReadyCache">ReadyCache</a>&lt;K, S, Req&gt;<span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;K: Debug + Eq + Hash,<br>&nbsp;&nbsp;&nbsp;&nbsp;S: Debug,</span></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/tower/ready_cache/cache.rs.html#132-143">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-ReadyCache%3CK%2C%20S%2C%20Req%3E" class="impl has-srclink"><a class="srclink rightside" href="../../../src/tower/ready_cache/cache.rs.html#113-125">source</a><a href="#impl-Default-for-ReadyCache%3CK%2C%20S%2C%20Req%3E" class="anchor"></a><h3 class="code-header">impl&lt;K, S, Req&gt; Default for <a class="struct" href="struct.ReadyCache.html" title="struct tower::ready_cache::cache::ReadyCache">ReadyCache</a>&lt;K, S, Req&gt;<span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;K: Eq + Hash,<br>&nbsp;&nbsp;&nbsp;&nbsp;S: <a class="trait" href="../../trait.Service.html" title="trait tower::Service">Service</a>&lt;Req&gt;,</span></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/tower/ready_cache/cache.rs.html#118-124">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><section id="impl-Unpin-for-ReadyCache%3CK%2C%20S%2C%20Req%3E" class="impl has-srclink"><a class="srclink rightside" href="../../../src/tower/ready_cache/cache.rs.html#77">source</a><a href="#impl-Unpin-for-ReadyCache%3CK%2C%20S%2C%20Req%3E" class="anchor"></a><h3 class="code-header">impl&lt;S, K:&nbsp;Eq + Hash, Req&gt; Unpin for <a class="struct" href="struct.ReadyCache.html" title="struct tower::ready_cache::cache::ReadyCache">ReadyCache</a>&lt;K, S, Req&gt;</h3></section></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-ReadyCache%3CK%2C%20S%2C%20Req%3E" class="impl has-srclink"><a href="#impl-RefUnwindSafe-for-ReadyCache%3CK%2C%20S%2C%20Req%3E" class="anchor"></a><h3 class="code-header">impl&lt;K, S, Req&gt; !RefUnwindSafe for <a class="struct" href="struct.ReadyCache.html" title="struct tower::ready_cache::cache::ReadyCache">ReadyCache</a>&lt;K, S, Req&gt;</h3></section><section id="impl-Send-for-ReadyCache%3CK%2C%20S%2C%20Req%3E" class="impl has-srclink"><a href="#impl-Send-for-ReadyCache%3CK%2C%20S%2C%20Req%3E" class="anchor"></a><h3 class="code-header">impl&lt;K, S, Req&gt; Send for <a class="struct" href="struct.ReadyCache.html" title="struct tower::ready_cache::cache::ReadyCache">ReadyCache</a>&lt;K, S, Req&gt;<span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;K: Send,<br>&nbsp;&nbsp;&nbsp;&nbsp;Req: Send,<br>&nbsp;&nbsp;&nbsp;&nbsp;S: Send,</span></h3></section><section id="impl-Sync-for-ReadyCache%3CK%2C%20S%2C%20Req%3E" class="impl has-srclink"><a href="#impl-Sync-for-ReadyCache%3CK%2C%20S%2C%20Req%3E" class="anchor"></a><h3 class="code-header">impl&lt;K, S, Req&gt; Sync for <a class="struct" href="struct.ReadyCache.html" title="struct tower::ready_cache::cache::ReadyCache">ReadyCache</a>&lt;K, S, Req&gt;<span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;K: Sync,<br>&nbsp;&nbsp;&nbsp;&nbsp;Req: Sync,<br>&nbsp;&nbsp;&nbsp;&nbsp;S: Sync,</span></h3></section><section id="impl-UnwindSafe-for-ReadyCache%3CK%2C%20S%2C%20Req%3E" class="impl has-srclink"><a href="#impl-UnwindSafe-for-ReadyCache%3CK%2C%20S%2C%20Req%3E" class="anchor"></a><h3 class="code-header">impl&lt;K, S, Req&gt; !UnwindSafe for <a class="struct" href="struct.ReadyCache.html" title="struct tower::ready_cache::cache::ReadyCache">ReadyCache</a>&lt;K, S, Req&gt;</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-ReadyCache%3CK%2C%20S%2C%20Req%3E" class="impl has-srclink"><a href="#impl-Any-for-ReadyCache%3CK%2C%20S%2C%20Req%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-ReadyCache%3CK%2C%20S%2C%20Req%3E" class="impl has-srclink"><a href="#impl-Borrow%3CT%3E-for-ReadyCache%3CK%2C%20S%2C%20Req%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-ReadyCache%3CK%2C%20S%2C%20Req%3E" class="impl has-srclink"><a href="#impl-BorrowMut%3CT%3E-for-ReadyCache%3CK%2C%20S%2C%20Req%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-ReadyCache%3CK%2C%20S%2C%20Req%3E" class="impl has-srclink"><a href="#impl-From%3CT%3E-for-ReadyCache%3CK%2C%20S%2C%20Req%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-Instrument-for-ReadyCache%3CK%2C%20S%2C%20Req%3E" class="impl has-srclink"><a class="srclink rightside" href="../../../src/tracing/instrument.rs.html#276">source</a><a href="#impl-Instrument-for-ReadyCache%3CK%2C%20S%2C%20Req%3E" class="anchor"></a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="../../../tracing/instrument/trait.Instrument.html" title="trait tracing::instrument::Instrument">Instrument</a> for T</h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.instrument" class="method trait-impl has-srclink"><a class="srclink rightside" href="../../../src/tracing/instrument.rs.html#82">source</a><a href="#method.instrument" class="anchor"></a><h4 class="code-header">fn <a href="../../../tracing/instrument/trait.Instrument.html#method.instrument" class="fnname">instrument</a>(self, span: <a class="struct" href="../../../tracing/span/struct.Span.html" title="struct tracing::span::Span">Span</a>) -&gt; <a class="struct" href="../../../tracing/instrument/struct.Instrumented.html" title="struct tracing::instrument::Instrumented">Instrumented</a>&lt;Self&gt;</h4></section></summary><div class='docblock'>Instruments this type with the provided <a href="../../../tracing/span/struct.Span.html" title="Span"><code>Span</code></a>, returning an
<code>Instrumented</code> wrapper. <a href="../../../tracing/instrument/trait.Instrument.html#method.instrument">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.in_current_span" class="method trait-impl has-srclink"><a class="srclink rightside" href="../../../src/tracing/instrument.rs.html#121">source</a><a href="#method.in_current_span" class="anchor"></a><h4 class="code-header">fn <a href="../../../tracing/instrument/trait.Instrument.html#method.in_current_span" class="fnname">in_current_span</a>(self) -&gt; <a class="struct" href="../../../tracing/instrument/struct.Instrumented.html" title="struct tracing::instrument::Instrumented">Instrumented</a>&lt;Self&gt;</h4></section></summary><div class='docblock'>Instruments this type with the <a href="../../../tracing/span/struct.Span.html#method.current">current</a> <a href="../../../tracing/span/struct.Span.html"><code>Span</code></a>, returning an
<code>Instrumented</code> wrapper. <a href="../../../tracing/instrument/trait.Instrument.html#method.in_current_span">Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-Into%3CU%3E-for-ReadyCache%3CK%2C%20S%2C%20Req%3E" class="impl has-srclink"><a href="#impl-Into%3CU%3E-for-ReadyCache%3CK%2C%20S%2C%20Req%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-ReadyCache%3CK%2C%20S%2C%20Req%3E" class="impl has-srclink"><a href="#impl-TryFrom%3CU%3E-for-ReadyCache%3CK%2C%20S%2C%20Req%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-ReadyCache%3CK%2C%20S%2C%20Req%3E" class="impl has-srclink"><a href="#impl-TryInto%3CU%3E-for-ReadyCache%3CK%2C%20S%2C%20Req%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><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-VZip%3CV%3E-for-ReadyCache%3CK%2C%20S%2C%20Req%3E" class="impl has-srclink"><a class="srclink rightside" href="../../../src/ppv_lite86/types.rs.html#221">source</a><a href="#impl-VZip%3CV%3E-for-ReadyCache%3CK%2C%20S%2C%20Req%3E" class="anchor"></a><h3 class="code-header">impl&lt;V, T&gt; <a class="trait" href="../../../ppv_lite86/types/trait.VZip.html" title="trait ppv_lite86::types::VZip">VZip</a>&lt;V&gt; for T<span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;V: <a class="trait" href="../../../ppv_lite86/types/trait.MultiLane.html" title="trait ppv_lite86::types::MultiLane">MultiLane</a>&lt;T&gt;,</span></h3></section></summary><div class="impl-items"><section id="method.vzip" class="method trait-impl has-srclink"><a class="srclink rightside" href="../../../src/ppv_lite86/types.rs.html#226">source</a><a href="#method.vzip" class="anchor"></a><h4 class="code-header">fn <a href="../../../ppv_lite86/types/trait.VZip.html#tymethod.vzip" class="fnname">vzip</a>(self) -&gt; V</h4></section></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-WithSubscriber-for-ReadyCache%3CK%2C%20S%2C%20Req%3E" class="impl has-srclink"><a class="srclink rightside" href="../../../src/tracing/instrument.rs.html#334">source</a><a href="#impl-WithSubscriber-for-ReadyCache%3CK%2C%20S%2C%20Req%3E" class="anchor"></a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="../../../tracing/instrument/trait.WithSubscriber.html" title="trait tracing::instrument::WithSubscriber">WithSubscriber</a> for T</h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.with_subscriber" class="method trait-impl has-srclink"><a class="srclink rightside" href="../../../src/tracing/instrument.rs.html#169-171">source</a><a href="#method.with_subscriber" class="anchor"></a><h4 class="code-header">fn <a href="../../../tracing/instrument/trait.WithSubscriber.html#method.with_subscriber" class="fnname">with_subscriber</a>&lt;S&gt;(self, subscriber: S) -&gt; <a class="struct" href="../../../tracing/instrument/struct.WithDispatch.html" title="struct tracing::instrument::WithDispatch">WithDispatch</a>&lt;Self&gt;<span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;S: Into&lt;<a class="struct" href="../../../tracing_core/dispatcher/struct.Dispatch.html" title="struct tracing_core::dispatcher::Dispatch">Dispatch</a>&gt;,</span></h4></section></summary><div class='docblock'>Attaches the provided <a href="../../../tracing_core/subscriber/trait.Subscriber.html"><code>Subscriber</code></a> to this type, returning a
<a href="../../../tracing/instrument/struct.WithDispatch.html" title="WithDispatch"><code>WithDispatch</code></a> wrapper. <a href="../../../tracing/instrument/trait.WithSubscriber.html#method.with_subscriber">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.with_current_subscriber" class="method trait-impl has-srclink"><a class="srclink rightside" href="../../../src/tracing/instrument.rs.html#221">source</a><a href="#method.with_current_subscriber" class="anchor"></a><h4 class="code-header">fn <a href="../../../tracing/instrument/trait.WithSubscriber.html#method.with_current_subscriber" class="fnname">with_current_subscriber</a>(self) -&gt; <a class="struct" href="../../../tracing/instrument/struct.WithDispatch.html" title="struct tracing::instrument::WithDispatch">WithDispatch</a>&lt;Self&gt;</h4></section></summary><div class='docblock'>Attaches the current <a href="../../../tracing/dispatcher/index.html#setting-the-default-subscriber">default</a> <a href="../../../tracing_core/subscriber/trait.Subscriber.html"><code>Subscriber</code></a> to this type, returning a
<a href="../../../tracing/instrument/struct.WithDispatch.html" title="WithDispatch"><code>WithDispatch</code></a> wrapper. <a href="../../../tracing/instrument/trait.WithSubscriber.html#method.with_current_subscriber">Read more</a></div></details></div></details></div></section></div></main><div id="rustdoc-vars" data-root-path="../../../" data-current-crate="tower" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.66.0-nightly (5c8bff74b 2022-10-21)" ></div></body></html>