pub enum CachePolicy<C, N> {
Cacheable(C),
NonCacheable(N),
}Expand description
Result of a cache decision.
Represents whether an entity should be cached or passed through without caching. Both variants preserve the entity, just wrapped differently.
§Type Parameters
C- Type of the cacheable entity (usually the cached representation)N- Type of the non-cacheable entity (usually the original response)
§Example
use hitbox_core::CachePolicy;
fn decide_caching(status: u16, body: String) -> CachePolicy<String, String> {
if status == 200 {
CachePolicy::Cacheable(body)
} else {
CachePolicy::NonCacheable(body)
}
}
match decide_caching(200, "OK".to_string()) {
CachePolicy::Cacheable(data) => println!("Cache: {}", data),
CachePolicy::NonCacheable(data) => println!("Pass through: {}", data),
}Variants§
Cacheable(C)
Entity should be cached.
NonCacheable(N)
Entity should not be cached; pass through directly.
Trait Implementations§
Auto Trait Implementations§
impl<C, N> Freeze for CachePolicy<C, N>
impl<C, N> RefUnwindSafe for CachePolicy<C, N>where
C: RefUnwindSafe,
N: RefUnwindSafe,
impl<C, N> Send for CachePolicy<C, N>
impl<C, N> Sync for CachePolicy<C, N>
impl<C, N> Unpin for CachePolicy<C, N>
impl<C, N> UnwindSafe for CachePolicy<C, N>where
C: UnwindSafe,
N: UnwindSafe,
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
Mutably borrows from an owned value. Read more