#[non_exhaustive]pub struct CacheConfig {
pub dir: PathBuf,
pub max_total_bytes: u64,
pub max_entry_bytes: u64,
pub max_age: Duration,
pub authenticated: bool,
}Expand description
Cache settings. Defaults are conservative; every limit is a ceiling.
Experimental.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.dir: PathBufThe cache directory. Created private if missing.
max_total_bytes: u64Total bytes of entries kept; the oldest are removed past this.
max_entry_bytes: u64Largest body stored. A larger response is simply not cached.
max_age: DurationOldest an entry may be, counted from its last successful revalidation. An older entry is treated as absent, offline mode included.
authenticated: boolAlso store responses to requests that carried credentials, and
Cache-Control: private responses. Off by default.
Implementations§
Source§impl CacheConfig
impl CacheConfig
Sourcepub fn new(dir: impl Into<PathBuf>) -> Self
pub fn new(dir: impl Into<PathBuf>) -> Self
Defaults: 512 MiB total, 64 MiB per entry, 7 days, no authenticated responses.
Sourcepub fn with_max_total_bytes(self, value: u64) -> Self
pub fn with_max_total_bytes(self, value: u64) -> Self
Sourcepub fn with_max_entry_bytes(self, value: u64) -> Self
pub fn with_max_entry_bytes(self, value: u64) -> Self
Sourcepub fn with_max_age(self, value: Duration) -> Self
pub fn with_max_age(self, value: Duration) -> Self
Set Self::max_age.
Sourcepub fn with_authenticated(self, value: bool) -> Self
pub fn with_authenticated(self, value: bool) -> Self
Set Self::authenticated.
Trait Implementations§
Source§impl Clone for CacheConfig
impl Clone for CacheConfig
Source§impl Debug for CacheConfig
impl Debug for CacheConfig
impl Eq for CacheConfig
Source§impl PartialEq for CacheConfig
impl PartialEq for CacheConfig
impl StructuralPartialEq for CacheConfig
Auto Trait Implementations§
impl Forget for CacheConfig
impl Freeze for CacheConfig
impl Move for CacheConfig
impl RefUnwindSafe for CacheConfig
impl Send for CacheConfig
impl Sync for CacheConfig
impl Unpin for CacheConfig
impl UnsafeUnpin for CacheConfig
impl UnwindSafe for CacheConfig
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