pub struct CacheBuilder { /* private fields */ }
Expand description
Builder to facilitate creating Cache
objects.
Implementations§
Source§impl CacheBuilder
impl CacheBuilder
Sourcepub fn new() -> CacheBuilder
pub fn new() -> CacheBuilder
Construct a new CacheBuilder
.
Sourcepub fn with_client_builder(client_builder: ClientBuilder) -> CacheBuilder
pub fn with_client_builder(client_builder: ClientBuilder) -> CacheBuilder
Construct a new CacheBuilder
with a ClientBuilder
.
Sourcepub fn dir(self, dir: PathBuf) -> CacheBuilder
pub fn dir(self, dir: PathBuf) -> CacheBuilder
Set the cache location. This can be set through the environment
variable RUST_CACHED_PATH_ROOT
. Otherwise it will default to a subdirectory
named ‘cache’ of the default system temp directory.
Sourcepub fn client_builder(self, client_builder: ClientBuilder) -> CacheBuilder
pub fn client_builder(self, client_builder: ClientBuilder) -> CacheBuilder
Set the ClientBuilder
.
Sourcepub fn timeout(self, timeout: Duration) -> CacheBuilder
pub fn timeout(self, timeout: Duration) -> CacheBuilder
Enable a request timeout.
Sourcepub fn connect_timeout(self, timeout: Duration) -> CacheBuilder
pub fn connect_timeout(self, timeout: Duration) -> CacheBuilder
Enable a timeout for the connect phase of each HTTP request.
Sourcepub fn max_retries(self, max_retries: u32) -> CacheBuilder
pub fn max_retries(self, max_retries: u32) -> CacheBuilder
Set maximum number of retries for HTTP requests.
Sourcepub fn max_backoff(self, max_backoff: u32) -> CacheBuilder
pub fn max_backoff(self, max_backoff: u32) -> CacheBuilder
Set the maximum backoff delay in milliseconds for retrying HTTP requests.
Sourcepub fn freshness_lifetime(self, freshness_lifetime: u64) -> CacheBuilder
pub fn freshness_lifetime(self, freshness_lifetime: u64) -> CacheBuilder
Set the default freshness lifetime, in seconds. The default is None, meaning the ETAG for an external resource will always be checked for a fresher value.
Sourcepub fn offline(self, offline: bool) -> CacheBuilder
pub fn offline(self, offline: bool) -> CacheBuilder
Only use offline functionality.
If set to true
, when the cached path of an HTTP resource is requested,
the latest cached version is returned without checking for freshness.
But if no cached versions exist, a
NoCachedVersions
error is returned.
Sourcepub fn progress_bar(self, progress_bar: Option<ProgressBar>) -> CacheBuilder
pub fn progress_bar(self, progress_bar: Option<ProgressBar>) -> CacheBuilder
Set the type of progress bar to use.
The default is Some(ProgressBar::Full)
.