pub struct Config {Show 24 fields
pub timeout_secs: u64,
pub connect_timeout_secs: u64,
pub max_body_bytes: u64,
pub max_output_bytes: u64,
pub max_redirects: u32,
pub max_retries: u32,
pub retry_base_ms: u64,
pub retry_max_delay_ms: u64,
pub disable_retry: bool,
pub rate_limit_delay_ms: u64,
pub max_concurrency: u32,
pub user_agent: String,
pub contact: Option<String>,
pub lang: Option<String>,
pub config_dir: Option<PathBuf>,
pub cache_dir: Option<PathBuf>,
pub cache_ttl_secs: u64,
pub max_cache_bytes: u64,
pub no_cache: bool,
pub crates_io_origin: String,
pub docs_rs_origin: String,
pub config_path_source: PathSource,
pub cache_path_source: PathSource,
pub config_toml_loaded: bool,
}Expand description
Runtime configuration resolved from defaults, XDG TOML, env, and CLI.
Fields§
§timeout_secs: u64Wall-clock timeout in seconds for one operation.
connect_timeout_secs: u64TCP connect timeout in seconds.
max_body_bytes: u64Maximum downloaded HTTP body size in bytes.
max_output_bytes: u64Maximum emitted stdout payload size in bytes.
max_redirects: u32Maximum HTTP redirects followed.
max_retries: u32Maximum retries for transient HTTP errors.
retry_base_ms: u64Base backoff delay in milliseconds between retries.
retry_max_delay_ms: u64Ceiling for a single retry sleep in milliseconds.
disable_retry: boolKill switch: when true, HTTP never retries (incident / debug).
rate_limit_delay_ms: u64Minimum delay between requests to the same host in milliseconds.
max_concurrency: u32Max concurrent CPU (spawn_blocking) tasks; 0 = auto from CPUs/RAM.
user_agent: StringHTTP User-Agent header value.
contact: Option<String>Optional contact URL or email embedded in the default User-Agent.
lang: Option<String>Preferred human-message locale (en or pt-BR).
config_dir: Option<PathBuf>Resolved XDG (or override) config directory.
cache_dir: Option<PathBuf>XDG (or override) root for HTTP response cache between process runs.
cache_ttl_secs: u64Disk cache TTL in seconds (default 24h).
max_cache_bytes: u64Soft cap on disk cache size in bytes (0 = unlimited).
no_cache: boolWhen true, skip disk cache read/write (--no-cache).
crates_io_origin: StringOrigin for crates.io API (default https://crates.io). Overridable for offline mocks.
docs_rs_origin: StringOrigin for docs.rs pages (default https://docs.rs). Overridable for offline mocks.
config_path_source: PathSourceLayer that resolved Self::config_dir.
cache_path_source: PathSourceLayer that resolved Self::cache_dir.
config_toml_loaded: boolTrue when config.toml existed and was applied during load.
Implementations§
Source§impl Config
impl Config
Sourcepub fn load(config_dir_override: Option<PathBuf>) -> AppResult<Self>
pub fn load(config_dir_override: Option<PathBuf>) -> AppResult<Self>
Loads configuration with an optional config-directory override.
§Errors
Returns ErrorKind::Config when the TOML file is unreadable or invalid.
Sourcepub fn load_with_cache_dir(
config_dir_override: Option<PathBuf>,
cache_dir_override: Option<PathBuf>,
) -> AppResult<Self>
pub fn load_with_cache_dir( config_dir_override: Option<PathBuf>, cache_dir_override: Option<PathBuf>, ) -> AppResult<Self>
Load config with optional config-dir and cache-dir overrides (CLI / tests).
§Errors
Returns ErrorKind::Config when config.toml is unreadable or invalid TOML.
Sourcepub fn config_file_path(&self) -> Option<PathBuf>
pub fn config_file_path(&self) -> Option<PathBuf>
Absolute path to config.toml under the resolved config directory, if any.
Sourcepub fn clamp_resource_limits(&mut self)
pub fn clamp_resource_limits(&mut self)
Clamp body/output budgets so config, env, or CLI cannot force multi-GiB allocs.
Call after every mutation path (TOML, env, CLI). Values above the hard
ceilings are silently reduced to HARD_MAX_BODY_BYTES /
HARD_MAX_OUTPUT_BYTES. Zero is left as-is (fail-closed for body reads).
Source§impl Config
impl Config
Sourcepub fn connect_timeout(&self) -> Duration
pub fn connect_timeout(&self) -> Duration
TCP connect timeout duration (at least one second).
Sourcepub fn rate_limit_delay(&self) -> Duration
pub fn rate_limit_delay(&self) -> Duration
Per-host rate-limit delay duration.
Sourcepub fn cache_enabled(&self) -> bool
pub fn cache_enabled(&self) -> bool
Whether disk cache should be used for HTTP GET bodies.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Config
impl<'de> Deserialize<'de> for Config
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>,
Auto Trait Implementations§
impl Freeze for Config
impl RefUnwindSafe for Config
impl Send for Config
impl Sync for Config
impl Unpin for Config
impl UnsafeUnpin for Config
impl UnwindSafe for Config
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more