pub struct Config {Show 27 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 retry_max_elapsed_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 log_directive: 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: AllowedOrigin,
pub docs_rs_origin: AllowedOrigin,
pub allow_loopback: bool,
pub config_path_source: PathSource,
pub cache_path_source: PathSource,
pub config_toml_loaded: bool,
}Expand description
Runtime configuration resolved from defaults, XDG TOML, and CLI flags.
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.
retry_max_elapsed_ms: u64Total retry loop wall budget in milliseconds (0 = derive from timeout_secs).
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.
Omitted from config show when unset — a null key is a dead field that
costs an agent tokens without carrying information.
lang: Option<String>Preferred human-message locale (en or pt-BR).
Omitted from config show when unset (see Config::contact).
log_directive: Option<String>Default tracing filter directive when -q / -v are absent.
This is the only way to steer stderr diagnostics beyond the CLI
flags: the process reads no product environment variable, so RUST_LOG
has no effect (ADR 0009). Omitted from config show when unset.
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: AllowedOriginOrigin for crates.io API (default https://crates.io). Overridable for offline mocks.
docs_rs_origin: AllowedOriginOrigin for docs.rs pages (default https://docs.rs). Overridable for offline mocks.
allow_loopback: boolWhen true, SSRF allowlist accepts loopback (127.0.0.1 / localhost) for offline mocks.
Set only via XDG config.toml (allow_loopback = true) or CLI --allow-loopback.
Never read from environment variables (ADR 0009).
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 crate::error::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 crate::error::ErrorKind::Config when config.toml is unreadable or invalid TOML.
Sourcepub fn load_with_options(
config_dir_override: Option<PathBuf>,
cache_dir_override: Option<PathBuf>,
allow_loopback: bool,
) -> AppResult<Self>
pub fn load_with_options( config_dir_override: Option<PathBuf>, cache_dir_override: Option<PathBuf>, allow_loopback: bool, ) -> AppResult<Self>
Load config with optional path overrides and a CLI loopback seed.
allow_loopback is applied before TOML origin parsing so
--allow-loopback works with mock origins in the same invocation
(ADR 0009 — never via env).
§Errors
Returns crate::error::ErrorKind::Config when config.toml is unreadable or invalid TOML.
Source§impl Config
impl Config
Sourcepub fn validate_origins(&mut self) -> AppResult<()>
pub fn validate_origins(&mut self) -> AppResult<()>
Re-validate origin fields after TOML/CLI mutation (fail-fast config).
§Errors
Returns crate::error::ErrorKind::Config when either origin is not a valid
allowlisted HTTP(S) URL (SSRF gate at config boundary).
Sourcepub fn validate_security(&mut self) -> AppResult<()>
pub fn validate_security(&mut self) -> AppResult<()>
Validate security-sensitive config fields (origins + User-Agent + contact).
§Errors
Returns crate::error::ErrorKind::Config on allowlist, contact, or
User-Agent policy failures.
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 resource budgets to hard safety ceilings (defense in depth).
Call after every mutation path (TOML, CLI). Operator-facing surfaces
(CLI flags and TOML body/output keys) reject values above
HARD_MAX_BODY_BYTES / HARD_MAX_OUTPUT_BYTES before this runs
(GAP-X-005). This method remains a last-line cap for other knobs and
accidental internal elevations. Zero body/output is left as-is
(fail-closed for body reads).
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.