pub struct Config {Show 26 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 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.
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: 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 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 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 ErrorKind::Config when config.toml is unreadable or invalid TOML.
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 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 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).
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