| <!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="Caching handle for [`ArcSwapAny`][ArcSwapAny]."><meta name="keywords" content="rust, rustlang, rust-lang, Cache"><title>Cache in arc_swap::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">☰</button><a class="sidebar-logo" href="../../arc_swap/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="../../arc_swap/index.html"><div class="logo-container"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></div></a><h2 class="location"><a href="#">Cache</a></h2><div class="sidebar-elems"><section><h3><a href="#implementations">Methods</a></h3><ul class="block"><li><a href="#method.arc_swap">arc_swap</a></li><li><a href="#method.load">load</a></li><li><a href="#method.map">map</a></li><li><a href="#method.new">new</a></li></ul><h3><a href="#trait-implementations">Trait Implementations</a></h3><ul class="block"><li><a href="#impl-Access%3C%3CT%20as%20Deref%3E%3A%3ATarget%3E-for-Cache%3CA%2C%20T%3E">Access<<T as Deref>::Target></a></li><li><a href="#impl-Clone-for-Cache%3CA%2C%20T%3E">Clone</a></li><li><a href="#impl-Debug-for-Cache%3CA%2C%20T%3E">Debug</a></li><li><a href="#impl-From%3CA%3E-for-Cache%3CA%2C%20T%3E">From<A></a></li></ul><h3><a href="#synthetic-implementations">Auto Trait Implementations</a></h3><ul class="block"><li><a href="#impl-RefUnwindSafe-for-Cache%3CA%2C%20T%3E">RefUnwindSafe</a></li><li><a href="#impl-Send-for-Cache%3CA%2C%20T%3E">Send</a></li><li><a href="#impl-Sync-for-Cache%3CA%2C%20T%3E">Sync</a></li><li><a href="#impl-Unpin-for-Cache%3CA%2C%20T%3E">Unpin</a></li><li><a href="#impl-UnwindSafe-for-Cache%3CA%2C%20T%3E">UnwindSafe</a></li></ul><h3><a href="#blanket-implementations">Blanket Implementations</a></h3><ul class="block"><li><a href="#impl-Any-for-Cache%3CA%2C%20T%3E">Any</a></li><li><a href="#impl-Borrow%3CT%3E-for-Cache%3CA%2C%20T%3E">Borrow<T></a></li><li><a href="#impl-BorrowMut%3CT%3E-for-Cache%3CA%2C%20T%3E">BorrowMut<T></a></li><li><a href="#impl-From%3CT%3E-for-Cache%3CA%2C%20T%3E">From<T></a></li><li><a href="#impl-Into%3CU%3E-for-Cache%3CA%2C%20T%3E">Into<U></a></li><li><a href="#impl-ToOwned-for-Cache%3CA%2C%20T%3E">ToOwned</a></li><li><a href="#impl-TryFrom%3CU%3E-for-Cache%3CA%2C%20T%3E">TryFrom<U></a></li><li><a href="#impl-TryInto%3CU%3E-for-Cache%3CA%2C%20T%3E">TryInto<U></a></li></ul></section><h2><a href="index.html">In arc_swap::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">arc_swap</a>::<wbr><a href="index.html">cache</a>::<wbr><a class="struct" href="#">Cache</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/arc_swap/cache.rs.html#110-113">source</a> · <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span></div><div class="item-decl"><pre class="rust struct"><code>pub struct Cache<A, T> { /* private fields */ }</code></pre></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Caching handle for <a href="../struct.ArcSwapAny.html" title="ArcSwapAny"><code>ArcSwapAny</code></a>.</p> |
| <p>Instead of loading the <a href="std::sync::Arc"><code>Arc</code></a> on every request from the shared storage, this keeps |
| another copy inside itself. Upon request it only cheaply revalidates it is up to |
| date. If it is, access is significantly faster. If it is stale, the <a href="../struct.ArcSwapAny.html#method.load_full">load_full</a> is done and the |
| cache value is replaced. Under a read-heavy loads, the measured speedup are 10-25 times, |
| depending on the architecture.</p> |
| <p>There are, however, downsides:</p> |
| <ul> |
| <li>The handle needs to be kept around by the caller (usually, one per thread). This is fine if |
| there’s one global <code>ArcSwapAny</code>, but starts being tricky with eg. data structures build from |
| them.</li> |
| <li>As it keeps a copy of the <a href="std::sync::Arc">Arc</a> inside the cache, the old value may be kept alive for longer |
| period of time ‒ it is replaced by the new value on <a href="struct.Cache.html#method.load" title="Cache::load">load</a>. You may not want to |
| use this if dropping the old value in timely manner is important (possibly because of |
| releasing large amount of RAM or because of closing file handles).</li> |
| </ul> |
| <h2 id="examples"><a href="#examples">Examples</a></h2> |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::sync::Arc; |
| <span class="kw">use </span>std::sync::atomic::{AtomicBool, Ordering}; |
| |
| <span class="kw">use </span>arc_swap::{ArcSwap, Cache}; |
| |
| <span class="kw">let </span>shared = Arc::new(ArcSwap::from_pointee(<span class="number">42</span>)); |
| <span class="kw">let </span>terminate = Arc::new(AtomicBool::new(<span class="bool-val">false</span>)); |
| <span class="comment">// Start 10 worker threads... |
| </span><span class="kw">for _ in </span><span class="number">0</span>..<span class="number">10 </span>{ |
| <span class="kw">let </span><span class="kw-2">mut </span>cache = Cache::new(Arc::clone(<span class="kw-2">&</span>shared)); |
| <span class="kw">let </span>terminate = Arc::clone(<span class="kw-2">&</span>terminate); |
| std::thread::spawn(<span class="kw">move </span>|| { |
| <span class="comment">// Keep loading it like mad.. |
| </span><span class="kw">while </span>!terminate.load(Ordering::Relaxed) { |
| <span class="kw">let </span>value = cache.load(); |
| do_something(value); |
| } |
| }); |
| } |
| shared.store(Arc::new(<span class="number">12</span>));</code></pre></div> |
| <p>Another one with using a thread local storage and explicit types:</p> |
| |
| <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">static </span>CURRENT_CONFIG: Lazy<ArcSwap<Config>> = Lazy::new(|| ArcSwap::from_pointee(Config::default())); |
| |
| <span class="macro">thread_local! </span>{ |
| <span class="kw">static </span>CACHE: RefCell<Cache<<span class="kw-2">&</span><span class="lifetime">'static </span>ArcSwap<Config>, Arc<Config>>> = RefCell::new(Cache::from(CURRENT_CONFIG.deref())); |
| } |
| |
| CACHE.with(|c| { |
| <span class="comment">// * RefCell needed, because load on cache is `&mut`. |
| // * You want to operate inside the `with` ‒ cloning the Arc is comparably expensive as |
| // ArcSwap::load itself and whatever you'd save by the cache would be lost on that. |
| </span><span class="macro">println!</span>(<span class="string">"{:?}"</span>, c.borrow_mut().load()); |
| });</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-Cache%3CA%2C%20T%3E" class="impl has-srclink"><a class="srclink rightside" href="../../src/arc_swap/cache.rs.html#115-227">source</a><a href="#impl-Cache%3CA%2C%20T%3E" class="anchor"></a><h3 class="code-header">impl<A, T, S> <a class="struct" href="struct.Cache.html" title="struct arc_swap::cache::Cache">Cache</a><A, T><span class="where fmt-newline">where<br> A: Deref<Target = <a class="struct" href="../struct.ArcSwapAny.html" title="struct arc_swap::ArcSwapAny">ArcSwapAny</a><T, S>>,<br> T: <a class="trait" href="../trait.RefCnt.html" title="trait arc_swap::RefCnt">RefCnt</a>,<br> S: <a class="trait" href="../strategy/trait.Strategy.html" title="trait arc_swap::strategy::Strategy">Strategy</a><T>,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.new" class="method has-srclink"><a class="srclink rightside" href="../../src/arc_swap/cache.rs.html#130-133">source</a><h4 class="code-header">pub fn <a href="#method.new" class="fnname">new</a>(arc_swap: A) -> Self</h4></section></summary><div class="docblock"><p>Creates a new caching handle.</p> |
| <p>The parameter is something dereferencing into an <a href="../struct.ArcSwapAny.html" title="ArcSwapAny"><code>ArcSwapAny</code></a> (eg. either to <a href="../type.ArcSwap.html"><code>ArcSwap</code></a> |
| or <a href="../type.ArcSwapOption.html"><code>ArcSwapOption</code></a>). That can be <a href="../struct.ArcSwapAny.html" title="ArcSwapAny"><code>ArcSwapAny</code></a> itself, but that’s not very useful. But |
| it also can be a reference to it or <code>Arc</code>, which makes it possible to share the |
| <a href="../struct.ArcSwapAny.html" title="ArcSwapAny"><code>ArcSwapAny</code></a> with multiple caches or access it in non-cached way too.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.arc_swap" class="method has-srclink"><a class="srclink rightside" href="../../src/arc_swap/cache.rs.html#136-138">source</a><h4 class="code-header">pub fn <a href="#method.arc_swap" class="fnname">arc_swap</a>(&self) -> &A::Target</h4></section></summary><div class="docblock"><p>Gives access to the (possibly shared) cached <a href="../struct.ArcSwapAny.html" title="ArcSwapAny"><code>ArcSwapAny</code></a>.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.load" class="method has-srclink"><a class="srclink rightside" href="../../src/arc_swap/cache.rs.html#148-151">source</a><h4 class="code-header">pub fn <a href="#method.load" class="fnname">load</a>(&mut self) -> &T</h4></section></summary><div class="docblock"><p>Loads the currently held value.</p> |
| <p>This first checks if the cached value is up to date. This check is very cheap.</p> |
| <p>If it is up to date, the cached value is simply returned without additional costs. If it is |
| outdated, a load is done on the underlying shared storage. The newly loaded value is then |
| stored in the cache and returned.</p> |
| </div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.map" class="method has-srclink"><a class="srclink rightside" href="../../src/arc_swap/cache.rs.html#218-226">source</a><h4 class="code-header">pub fn <a href="#method.map" class="fnname">map</a><F, U>(self, f: F) -> <a class="struct" href="struct.MapCache.html" title="struct arc_swap::cache::MapCache">MapCache</a><A, T, F><span class="where fmt-newline">where<br> F: FnMut(&T) -> &U,</span></h4></section></summary><div class="docblock"><p>Turns this cache into a cache with a projection inside the cached value.</p> |
| <p>You’d use this in case when some part of code needs access to fresh values of <code>U</code>, however |
| a bigger structure containing <code>U</code> is provided by this cache. The possibility of giving the |
| whole structure to the part of the code falls short in terms of reusability (the part of |
| the code could be used within multiple contexts, each with a bigger different structure |
| containing <code>U</code>) and code separation (the code shouldn’t needs to know about the big |
| structure).</p> |
| <h5 id="warning"><a href="#warning">Warning</a></h5> |
| <p>As the provided <code>f</code> is called inside every <a href="trait.Access.html#tymethod.load" title="Access::load"><code>load</code></a>, this one should be |
| cheap. Most often it is expected to be just a closure taking reference of some inner field.</p> |
| <p>For the same reasons, it should not have side effects and should never panic (these will |
| not break Rust’s safety rules, but might produce behaviour you don’t expect).</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>arc_swap::ArcSwap; |
| <span class="kw">use </span>arc_swap::cache::{Access, Cache}; |
| |
| <span class="kw">struct </span>InnerCfg { |
| answer: usize, |
| } |
| |
| <span class="kw">struct </span>FullCfg { |
| inner: InnerCfg, |
| } |
| |
| <span class="kw">fn </span>use_inner<A: Access<InnerCfg>>(cache: <span class="kw-2">&mut </span>A) { |
| <span class="kw">let </span>value = cache.load(); |
| <span class="macro">println!</span>(<span class="string">"The answer is: {}"</span>, value.answer); |
| } |
| |
| <span class="kw">let </span>full_cfg = ArcSwap::from_pointee(FullCfg { |
| inner: InnerCfg { |
| answer: <span class="number">42</span>, |
| } |
| }); |
| <span class="kw">let </span>cache = Cache::new(<span class="kw-2">&</span>full_cfg); |
| use_inner(<span class="kw-2">&mut </span>cache.map(|full| <span class="kw-2">&</span>full.inner)); |
| |
| <span class="kw">let </span>inner_cfg = ArcSwap::from_pointee(InnerCfg { answer: <span class="number">24 </span>}); |
| <span class="kw">let </span><span class="kw-2">mut </span>inner_cache = Cache::new(<span class="kw-2">&</span>inner_cfg); |
| use_inner(<span class="kw-2">&mut </span>inner_cache);</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-Access%3C%3CT%20as%20Deref%3E%3A%3ATarget%3E-for-Cache%3CA%2C%20T%3E" class="impl has-srclink"><a class="srclink rightside" href="../../src/arc_swap/cache.rs.html#229-238">source</a><a href="#impl-Access%3C%3CT%20as%20Deref%3E%3A%3ATarget%3E-for-Cache%3CA%2C%20T%3E" class="anchor"></a><h3 class="code-header">impl<A, T, S> <a class="trait" href="trait.Access.html" title="trait arc_swap::cache::Access">Access</a><<T as Deref>::Target> for <a class="struct" href="struct.Cache.html" title="struct arc_swap::cache::Cache">Cache</a><A, T><span class="where fmt-newline">where<br> A: Deref<Target = <a class="struct" href="../struct.ArcSwapAny.html" title="struct arc_swap::ArcSwapAny">ArcSwapAny</a><T, S>>,<br> T: Deref<Target = <T as <a class="trait" href="../trait.RefCnt.html" title="trait arc_swap::RefCnt">RefCnt</a>>::<a class="associatedtype" href="../trait.RefCnt.html#associatedtype.Base" title="type arc_swap::RefCnt::Base">Base</a>> + <a class="trait" href="../trait.RefCnt.html" title="trait arc_swap::RefCnt">RefCnt</a>,<br> S: <a class="trait" href="../strategy/trait.Strategy.html" title="trait arc_swap::strategy::Strategy">Strategy</a><T>,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.load-1" class="method trait-impl has-srclink"><a class="srclink rightside" href="../../src/arc_swap/cache.rs.html#235-237">source</a><a href="#method.load-1" class="anchor"></a><h4 class="code-header">fn <a href="trait.Access.html#tymethod.load" class="fnname">load</a>(&mut self) -> &T::Target</h4></section></summary><div class='docblock'>Loads the value from cache. <a href="trait.Access.html#tymethod.load">Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Clone-for-Cache%3CA%2C%20T%3E" class="impl has-srclink"><a class="srclink rightside" href="../../src/arc_swap/cache.rs.html#109">source</a><a href="#impl-Clone-for-Cache%3CA%2C%20T%3E" class="anchor"></a><h3 class="code-header">impl<A: Clone, T: Clone> Clone for <a class="struct" href="struct.Cache.html" title="struct arc_swap::cache::Cache">Cache</a><A, T></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.clone" class="method trait-impl has-srclink"><a class="srclink rightside" href="../../src/arc_swap/cache.rs.html#109">source</a><a href="#method.clone" class="anchor"></a><h4 class="code-header">fn <a class="fnname">clone</a>(&self) -> <a class="struct" href="struct.Cache.html" title="struct arc_swap::cache::Cache">Cache</a><A, T></h4></section></summary><div class='docblock'>Returns a copy of the value. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.clone_from" class="method trait-impl has-srclink"><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><a href="#method.clone_from" class="anchor"></a><h4 class="code-header">const fn <a class="fnname">clone_from</a>(&mut self, source: &Self)</h4></section></summary><div class='docblock'>Performs copy-assignment from <code>source</code>. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Debug-for-Cache%3CA%2C%20T%3E" class="impl has-srclink"><a class="srclink rightside" href="../../src/arc_swap/cache.rs.html#109">source</a><a href="#impl-Debug-for-Cache%3CA%2C%20T%3E" class="anchor"></a><h3 class="code-header">impl<A: Debug, T: Debug> Debug for <a class="struct" href="struct.Cache.html" title="struct arc_swap::cache::Cache">Cache</a><A, T></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/arc_swap/cache.rs.html#109">source</a><a href="#method.fmt" class="anchor"></a><h4 class="code-header">fn <a class="fnname">fmt</a>(&self, f: &mut Formatter<'_>) -> 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-From%3CA%3E-for-Cache%3CA%2C%20T%3E" class="impl has-srclink"><a class="srclink rightside" href="../../src/arc_swap/cache.rs.html#240-249">source</a><a href="#impl-From%3CA%3E-for-Cache%3CA%2C%20T%3E" class="anchor"></a><h3 class="code-header">impl<A, T, S> From<A> for <a class="struct" href="struct.Cache.html" title="struct arc_swap::cache::Cache">Cache</a><A, T><span class="where fmt-newline">where<br> A: Deref<Target = <a class="struct" href="../struct.ArcSwapAny.html" title="struct arc_swap::ArcSwapAny">ArcSwapAny</a><T, S>>,<br> T: <a class="trait" href="../trait.RefCnt.html" title="trait arc_swap::RefCnt">RefCnt</a>,<br> S: <a class="trait" href="../strategy/trait.Strategy.html" title="trait arc_swap::strategy::Strategy">Strategy</a><T>,</span></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"><a class="srclink rightside" href="../../src/arc_swap/cache.rs.html#246-248">source</a><a href="#method.from" class="anchor"></a><h4 class="code-header">fn <a class="fnname">from</a>(arc_swap: A) -> Self</h4></section></summary><div class='docblock'>Converts to this type from the input type.</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-Cache%3CA%2C%20T%3E" class="impl has-srclink"><a href="#impl-RefUnwindSafe-for-Cache%3CA%2C%20T%3E" class="anchor"></a><h3 class="code-header">impl<A, T> RefUnwindSafe for <a class="struct" href="struct.Cache.html" title="struct arc_swap::cache::Cache">Cache</a><A, T><span class="where fmt-newline">where<br> A: RefUnwindSafe,<br> T: RefUnwindSafe,</span></h3></section><section id="impl-Send-for-Cache%3CA%2C%20T%3E" class="impl has-srclink"><a href="#impl-Send-for-Cache%3CA%2C%20T%3E" class="anchor"></a><h3 class="code-header">impl<A, T> Send for <a class="struct" href="struct.Cache.html" title="struct arc_swap::cache::Cache">Cache</a><A, T><span class="where fmt-newline">where<br> A: Send,<br> T: Send,</span></h3></section><section id="impl-Sync-for-Cache%3CA%2C%20T%3E" class="impl has-srclink"><a href="#impl-Sync-for-Cache%3CA%2C%20T%3E" class="anchor"></a><h3 class="code-header">impl<A, T> Sync for <a class="struct" href="struct.Cache.html" title="struct arc_swap::cache::Cache">Cache</a><A, T><span class="where fmt-newline">where<br> A: Sync,<br> T: Sync,</span></h3></section><section id="impl-Unpin-for-Cache%3CA%2C%20T%3E" class="impl has-srclink"><a href="#impl-Unpin-for-Cache%3CA%2C%20T%3E" class="anchor"></a><h3 class="code-header">impl<A, T> Unpin for <a class="struct" href="struct.Cache.html" title="struct arc_swap::cache::Cache">Cache</a><A, T><span class="where fmt-newline">where<br> A: Unpin,<br> T: Unpin,</span></h3></section><section id="impl-UnwindSafe-for-Cache%3CA%2C%20T%3E" class="impl has-srclink"><a href="#impl-UnwindSafe-for-Cache%3CA%2C%20T%3E" class="anchor"></a><h3 class="code-header">impl<A, T> UnwindSafe for <a class="struct" href="struct.Cache.html" title="struct arc_swap::cache::Cache">Cache</a><A, T><span class="where fmt-newline">where<br> A: UnwindSafe,<br> T: 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-Cache%3CA%2C%20T%3E" class="impl has-srclink"><a href="#impl-Any-for-Cache%3CA%2C%20T%3E" class="anchor"></a><h3 class="code-header">impl<T> Any for T<span class="where fmt-newline">where<br> 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>(&self) -> 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-Cache%3CA%2C%20T%3E" class="impl has-srclink"><a href="#impl-Borrow%3CT%3E-for-Cache%3CA%2C%20T%3E" class="anchor"></a><h3 class="code-header">impl<T> Borrow<T> for T<span class="where fmt-newline">where<br> 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>(&self) -> &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-Cache%3CA%2C%20T%3E" class="impl has-srclink"><a href="#impl-BorrowMut%3CT%3E-for-Cache%3CA%2C%20T%3E" class="anchor"></a><h3 class="code-header">impl<T> BorrowMut<T> for T<span class="where fmt-newline">where<br> 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>(&mut self) -> &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-Cache%3CA%2C%20T%3E" class="impl has-srclink"><a href="#impl-From%3CT%3E-for-Cache%3CA%2C%20T%3E" class="anchor"></a><h3 class="code-header">impl<T> From<T> for T</h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.from-1" 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-1" class="anchor"></a><h4 class="code-header">fn <a class="fnname">from</a>(t: T) -> 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-Cache%3CA%2C%20T%3E" class="impl has-srclink"><a href="#impl-Into%3CU%3E-for-Cache%3CA%2C%20T%3E" class="anchor"></a><h3 class="code-header">impl<T, U> Into<U> for T<span class="where fmt-newline">where<br> U: From<T>,</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) -> 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]<T> for U</code> chooses to do.</p> |
| </div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-ToOwned-for-Cache%3CA%2C%20T%3E" class="impl has-srclink"><a href="#impl-ToOwned-for-Cache%3CA%2C%20T%3E" class="anchor"></a><h3 class="code-header">impl<T> ToOwned for T<span class="where fmt-newline">where<br> T: Clone,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Owned" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Owned" class="anchor"></a><h4 class="code-header">type <a class="associatedtype">Owned</a> = T</h4></section></summary><div class='docblock'>The resulting type after obtaining ownership.</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.to_owned" class="method trait-impl has-srclink"><a href="#method.to_owned" class="anchor"></a><h4 class="code-header">fn <a class="fnname">to_owned</a>(&self) -> T</h4></section></summary><div class='docblock'>Creates owned data from borrowed data, usually by cloning. <a>Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.clone_into" class="method trait-impl has-srclink"><a href="#method.clone_into" class="anchor"></a><h4 class="code-header">fn <a class="fnname">clone_into</a>(&self, target: &mut T)</h4></section></summary><div class='docblock'>Uses borrowed data to replace owned data, usually by cloning. <a>Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-TryFrom%3CU%3E-for-Cache%3CA%2C%20T%3E" class="impl has-srclink"><a href="#impl-TryFrom%3CU%3E-for-Cache%3CA%2C%20T%3E" class="anchor"></a><h3 class="code-header">impl<T, U> TryFrom<U> for T<span class="where fmt-newline">where<br> U: Into<T>,</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) -> Result<T, <T as TryFrom<U>>::Error></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-Cache%3CA%2C%20T%3E" class="impl has-srclink"><a href="#impl-TryInto%3CU%3E-for-Cache%3CA%2C%20T%3E" class="anchor"></a><h3 class="code-header">impl<T, U> TryInto<U> for T<span class="where fmt-newline">where<br> U: TryFrom<T>,</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> = <U as TryFrom<T>>::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) -> Result<U, <U as TryFrom<T>>::Error></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="arc_swap" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.66.0-nightly (5c8bff74b 2022-10-21)" ></div></body></html> |