Struct cached_path::CacheBuilder
source · 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)
.