Skip to main content

Config

Struct Config 

Source
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: u64

Wall-clock timeout in seconds for one operation.

§connect_timeout_secs: u64

TCP connect timeout in seconds.

§max_body_bytes: u64

Maximum downloaded HTTP body size in bytes.

§max_output_bytes: u64

Maximum emitted stdout payload size in bytes.

§max_redirects: u32

Maximum HTTP redirects followed.

§max_retries: u32

Maximum retries for transient HTTP errors.

§retry_base_ms: u64

Base backoff delay in milliseconds between retries.

§retry_max_delay_ms: u64

Ceiling for a single retry sleep in milliseconds.

§disable_retry: bool

Kill switch: when true, HTTP never retries (incident / debug).

§rate_limit_delay_ms: u64

Minimum delay between requests to the same host in milliseconds.

§max_concurrency: u32

Max concurrent CPU (spawn_blocking) tasks; 0 = auto from CPUs/RAM.

See crate::concurrency::resolve_max_concurrency.

§user_agent: String

HTTP 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: u64

Disk cache TTL in seconds (default 24h).

§max_cache_bytes: u64

Soft cap on disk cache size in bytes (0 = unlimited).

§no_cache: bool

When true, skip disk cache read/write (--no-cache).

§crates_io_origin: String

Origin for crates.io API (default https://crates.io). Overridable for offline mocks.

§docs_rs_origin: String

Origin for docs.rs pages (default https://docs.rs). Overridable for offline mocks.

§config_path_source: PathSource

Layer that resolved Self::config_dir.

§cache_path_source: PathSource

Layer that resolved Self::cache_dir.

§config_toml_loaded: bool

True when config.toml existed and was applied during load.

Implementations§

Source§

impl Config

Source

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.

Source

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.

Source

pub fn config_file_path(&self) -> Option<PathBuf>

Absolute path to config.toml under the resolved config directory, if any.

Source

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

Source

pub fn timeout(&self) -> Duration

Wall-clock timeout duration (at least one second).

Source

pub fn connect_timeout(&self) -> Duration

TCP connect timeout duration (at least one second).

Source

pub fn rate_limit_delay(&self) -> Duration

Per-host rate-limit delay duration.

Source

pub fn cache_ttl(&self) -> Duration

TTL for disk cache entries.

Source

pub fn cache_enabled(&self) -> bool

Whether disk cache should be used for HTTP GET bodies.

Trait Implementations§

Source§

impl Clone for Config

Source§

fn clone(&self) -> Config

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Config

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Config

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Config

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for Config

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more