Browse Source

impl Default for HttpConfig, so field isn't required in config file

these changes allow omitting the http field of the top-level config,
relying on the defaults instead. previously, not having an [http] section
in the config.toml would fail to parse.
master
Jonathan Strong 2 years ago
parent
commit
bd0e3ccda7
  1. 11
      src/main.rs

11
src/main.rs

@ -194,6 +194,7 @@ pub struct Config {
pub output: OutputConfig,
/// Download settings
#[clap(flatten)]
#[serde(default)]
pub http: HttpConfig,
/// Specify configuration values using the provided TOML file, instead of
/// via command line flags. The values in the config file will override
@ -274,6 +275,16 @@ impl std::fmt::Debug for TargetRegistryConfig {
}
}
impl Default for HttpConfig {
fn default() -> Self {
Self {
user_agent: default_user_agent(),
requests_per_second: default_requests_per_second(),
max_concurrent_requests: default_max_concurrent_requests(),
}
}
}
impl std::fmt::Debug for HttpConfig {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.debug_struct("Config")

Loading…
Cancel
Save