diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 38505e1..861014c 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -20,6 +20,16 @@ env: CARGO_TERM_COLOR: always jobs: + clippy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - run: rustup component add clippy + - uses: actions-rs/clippy-check@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + args: --all-features + build: runs-on: ubuntu-latest steps: diff --git a/settings.sample.yaml b/settings.sample.yaml index b73314d..2dc6f6c 100644 --- a/settings.sample.yaml +++ b/settings.sample.yaml @@ -21,8 +21,7 @@ # # Default values are commented out. -# The size in mebibytes of the cache -# You can use megabytes instead in a pinch, +# The size in mebibytes of the cache You can use megabytes instead in a pinch, # but just know the two are **NOT** the same. max_cache_size_in_mebibytes: 0 @@ -34,7 +33,7 @@ server_settings: # port: 443 # This controls the value the server receives for your upload speed. - external_max_kilobits_per_second: 0 + external_max_kilobits_per_second: 1 # # Advanced settings diff --git a/src/config.rs b/src/config.rs index cb21c0f..0ec0962 100644 --- a/src/config.rs +++ b/src/config.rs @@ -178,28 +178,6 @@ impl Config { } } -#[derive(Deserialize)] -struct YamlArgs { - // Naming is legacy - max_cache_size_in_mebibytes: Mebibytes, - server_settings: YamlServerSettings, - // This implementation custom options - extended_options: Option, -} - -// Naming is legacy -#[derive(Deserialize)] -struct YamlServerSettings { - secret: ClientSecret, - #[serde(default)] - port: Port, - external_max_kilobits_per_second: KilobitsPerSecond, - external_port: Option, - graceful_shutdown_wait_seconds: Option, - hostname: Option, - external_ip: Option, -} - // this intentionally does not implement display #[derive(Deserialize, Serialize, Clone)] pub struct ClientSecret(String); @@ -210,16 +188,6 @@ impl std::fmt::Debug for ClientSecret { } } -#[derive(Deserialize, Default)] -struct YamlExtendedOptions { - memory_quota: Option, - cache_type: Option, - ephemeral_disk_encryption: Option, - enable_metrics: Option, - logging_level: Option, - cache_path: Option, -} - #[derive(Deserialize, Copy, Clone, Debug)] #[serde(rename_all = "snake_case")] pub enum CacheType { @@ -247,6 +215,38 @@ impl Default for CacheType { } } +#[derive(Deserialize)] +struct YamlArgs { + // Naming is legacy + max_cache_size_in_mebibytes: Mebibytes, + server_settings: YamlServerSettings, + // This implementation custom options + extended_options: Option, +} + +// Naming is legacy +#[derive(Deserialize)] +struct YamlServerSettings { + secret: ClientSecret, + #[serde(default)] + port: Port, + external_max_kilobits_per_second: KilobitsPerSecond, + external_port: Option, + graceful_shutdown_wait_seconds: Option, + hostname: Option, + external_ip: Option, +} + +#[derive(Deserialize, Default)] +struct YamlExtendedOptions { + memory_quota: Option, + cache_type: Option, + ephemeral_disk_encryption: Option, + enable_metrics: Option, + logging_level: Option, + cache_path: Option, +} + #[derive(Clap, Clone)] #[clap(version = crate_version!(), author = crate_authors!(), about = crate_description!())] struct CliArgs { @@ -332,3 +332,13 @@ impl Display for UnstableOptions { } } } + +#[cfg(test)] +mod sample_yaml { + use crate::config::YamlArgs; + + #[test] + fn sample_yaml_parses() { + assert!(serde_yaml::from_str::(include_str!("../settings.sample.yaml")).is_ok()) + } +}