aboutsummaryrefslogtreecommitdiff
path: root/src/config
diff options
context:
space:
mode:
authorQuentin Dufour <quentin@deuxfleurs.fr>2021-09-20 15:00:31 +0200
committerQuentin Dufour <quentin@deuxfleurs.fr>2021-09-20 15:13:16 +0200
commit7d478d997620c0af41a6ffb8b3f29dc6dda2cb98 (patch)
tree03b08b4c27401b46c3e64c53e3469d2803efa3e9 /src/config
parent2bbc9109991f8bb79a09a965a1d2779e1749b25b (diff)
downloaddiplonat-7d478d997620c0af41a6ffb8b3f29dc6dda2cb98.tar.gz
diplonat-7d478d997620c0af41a6ffb8b3f29dc6dda2cb98.zip
Stricter Rust formating rules and build in the CI
Diffstat (limited to 'src/config')
-rw-r--r--src/config/options.rs4
-rw-r--r--src/config/options_test.rs3
-rw-r--r--src/config/runtime.rs17
3 files changed, 11 insertions, 13 deletions
diff --git a/src/config/options.rs b/src/config/options.rs
index f62d14c..b8dccf7 100644
--- a/src/config/options.rs
+++ b/src/config/options.rs
@@ -62,9 +62,7 @@ impl ConfigOpts {
// Currently only used in tests
#[allow(dead_code)]
pub fn from_iter<Iter: Clone>(iter: Iter) -> Result<RuntimeConfig>
- where
- Iter: IntoIterator<Item = (String, String)>,
- {
+ where Iter: IntoIterator<Item = (String, String)> {
let base: ConfigOptsBase = envy::prefixed("DIPLONAT_").from_iter(iter.clone())?;
let consul: ConfigOptsConsul = envy::prefixed("DIPLONAT_CONSUL_").from_iter(iter.clone())?;
let acme: ConfigOptsAcme = envy::prefixed("DIPLONAT_ACME_").from_iter(iter.clone())?;
diff --git a/src/config/options_test.rs b/src/config/options_test.rs
index c0c7367..790a14e 100644
--- a/src/config/options_test.rs
+++ b/src/config/options_test.rs
@@ -1,5 +1,4 @@
-use std::collections::HashMap;
-use std::time::Duration;
+use std::{collections::HashMap, time::Duration};
use crate::config::*;
diff --git a/src/config/runtime.rs b/src/config/runtime.rs
index 0d52b15..eeb34f6 100644
--- a/src/config/runtime.rs
+++ b/src/config/runtime.rs
@@ -6,8 +6,8 @@ use crate::config::{ConfigOpts, ConfigOptsAcme, ConfigOptsBase, ConfigOptsConsul
// This code is inspired by the Trunk crate (https://github.com/thedodd/trunk)
-// In this file, we take ConfigOpts and transform them into ready-to-use RuntimeConfig.
-// We apply default values and business logic.
+// In this file, we take ConfigOpts and transform them into ready-to-use
+// RuntimeConfig. We apply default values and business logic.
#[derive(Debug)]
pub struct RuntimeConfigAcme {
@@ -59,12 +59,11 @@ impl RuntimeConfig {
impl RuntimeConfigAcme {
pub fn new(opts: ConfigOptsAcme) -> Result<Option<Self>> {
if !opts.enable {
- return Ok(None);
+ return Ok(None)
}
let email = opts.email.expect(
- "'DIPLONAT_ACME_EMAIL' environment variable is required \
- if 'DIPLONAT_ACME_ENABLE' == 'true'",
+ "'DIPLONAT_ACME_EMAIL' environment variable is required if 'DIPLONAT_ACME_ENABLE' == 'true'",
);
Ok(Some(Self { email }))
@@ -105,9 +104,11 @@ impl RuntimeConfigIgd {
if refresh_time.as_secs() * 2 > expiration_time.as_secs() {
return Err(anyhow!(
- "IGD expiration time (currently: {}s) must be at least twice bigger than refresh time (currently: {}s)",
- expiration_time.as_secs(),
- refresh_time.as_secs()));
+ "IGD expiration time (currently: {}s) must be at least twice bigger than refresh time \
+ (currently: {}s)",
+ expiration_time.as_secs(),
+ refresh_time.as_secs()
+ ))
}
Ok(Self {