pub struct CacheLayer { /* private fields */ }target_family=wasm only.Expand description
A provider layer that caches RPC responses and serves them on subsequent requests.
In order to initialize the caching layer, the path to the cache file is provided along with the max number of items that are stored in the in-memory LRU cache.
One can load the cache from the file system by calling load_cache and save the cache to the
file system by calling save_cache.
Implementations§
Source§impl CacheLayer
impl CacheLayer
Sourcepub fn new(max_items: u32) -> Self
pub fn new(max_items: u32) -> Self
Instantiate a new cache layer with the maximum number of items to store.
Sourcepub const fn max_items(&self) -> u32
pub const fn max_items(&self) -> u32
Returns the maximum number of items that can be stored in the cache, set at initialization.
Sourcepub fn cache(&self) -> SharedCache
pub fn cache(&self) -> SharedCache
Returns the shared cache.
Trait Implementations§
Source§impl Clone for CacheLayer
impl Clone for CacheLayer
Source§fn clone(&self) -> CacheLayer
fn clone(&self) -> CacheLayer
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CacheLayer
impl Debug for CacheLayer
Source§impl<P, N> ProviderLayer<P, N> for CacheLayer
impl<P, N> ProviderLayer<P, N> for CacheLayer
Auto Trait Implementations§
impl !RefUnwindSafe for CacheLayer
impl !UnwindSafe for CacheLayer
impl Freeze for CacheLayer
impl Send for CacheLayer
impl Sync for CacheLayer
impl Unpin for CacheLayer
impl UnsafeUnpin for CacheLayer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
Source§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
Source§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 16 bytes