pub struct Cache { /* private fields */ }
Expand description
A cache used to skip unnecessary network requests.
Implementations§
Source§impl Cache
impl Cache
Sourcepub fn lookup(&self, url: &Url) -> Option<&CacheEntry>
pub fn lookup(&self, url: &Url) -> Option<&CacheEntry>
Lookup a particular CacheEntry
.
Sourcepub fn insert(&mut self, url: Url, entry: CacheEntry)
pub fn insert(&mut self, url: Url, entry: CacheEntry)
Add a new CacheEntry
to the cache.
Sourcepub fn url_is_still_valid(&self, url: &Url, timeout: Duration) -> bool
pub fn url_is_still_valid(&self, url: &Url, timeout: Duration) -> bool
Ask the Cache
whether a particular Url
is still okay (i.e.
CacheEntry::valid
is true
).
Sourcepub fn iter(&self) -> impl Iterator<Item = (&Url, &CacheEntry)> + '_
pub fn iter(&self) -> impl Iterator<Item = (&Url, &CacheEntry)> + '_
Iterate over all known CacheEntries
, regardless of
whether they are stale or invalid.
Sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Forget all CacheEntries
.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Cache
impl<'de> Deserialize<'de> for Cache
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Extend<(Url, CacheEntry)> for Cache
impl Extend<(Url, CacheEntry)> for Cache
Source§fn extend<T: IntoIterator<Item = (Url, CacheEntry)>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = (Url, CacheEntry)>>(&mut self, iter: T)
Extends a collection with the contents of an iterator. Read more
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
🔬This is a nightly-only experimental API. (
extend_one
)Extends a collection with exactly one element.
Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (
extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more
impl StructuralPartialEq for Cache
Auto Trait Implementations§
impl Freeze for Cache
impl RefUnwindSafe for Cache
impl Send for Cache
impl Sync for Cache
impl Unpin for Cache
impl UnwindSafe for Cache
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