diff options
author | Aaron Hill <aa1ronham@gmail.com> | 2018-10-14 20:32:26 -0400 |
---|---|---|
committer | Aaron Hill <aa1ronham@gmail.com> | 2018-10-17 21:21:04 -0400 |
commit | 56961b62187d55a62539a7443a289b373cbb5144 (patch) | |
tree | d994cda80134e614406564c348e4592f94fc8695 /src/config | |
parent | 1f09d2797c4061e2f15146af061a24a71c1e10af (diff) | |
download | roughenough-56961b62187d55a62539a7443a289b373cbb5144.zip |
Run rustfmt
Diffstat (limited to 'src/config')
-rw-r--r-- | src/config/environment.rs | 2 | ||||
-rw-r--r-- | src/config/file.rs | 7 | ||||
-rw-r--r-- | src/config/memory.rs | 10 | ||||
-rw-r--r-- | src/config/mod.rs | 15 |
4 files changed, 21 insertions, 13 deletions
diff --git a/src/config/environment.rs b/src/config/environment.rs index 533f5c0..5edb6d0 100644 --- a/src/config/environment.rs +++ b/src/config/environment.rs @@ -19,8 +19,8 @@ use std::time::Duration; use config::ServerConfig; use config::{DEFAULT_BATCH_SIZE, DEFAULT_STATUS_INTERVAL}; -use Error; use key::KeyProtection; +use Error; /// /// Obtain a Roughenough server configuration ([ServerConfig](trait.ServerConfig.html)) diff --git a/src/config/file.rs b/src/config/file.rs index bef0f1e..b0f8b4d 100644 --- a/src/config/file.rs +++ b/src/config/file.rs @@ -21,8 +21,8 @@ use yaml_rust::YamlLoader; use config::ServerConfig; use config::{DEFAULT_BATCH_SIZE, DEFAULT_STATUS_INTERVAL}; -use Error; use key::KeyProtection; +use Error; /// /// Read a Roughenough server configuration ([ServerConfig](trait.ServerConfig.html)) @@ -86,7 +86,9 @@ impl FileConfig { config.status_interval = Duration::from_secs(val as u64) } "key_protection" => { - let val = value.as_str().unwrap() + let val = value + .as_str() + .unwrap() .parse() .expect(format!("invalid key_protection value: {:?}", value).as_ref()); config.key_protection = val @@ -125,7 +127,6 @@ impl ServerConfig for FileConfig { self.status_interval } - fn key_protection(&self) -> &KeyProtection { &self.key_protection } diff --git a/src/config/memory.rs b/src/config/memory.rs index 6f35532..1227075 100644 --- a/src/config/memory.rs +++ b/src/config/memory.rs @@ -1,11 +1,10 @@ -use std::time::Duration; use config::ServerConfig; use config::{DEFAULT_BATCH_SIZE, DEFAULT_STATUS_INTERVAL}; use key::KeyProtection; +use std::time::Duration; use hex; - /// A purely in-memory Roughenough config /// This is useful for fuzzing a server without the need /// to create additioanl files. @@ -15,7 +14,7 @@ pub struct MemoryConfig { pub seed: Vec<u8>, pub batch_size: u8, pub status_interval: Duration, - pub key_protection: KeyProtection + pub key_protection: KeyProtection, } impl MemoryConfig { @@ -23,10 +22,11 @@ impl MemoryConfig { MemoryConfig { port, interface: "127.0.0.1".to_string(), - seed: hex::decode("a32049da0ffde0ded92ce10a0230d35fe615ec8461c14986baa63fe3b3bac3db").unwrap(), + seed: hex::decode("a32049da0ffde0ded92ce10a0230d35fe615ec8461c14986baa63fe3b3bac3db") + .unwrap(), batch_size: DEFAULT_BATCH_SIZE, status_interval: DEFAULT_STATUS_INTERVAL, - key_protection: KeyProtection::Plaintext + key_protection: KeyProtection::Plaintext, } } } diff --git a/src/config/mod.rs b/src/config/mod.rs index 658669a..772e1ee 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -37,8 +37,8 @@ pub use self::environment::EnvironmentConfig; mod memory; pub use self::memory::MemoryConfig; -use Error; use key::KeyProtection; +use Error; /// Maximum number of requests to process in one batch and include the the Merkle tree. pub const DEFAULT_BATCH_SIZE: u8 = 64; @@ -98,7 +98,6 @@ pub trait ServerConfig { Ok(v) => Ok(v), Err(_) => Err(Error::InvalidConfiguration(addr)), } - } } @@ -145,14 +144,22 @@ pub fn is_valid_config(cfg: &Box<ServerConfig>) -> bool { is_valid = false; } if cfg.batch_size() < 1 || cfg.batch_size() > 64 { - error!("batch_size {} is invalid; valid range 1-64", cfg.batch_size()); + error!( + "batch_size {} is invalid; valid range 1-64", + cfg.batch_size() + ); is_valid = false; } if is_valid { match cfg.socket_addr() { Err(e) => { - error!("failed to create socket {}:{} {:?}", cfg.interface(), cfg.port(), e); + error!( + "failed to create socket {}:{} {:?}", + cfg.interface(), + cfg.port(), + e + ); is_valid = false; } _ => (), |