Files
greptimedb/object_store/layers/mock/trait.Layer.html
2026-03-13 04:38:03 +00:00

82 lines
21 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!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="Layer is used to intercept the operations on the underlying storage."><title>Layer in object_store::layers::mock - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../../static.files/rustdoc-e56847b5.css"><meta name="rustdoc-vars" data-root-path="../../../" data-static-root-path="../../../static.files/" data-current-crate="object_store" data-themes="" data-resource-suffix="" data-rustdoc-version="1.92.0-nightly (fa3155a64 2025-09-30)" data-channel="nightly" data-search-js="search-e256b49e.js" data-stringdex-js="stringdex-828709d0.js" data-settings-js="settings-c38705f0.js" ><script src="../../../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../../static.files/main-ce535bd0.js"></script><noscript><link rel="stylesheet" href="../../../static.files/noscript-263c88ec.css"></noscript><link rel="alternate icon" type="image/png" href="../../../static.files/favicon-32x32-eab170b8.png"><link rel="icon" type="image/svg+xml" href="../../../static.files/favicon-044be391.svg"></head><body class="rustdoc trait"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">Layer</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../../object_store/index.html">object_<wbr>store</a><span class="version">1.0.0-rc.2</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Layer</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#notes" title="Notes">Notes</a><ul><li><a href="#inner" title="Inner">Inner</a></li></ul></li><li><a href="#examples" title="Examples">Examples</a></li></ul><h3><a href="#required-associated-types">Required Associated Types</a></h3><ul class="block"><li><a href="#associatedtype.LayeredAccess" title="LayeredAccess">LayeredAccess</a></li></ul><h3><a href="#required-methods">Required Methods</a></h3><ul class="block"><li><a href="#tymethod.layer" title="layer">layer</a></li></ul><h3><a href="#implementors">Implementors</a></h3></section><div id="rustdoc-modnav"><h2><a href="index.html">In object_<wbr>store::<wbr>layers::<wbr>mock</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../../index.html">object_store</a>::<wbr><a href="../index.html">layers</a>::<wbr><a href="index.html">mock</a></div><h1>Trait <span class="trait">Layer</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"></span></div><pre class="rust item-decl"><code>pub trait Layer&lt;A&gt;<div class="where">where
A: <a class="trait" href="../../trait.Access.html" title="trait object_store::Access">Access</a>,</div>{
type <a href="#associatedtype.LayeredAccess" class="associatedtype">LayeredAccess</a>: <a class="trait" href="../../trait.Access.html" title="trait object_store::Access">Access</a>;
// Required method
fn <a href="#tymethod.layer" class="fn">layer</a>(&amp;self, inner: A) -&gt; Self::<a class="associatedtype" href="trait.Layer.html#associatedtype.LayeredAccess" title="type object_store::layers::mock::Layer::LayeredAccess">LayeredAccess</a>;
}</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Layer is used to intercept the operations on the underlying storage.</p>
<p>Struct that implement this trait must accept input <code>Arc&lt;dyn Accessor&gt;</code> as inner,
and returns a new <code>Arc&lt;dyn Accessor&gt;</code> as output.</p>
<p>All functions in <code>Accessor</code> requires <code>&amp;self</code>, so its implementers responsibility
to maintain the internal mutability. Please also keep in mind that <code>Accessor</code>
requires <code>Send</code> and <code>Sync</code>.</p>
<h2 id="notes"><a class="doc-anchor" href="#notes">§</a>Notes</h2><h3 id="inner"><a class="doc-anchor" href="#inner">§</a>Inner</h3>
<p>Its required to implement <code>fn inner() -&gt; Option&lt;Arc&lt;dyn Accessor&gt;&gt;</code> for layers accessors.</p>
<p>By implement this method, all API calls will be forwarded to inner accessor instead.</p>
<h2 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h2>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::sync::Arc;
<span class="kw">use </span>opendal::raw::<span class="kw-2">*</span>;
<span class="kw">use </span>opendal::<span class="kw-2">*</span>;
<span class="doccomment">/// Implement the real accessor logic here.
</span><span class="attr">#[derive(Debug)]
</span><span class="kw">struct </span>TraceAccessor&lt;A: Access&gt; {
inner: A,
}
<span class="kw">impl</span>&lt;A: Access&gt; LayeredAccess <span class="kw">for </span>TraceAccessor&lt;A&gt; {
<span class="kw">type </span>Inner = A;
<span class="kw">type </span>Reader = A::Reader;
<span class="kw">type </span>Writer = A::Writer;
<span class="kw">type </span>Lister = A::Lister;
<span class="kw">type </span>Deleter = A::Deleter;
<span class="kw">fn </span>inner(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; <span class="kw-2">&amp;</span><span class="self">Self</span>::Inner {
<span class="kw-2">&amp;</span><span class="self">self</span>.inner
}
<span class="kw">async fn </span>read(<span class="kw-2">&amp;</span><span class="self">self</span>, path: <span class="kw-2">&amp;</span>str, args: OpRead) -&gt; <span class="prelude-ty">Result</span>&lt;(RpRead, <span class="self">Self</span>::Reader)&gt; {
<span class="self">self</span>.inner.read(path, args).<span class="kw">await
</span>}
<span class="kw">async fn </span>write(<span class="kw-2">&amp;</span><span class="self">self</span>, path: <span class="kw-2">&amp;</span>str, args: OpWrite) -&gt; <span class="prelude-ty">Result</span>&lt;(RpWrite, <span class="self">Self</span>::Writer)&gt; {
<span class="self">self</span>.inner.write(path, args).<span class="kw">await
</span>}
<span class="kw">async fn </span>list(<span class="kw-2">&amp;</span><span class="self">self</span>, path: <span class="kw-2">&amp;</span>str, args: OpList) -&gt; <span class="prelude-ty">Result</span>&lt;(RpList, <span class="self">Self</span>::Lister)&gt; {
<span class="self">self</span>.inner.list(path, args).<span class="kw">await
</span>}
<span class="kw">async fn </span>delete(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; <span class="prelude-ty">Result</span>&lt;(RpDelete, <span class="self">Self</span>::Deleter)&gt; {
<span class="self">self</span>.inner.delete().<span class="kw">await
</span>}
}
<span class="doccomment">/// The public struct that exposed to users.
///
/// Will be used like `op.layer(TraceLayer)`
</span><span class="kw">struct </span>TraceLayer;
<span class="kw">impl</span>&lt;A: Access&gt; Layer&lt;A&gt; <span class="kw">for </span>TraceLayer {
<span class="kw">type </span>LayeredAccess = TraceAccessor&lt;A&gt;;
<span class="kw">fn </span>layer(<span class="kw-2">&amp;</span><span class="self">self</span>, inner: A) -&gt; <span class="self">Self</span>::LayeredAccess {
TraceAccessor { inner }
}
}</code></pre></div></div></details><h2 id="required-associated-types" class="section-header">Required Associated Types<a href="#required-associated-types" class="anchor">§</a></h2><div class="methods"><details class="toggle" open><summary><section id="associatedtype.LayeredAccess" class="method"><h4 class="code-header">type <a href="#associatedtype.LayeredAccess" class="associatedtype">LayeredAccess</a>: <a class="trait" href="../../trait.Access.html" title="trait object_store::Access">Access</a></h4></section></summary><div class="docblock"><p>The layered accessor that returned by this layer.</p>
</div></details></div><h2 id="required-methods" class="section-header">Required Methods<a href="#required-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="tymethod.layer" class="method"><h4 class="code-header">fn <a href="#tymethod.layer" class="fn">layer</a>(&amp;self, inner: A) -&gt; Self::<a class="associatedtype" href="trait.Layer.html#associatedtype.LayeredAccess" title="type object_store::layers::mock::Layer::LayeredAccess">LayeredAccess</a></h4></section></summary><div class="docblock"><p>Intercept the operations on the underlying storage.</p>
</div></details></div><h2 id="implementors" class="section-header">Implementors<a href="#implementors" class="anchor">§</a></h2><div id="implementors-list"><details class="toggle implementors-toggle"><summary><section id="impl-Layer%3CA%3E-for-CapabilityCheckLayer" class="impl"><a href="#impl-Layer%3CA%3E-for-CapabilityCheckLayer" class="anchor">§</a><h3 class="code-header">impl&lt;A&gt; <a class="trait" href="trait.Layer.html" title="trait object_store::layers::mock::Layer">Layer</a>&lt;A&gt; for <a class="struct" href="../struct.CapabilityCheckLayer.html" title="struct object_store::layers::CapabilityCheckLayer">CapabilityCheckLayer</a><div class="where">where
A: <a class="trait" href="../../trait.Access.html" title="trait object_store::Access">Access</a>,</div></h3></section></summary><div class="impl-items"><section id="associatedtype.LayeredAccess-1" class="associatedtype trait-impl"><a href="#associatedtype.LayeredAccess-1" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.LayeredAccess" class="associatedtype">LayeredAccess</a> = CapabilityAccessor&lt;A&gt;</h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Layer%3CA%3E-for-ConcurrentLimitLayer" class="impl"><a href="#impl-Layer%3CA%3E-for-ConcurrentLimitLayer" class="anchor">§</a><h3 class="code-header">impl&lt;A&gt; <a class="trait" href="trait.Layer.html" title="trait object_store::layers::mock::Layer">Layer</a>&lt;A&gt; for <a class="struct" href="../struct.ConcurrentLimitLayer.html" title="struct object_store::layers::ConcurrentLimitLayer">ConcurrentLimitLayer</a><div class="where">where
A: <a class="trait" href="../../trait.Access.html" title="trait object_store::Access">Access</a>,</div></h3></section></summary><div class="impl-items"><section id="associatedtype.LayeredAccess-2" class="associatedtype trait-impl"><a href="#associatedtype.LayeredAccess-2" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.LayeredAccess" class="associatedtype">LayeredAccess</a> = ConcurrentLimitAccessor&lt;A&gt;</h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Layer%3CA%3E-for-HttpClientLayer" class="impl"><a href="#impl-Layer%3CA%3E-for-HttpClientLayer" class="anchor">§</a><h3 class="code-header">impl&lt;A&gt; <a class="trait" href="trait.Layer.html" title="trait object_store::layers::mock::Layer">Layer</a>&lt;A&gt; for <a class="struct" href="../struct.HttpClientLayer.html" title="struct object_store::layers::HttpClientLayer">HttpClientLayer</a><div class="where">where
A: <a class="trait" href="../../trait.Access.html" title="trait object_store::Access">Access</a>,</div></h3></section></summary><div class="impl-items"><section id="associatedtype.LayeredAccess-3" class="associatedtype trait-impl"><a href="#associatedtype.LayeredAccess-3" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.LayeredAccess" class="associatedtype">LayeredAccess</a> = HttpClientAccessor&lt;A&gt;</h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Layer%3CA%3E-for-ImmutableIndexLayer" class="impl"><a href="#impl-Layer%3CA%3E-for-ImmutableIndexLayer" class="anchor">§</a><h3 class="code-header">impl&lt;A&gt; <a class="trait" href="trait.Layer.html" title="trait object_store::layers::mock::Layer">Layer</a>&lt;A&gt; for <a class="struct" href="../struct.ImmutableIndexLayer.html" title="struct object_store::layers::ImmutableIndexLayer">ImmutableIndexLayer</a><div class="where">where
A: <a class="trait" href="../../trait.Access.html" title="trait object_store::Access">Access</a>,</div></h3></section></summary><div class="impl-items"><section id="associatedtype.LayeredAccess-4" class="associatedtype trait-impl"><a href="#associatedtype.LayeredAccess-4" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.LayeredAccess" class="associatedtype">LayeredAccess</a> = ImmutableIndexAccessor&lt;A&gt;</h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Layer%3CA%3E-for-PrometheusLayer" class="impl"><a href="#impl-Layer%3CA%3E-for-PrometheusLayer" class="anchor">§</a><h3 class="code-header">impl&lt;A&gt; <a class="trait" href="trait.Layer.html" title="trait object_store::layers::mock::Layer">Layer</a>&lt;A&gt; for <a class="struct" href="../struct.PrometheusLayer.html" title="struct object_store::layers::PrometheusLayer">PrometheusLayer</a><div class="where">where
A: <a class="trait" href="../../trait.Access.html" title="trait object_store::Access">Access</a>,</div></h3></section></summary><div class="impl-items"><section id="associatedtype.LayeredAccess-5" class="associatedtype trait-impl"><a href="#associatedtype.LayeredAccess-5" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.LayeredAccess" class="associatedtype">LayeredAccess</a> = <a class="struct" href="../observe/struct.MetricsAccessor.html" title="struct object_store::layers::observe::MetricsAccessor">MetricsAccessor</a>&lt;A, PrometheusInterceptor&gt;</h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Layer%3CA%3E-for-TimeoutLayer" class="impl"><a href="#impl-Layer%3CA%3E-for-TimeoutLayer" class="anchor">§</a><h3 class="code-header">impl&lt;A&gt; <a class="trait" href="trait.Layer.html" title="trait object_store::layers::mock::Layer">Layer</a>&lt;A&gt; for <a class="struct" href="../struct.TimeoutLayer.html" title="struct object_store::layers::TimeoutLayer">TimeoutLayer</a><div class="where">where
A: <a class="trait" href="../../trait.Access.html" title="trait object_store::Access">Access</a>,</div></h3></section></summary><div class="impl-items"><section id="associatedtype.LayeredAccess-6" class="associatedtype trait-impl"><a href="#associatedtype.LayeredAccess-6" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.LayeredAccess" class="associatedtype">LayeredAccess</a> = TimeoutAccessor&lt;A&gt;</h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Layer%3CA%3E-for-TracingLayer" class="impl"><a href="#impl-Layer%3CA%3E-for-TracingLayer" class="anchor">§</a><h3 class="code-header">impl&lt;A&gt; <a class="trait" href="trait.Layer.html" title="trait object_store::layers::mock::Layer">Layer</a>&lt;A&gt; for <a class="struct" href="../struct.TracingLayer.html" title="struct object_store::layers::TracingLayer">TracingLayer</a><div class="where">where
A: <a class="trait" href="../../trait.Access.html" title="trait object_store::Access">Access</a>,</div></h3></section></summary><div class="impl-items"><section id="associatedtype.LayeredAccess-7" class="associatedtype trait-impl"><a href="#associatedtype.LayeredAccess-7" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.LayeredAccess" class="associatedtype">LayeredAccess</a> = TracingAccessor&lt;A&gt;</h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Layer%3CA%3E-for-MetricsLayer%3CI%3E" class="impl"><a href="#impl-Layer%3CA%3E-for-MetricsLayer%3CI%3E" class="anchor">§</a><h3 class="code-header">impl&lt;A, I&gt; <a class="trait" href="trait.Layer.html" title="trait object_store::layers::mock::Layer">Layer</a>&lt;A&gt; for <a class="struct" href="../observe/struct.MetricsLayer.html" title="struct object_store::layers::observe::MetricsLayer">MetricsLayer</a>&lt;I&gt;<div class="where">where
A: <a class="trait" href="../../trait.Access.html" title="trait object_store::Access">Access</a>,
I: <a class="trait" href="../observe/trait.MetricsIntercept.html" title="trait object_store::layers::observe::MetricsIntercept">MetricsIntercept</a>,</div></h3></section></summary><div class="impl-items"><section id="associatedtype.LayeredAccess-8" class="associatedtype trait-impl"><a href="#associatedtype.LayeredAccess-8" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.LayeredAccess" class="associatedtype">LayeredAccess</a> = <a class="struct" href="../observe/struct.MetricsAccessor.html" title="struct object_store::layers::observe::MetricsAccessor">MetricsAccessor</a>&lt;A, I&gt;</h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Layer%3CA%3E-for-LoggingLayer%3CI%3E" class="impl"><a href="#impl-Layer%3CA%3E-for-LoggingLayer%3CI%3E" class="anchor">§</a><h3 class="code-header">impl&lt;A, I&gt; <a class="trait" href="trait.Layer.html" title="trait object_store::layers::mock::Layer">Layer</a>&lt;A&gt; for <a class="struct" href="../struct.LoggingLayer.html" title="struct object_store::layers::LoggingLayer">LoggingLayer</a>&lt;I&gt;<div class="where">where
A: <a class="trait" href="../../trait.Access.html" title="trait object_store::Access">Access</a>,
I: <a class="trait" href="../trait.LoggingInterceptor.html" title="trait object_store::layers::LoggingInterceptor">LoggingInterceptor</a>,</div></h3></section></summary><div class="impl-items"><section id="associatedtype.LayeredAccess-9" class="associatedtype trait-impl"><a href="#associatedtype.LayeredAccess-9" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.LayeredAccess" class="associatedtype">LayeredAccess</a> = LoggingAccessor&lt;A, I&gt;</h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Layer%3CA%3E-for-RetryLayer%3CI%3E" class="impl"><a href="#impl-Layer%3CA%3E-for-RetryLayer%3CI%3E" class="anchor">§</a><h3 class="code-header">impl&lt;A, I&gt; <a class="trait" href="trait.Layer.html" title="trait object_store::layers::mock::Layer">Layer</a>&lt;A&gt; for <a class="struct" href="../struct.RetryLayer.html" title="struct object_store::layers::RetryLayer">RetryLayer</a>&lt;I&gt;<div class="where">where
A: <a class="trait" href="../../trait.Access.html" title="trait object_store::Access">Access</a>,
I: <a class="trait" href="../trait.RetryInterceptor.html" title="trait object_store::layers::RetryInterceptor">RetryInterceptor</a>,</div></h3></section></summary><div class="impl-items"><section id="associatedtype.LayeredAccess-10" class="associatedtype trait-impl"><a href="#associatedtype.LayeredAccess-10" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.LayeredAccess" class="associatedtype">LayeredAccess</a> = RetryAccessor&lt;A, I&gt;</h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Layer%3CA%3E-for-MockLayer" class="impl"><a class="src rightside" href="../../../src/object_store/layers/mock.rs.html#59-72">Source</a><a href="#impl-Layer%3CA%3E-for-MockLayer" class="anchor">§</a><h3 class="code-header">impl&lt;A: <a class="trait" href="../../trait.Access.html" title="trait object_store::Access">Access</a>&gt; <a class="trait" href="trait.Layer.html" title="trait object_store::layers::mock::Layer">Layer</a>&lt;A&gt; for <a class="struct" href="struct.MockLayer.html" title="struct object_store::layers::mock::MockLayer">MockLayer</a></h3></section></summary><div class="impl-items"><section id="associatedtype.LayeredAccess-11" class="associatedtype trait-impl"><a class="src rightside" href="../../../src/object_store/layers/mock.rs.html#60">Source</a><a href="#associatedtype.LayeredAccess-11" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.LayeredAccess" class="associatedtype">LayeredAccess</a> = <a class="struct" href="struct.MockAccessor.html" title="struct object_store::layers::mock::MockAccessor">MockAccessor</a>&lt;A&gt;</h4></section></div></details></div><script src="../../../trait.impl/opendal/raw/layer/trait.Layer.js" data-ignore-extern-crates="opendal" async></script></section></div></main></body></html>