Skip to main content

Module config

Module config 

Source
Expand description

Tool-wide configuration: where Sendra’s config files live, how a project config overrides a global one, and what the result does to a request.

Two files, either or both of which may be absent:

  • Project: .sendra/config.yaml, found by walking up from the current directory the way git looks for .git, so running from a subdirectory of a project still finds the project’s config.
  • Global: config.yaml under the platform’s config directory — on Linux $XDG_CONFIG_HOME/sendra (i.e. ~/.config/sendra by default), on macOS ~/Library/Application Support/sendra, on Windows %APPDATA%\sendra. See global_config_path.

Project values override global values per key, not per file: a project config that sets only a timeout still inherits the global default headers. No config file anywhere is a perfectly ordinary state — everything falls back to the hardcoded defaults in Config::default.

The schema stays small on purpose, and grows only as a feature actually needs a new key — ConfigFile documents the current full set. This module exists first to prove the resolution mechanism: every key resolves through the same global-then-project, per-key merge_over.

Structs§

ClientCertFile
The client_cert: config key’s on-disk shape: a cert path and a key path, both plain strings so [resolve_client_cert_paths] can rewrite a relative one in place before it is ever turned into a PathBuf.
Config
Resolved, ready-to-use configuration: every field decided, no Options left. Built by merging whichever config files exist over the hardcoded defaults, so the rest of the crate never has to ask whether a file was found.
ConfigFile
One config file, exactly as it appears on disk.

Enums§

FollowRedirects
How a run treats an HTTP redirect: follow up to some maximum number of hops, or not at all.

Constants§

DEFAULT_MAX_REDIRECTS
reqwest’s own default: up to 10 redirects in a chain before giving up. Sendra keeps this as its default too, so a config that never mentions follow_redirects behaves exactly as it always has.
DEFAULT_TIMEOUT
Timeout applied when no config file sets one.

Functions§

find_project_config
Walk up from start_dir looking for .sendra/config.yaml, returning the first one found.
global_config_path
Path to the global config file, or None if the platform cannot say where config belongs (a daemon with no home directory, say) — in which case there is simply no global config.