pub enum CachingStrategy {
Strict,
Adhoc,
Extendable,
}Expand description
Defines how StaticApiProvider handles namespace cache misses.
Different strategies offer different trade-offs between strictness, performance, and flexibility.
Variants§
Strict
Only allow access to namespaces that were pre-cached during initialization.
Returns an error if a namespace is not in the cache. This is the safest option and guarantees no runtime Api allocations.
Performance: Lock-free HashMap lookup (~5ns)
Adhoc
Create Api instances on-the-fly for uncached namespaces without caching them.
If a namespace is in the cache, returns the cached instance. Otherwise, creates a new Api instance each time (not cached). Useful when you have a core set of frequently-accessed namespaces but occasionally need to access others.
Performance:
- Cached: Lock-free HashMap lookup (~5ns)
- Uncached: Api creation per call (~100ns)
Extendable
Lazily create and cache Api instances on first access (extendable cache).
Similar to CachedApiProvider, but can be pre-populated with known namespaces. Uses RwLock for thread-safe dynamic caching.
Performance:
- Cached: RwLock read + HashMap lookup (~10-15ns)
- First access: RwLock write + Api creation (~100ns, one-time per namespace)
Trait Implementations§
Source§impl Clone for CachingStrategy
impl Clone for CachingStrategy
Source§fn clone(&self) -> CachingStrategy
fn clone(&self) -> CachingStrategy
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CachingStrategy
impl Debug for CachingStrategy
Source§impl PartialEq for CachingStrategy
impl PartialEq for CachingStrategy
impl Copy for CachingStrategy
impl Eq for CachingStrategy
impl StructuralPartialEq for CachingStrategy
Auto Trait Implementations§
impl Freeze for CachingStrategy
impl RefUnwindSafe for CachingStrategy
impl Send for CachingStrategy
impl Sync for CachingStrategy
impl Unpin for CachingStrategy
impl UnwindSafe for CachingStrategy
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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 more