pub trait Context {
// Required methods
fn client(&self) -> &Client;
fn filesystem_options(&self) -> &Options;
// Provided methods
fn url_specific_headers(&self, _url: &Url) -> HeaderMap { ... }
fn cache(&self) -> Option<MutexGuard<'_, Cache>> { ... }
fn concurrency(&self) -> usize { ... }
fn cache_timeout(&self) -> Duration { ... }
fn should_ignore(&self, _link: &Link) -> bool { ... }
}
Expand description
Contextual information that callers can provide to guide the validation process.
Required Methods§
Sourcefn filesystem_options(&self) -> &Options
fn filesystem_options(&self) -> &Options
Options to use when checking a link on the filesystem.
Provided Methods§
Sourcefn url_specific_headers(&self, _url: &Url) -> HeaderMap
fn url_specific_headers(&self, _url: &Url) -> HeaderMap
Get any extra headers that should be sent when checking this Url
.
Sourcefn cache(&self) -> Option<MutexGuard<'_, Cache>>
fn cache(&self) -> Option<MutexGuard<'_, Cache>>
An optional cache that can be used to avoid unnecessary network requests.
We need to use internal mutability here because validation is done
concurrently. This MutexGuard
is guaranteed to be short lived (just
the duration of a Cache::insert()
or Cache::lookup()
), so it’s
okay to use a std::sync::Mutex
instead of futures::lock::Mutex
.
Sourcefn concurrency(&self) -> usize
fn concurrency(&self) -> usize
How many items should we check at a time?
Sourcefn cache_timeout(&self) -> Duration
fn cache_timeout(&self) -> Duration
How long should a cached item be considered valid for before we need to check again?
Sourcefn should_ignore(&self, _link: &Link) -> bool
fn should_ignore(&self, _link: &Link) -> bool
Should this Link
be skipped?