diff options
author | Katharina Fey <kookie@spacekookie.de> | 2019-04-22 02:17:36 +0200 |
---|---|---|
committer | Katharina Fey <kookie@spacekookie.de> | 2019-04-22 02:17:36 +0200 |
commit | 16522d90a7ad626bb36d57fbc24076bb01ce8616 (patch) | |
tree | a3b3a5bb6a5b1826ebe4807e40df1be45ff9b292 | |
parent | f12fae4479c5b97ab37823d7aa58d9156e2fc3ad (diff) |
Running rustfmt
28 files changed, 45 insertions, 47 deletions
diff --git a/lockchain-core/src/crypto/data.rs b/lockchain-core/src/crypto/data.rs index f1ed15c..4655a02 100644 --- a/lockchain-core/src/crypto/data.rs +++ b/lockchain-core/src/crypto/data.rs @@ -1,5 +1,5 @@ use crate::traits::AutoEncoder; -use serde::{Serialize, Deserialize}; +use serde::{Deserialize, Serialize}; /// Representation of encrypted data as an enecoded format /// @@ -13,4 +13,4 @@ pub struct PackedData { pub data: Vec<u8>, } -impl AutoEncoder for PackedData {}
\ No newline at end of file +impl AutoEncoder for PackedData {} diff --git a/lockchain-core/src/crypto/encoding.rs b/lockchain-core/src/crypto/encoding.rs index 0c49490..bc72c02 100644 --- a/lockchain-core/src/crypto/encoding.rs +++ b/lockchain-core/src/crypto/encoding.rs @@ -21,4 +21,4 @@ pub fn encode_hex(data: &str) -> String { } return s; -}
\ No newline at end of file +} diff --git a/lockchain-core/src/crypto/mod.rs b/lockchain-core/src/crypto/mod.rs index 6a1c45e..c0c0c59 100644 --- a/lockchain-core/src/crypto/mod.rs +++ b/lockchain-core/src/crypto/mod.rs @@ -1,24 +1,23 @@ //! Shared cryptographic primitives and utilities -//! -//! - +//! +//! /// We re-export keybob's API here mod keys { - pub use keybob::{Key, KeyType}; use crate::traits::{AutoEncoder, Encryptable}; + pub use keybob::{Key, KeyType}; impl AutoEncoder for Key {} impl AutoEncoder for KeyType {} - + impl Encryptable for Key {} impl Encryptable for KeyType {} } mod data; pub mod encoding; -pub mod random; pub mod hashing; +pub mod random; pub use self::data::PackedData; pub use self::keys::{Key, KeyType}; diff --git a/lockchain-core/src/errors/auth.rs b/lockchain-core/src/errors/auth.rs index 4e2332f..c86a741 100644 --- a/lockchain-core/src/errors/auth.rs +++ b/lockchain-core/src/errors/auth.rs @@ -1,8 +1,8 @@ //! Athentication errors +use serde::{Deserialize, Serialize}; use std::error::Error as StdError; use std::fmt::{Display, Formatter, Result}; -use serde::{Serialize, Deserialize}; /// Common errors that can occur when authenticating users #[derive(Debug, Serialize, Deserialize)] diff --git a/lockchain-core/src/errors/crypto.rs b/lockchain-core/src/errors/crypto.rs index e33b718..018b68d 100644 --- a/lockchain-core/src/errors/crypto.rs +++ b/lockchain-core/src/errors/crypto.rs @@ -1,8 +1,8 @@ //! I sell crypto and crypto accessories (errors) +use serde::{Deserialize, Serialize}; use std::error::Error as StdError; use std::fmt::{Display, Formatter, Result}; -use serde::{Serialize, Deserialize}; #[derive(Debug, Serialize, Deserialize)] pub enum Error { diff --git a/lockchain-core/src/errors/data.rs b/lockchain-core/src/errors/data.rs index fec14ba..c23cb65 100644 --- a/lockchain-core/src/errors/data.rs +++ b/lockchain-core/src/errors/data.rs @@ -1,8 +1,8 @@ //! Data integrity errors +use serde::{Deserialize, Serialize}; use std::error::Error as StdError; use std::fmt::{Display, Formatter, Result}; -use serde::{Serialize, Deserialize}; #[derive(Debug, Serialize, Deserialize)] pub enum Error { diff --git a/lockchain-core/src/errors/mod.rs b/lockchain-core/src/errors/mod.rs index 0355998..86e344f 100644 --- a/lockchain-core/src/errors/mod.rs +++ b/lockchain-core/src/errors/mod.rs @@ -17,9 +17,9 @@ pub use self::crypto::Error as CryptoError; pub use self::data::Error as DataError; pub use self::vault::Error as VaultError; +use serde::{Deserialize, Serialize}; use std::error::Error as StdError; use std::fmt::{Display, Formatter, Result}; -use serde::{Serialize, Deserialize}; #[derive(Debug, Serialize, Deserialize)] pub enum Error { diff --git a/lockchain-core/src/errors/vault.rs b/lockchain-core/src/errors/vault.rs index 5d3fb6e..475242c 100644 --- a/lockchain-core/src/errors/vault.rs +++ b/lockchain-core/src/errors/vault.rs @@ -1,8 +1,8 @@ //! Vault workflow and I/O errors +use serde::{Deserialize, Serialize}; use std::error::Error as StdError; use std::fmt::{Display, Formatter, Result}; -use serde::{Serialize, Deserialize}; #[derive(Debug, Serialize, Deserialize)] pub enum Error { diff --git a/lockchain-core/src/init.rs b/lockchain-core/src/init.rs index 2fad6fc..8fa2ccc 100644 --- a/lockchain-core/src/init.rs +++ b/lockchain-core/src/init.rs @@ -1,6 +1,6 @@ use crate::errors::VaultError; use crate::traits::{Body, Vault}; -use serde::{Serialize, Deserialize}; +use serde::{Deserialize, Serialize}; /// Describes the internal permission layout of a vault /// diff --git a/lockchain-core/src/lib.rs b/lockchain-core/src/lib.rs index bfe014f..385f674 100644 --- a/lockchain-core/src/lib.rs +++ b/lockchain-core/src/lib.rs @@ -66,14 +66,14 @@ pub mod users; mod init; pub use self::crypto::PackedData; +pub use self::init::{Generator, VaultType}; pub use self::meta::{MetaDomain, VaultMetadata}; pub use self::record::{EncryptedBody, Header, Payload, Record}; -pub use self::init::{VaultType, Generator}; /// Export commonly used types via the prelude pub mod prelude { pub use super::crypto::PackedData; + pub use super::init::{Generator, VaultType}; pub use super::meta::{MetaDomain, VaultMetadata}; pub use super::record::{EncryptedBody, Header, Payload, Record}; - pub use super::init::{VaultType, Generator}; } diff --git a/lockchain-core/src/meta.rs b/lockchain-core/src/meta.rs index c46cd95..91c7f39 100644 --- a/lockchain-core/src/meta.rs +++ b/lockchain-core/src/meta.rs @@ -5,9 +5,9 @@ //! or trait base security. use crate::record::Payload; -use std::collections::HashMap; use crate::traits::{AutoEncoder, Body}; -use serde::{Serialize, Deserialize}; +use serde::{Deserialize, Serialize}; +use std::collections::HashMap; /// A simple representation of metadata for a vault or vault section pub struct VaultMetadata { diff --git a/lockchain-core/src/record.rs b/lockchain-core/src/record.rs index 8f17468..a41f181 100644 --- a/lockchain-core/src/record.rs +++ b/lockchain-core/src/record.rs @@ -9,10 +9,10 @@ //! //! **No secret information should ever be stored in the header** +use crate::traits::{AutoEncoder, Body}; use chrono::{DateTime, Local}; -use serde::{Serialize, Deserialize}; +use serde::{Deserialize, Serialize}; use std::collections::BTreeMap; -use crate::traits::{AutoEncoder, Body}; /// An enum that wraps around all possible data types to store /// as the value of a vault record. diff --git a/lockchain-core/src/traits.rs b/lockchain-core/src/traits.rs index eb7c99b..d58707b 100644 --- a/lockchain-core/src/traits.rs +++ b/lockchain-core/src/traits.rs @@ -15,8 +15,8 @@ use crate::errors::VaultError; use crate::init::Generator; use crate::meta::{MetaDomain, VaultMetadata}; use crate::record::{EncryptedBody, Header, Payload, Record}; -use serde::{de::DeserializeOwned, Serialize}; use crate::users::{Access, Token}; +use serde::{de::DeserializeOwned, Serialize}; use base64; use serde_json::{self, Error as SerdeError}; diff --git a/lockchain-core/src/users/auth.rs b/lockchain-core/src/users/auth.rs index ffedb49..8b18de6 100644 --- a/lockchain-core/src/users/auth.rs +++ b/lockchain-core/src/users/auth.rs @@ -24,4 +24,4 @@ pub fn pam_authenticate(username: &str, password: &str) -> Result<(), AuthError> // pub fn yubikey_authenticate(username: &str, yubi_id: &str) -> Result<(), AuthError> { // unimplemented!() -// }
\ No newline at end of file +// } diff --git a/lockchain-core/src/users/rights.rs b/lockchain-core/src/users/rights.rs index 635df3c..4d4a7a7 100644 --- a/lockchain-core/src/users/rights.rs +++ b/lockchain-core/src/users/rights.rs @@ -1,7 +1,7 @@ //! Permission and access system for lockchain use crate::traits::AutoEncoder; -use serde::{Serialize, Deserialize}; +use serde::{Deserialize, Serialize}; /// Specifies access to a resource #[derive(Hash, Serialize, Deserialize, Clone, PartialEq, Eq)] diff --git a/lockchain-core/src/users/secrets.rs b/lockchain-core/src/users/secrets.rs index 6c22293..64f887d 100644 --- a/lockchain-core/src/users/secrets.rs +++ b/lockchain-core/src/users/secrets.rs @@ -1,7 +1,7 @@ //! A secrets type module that wraps around some user content with metadata use crate::traits::AutoEncoder; -use serde::{Serialize, Deserialize}; +use serde::{Deserialize, Serialize}; /// Specifies the type of secret that's used to derive a vault user secret #[derive(Serialize, Deserialize)] diff --git a/lockchain-core/src/users/tokens.rs b/lockchain-core/src/users/tokens.rs index 3f29af1..c5b3655 100644 --- a/lockchain-core/src/users/tokens.rs +++ b/lockchain-core/src/users/tokens.rs @@ -1,5 +1,5 @@ use crate::crypto::{Key, KeyType}; -use serde::{Serialize, Deserialize}; +use serde::{Deserialize, Serialize}; use std::borrow::Cow; /// An authentication token that can be compared in constant time diff --git a/lockchain-core/src/users/user.rs b/lockchain-core/src/users/user.rs index beaba1a..9538708 100644 --- a/lockchain-core/src/users/user.rs +++ b/lockchain-core/src/users/user.rs @@ -2,9 +2,9 @@ use super::rights::{Access, Role}; use crate::crypto::{encoding, hashing, random}; -use std::collections::HashMap; use crate::traits::AutoEncoder; -use serde::{Serialize, Deserialize}; +use serde::{Deserialize, Serialize}; +use std::collections::HashMap; /// A generic user representation /// diff --git a/lockchain-core/src/users/userstore.rs b/lockchain-core/src/users/userstore.rs index 10a2858..ae76900 100644 --- a/lockchain-core/src/users/userstore.rs +++ b/lockchain-core/src/users/userstore.rs @@ -1,9 +1,9 @@ //! Merging `KeyStore` and `Userstore` into the same concept use super::rights::Access; -use std::collections::HashMap; use crate::traits::AutoEncoder; -use serde::{Serialize, Deserialize}; +use serde::{Deserialize, Serialize}; +use std::collections::HashMap; /// A thin user UserStore /// diff --git a/lockchain-crypto/src/databody.rs b/lockchain-crypto/src/databody.rs index 2662f51..8f780f1 100644 --- a/lockchain-crypto/src/databody.rs +++ b/lockchain-crypto/src/databody.rs @@ -7,7 +7,7 @@ use crate::lcc::traits::{AutoEncoder, Body}; use crate::lcc::Payload; -use serde::{Serialize, Deserialize}; +use serde::{Deserialize, Serialize}; use std::collections::BTreeMap; #[derive(Serialize, Deserialize)] diff --git a/lockchain-crypto/src/engine.rs b/lockchain-crypto/src/engine.rs index fe9c94c..66b22e4 100644 --- a/lockchain-crypto/src/engine.rs +++ b/lockchain-crypto/src/engine.rs @@ -3,12 +3,12 @@ //! Can be initialised from scratch or with a pw/salt //! combintaion which derives a key via the `keybob` crate. +use crate::lcc::crypto::{random, Key}; use crate::lcc::traits::{AutoEncoder, Encryptable, EncryptionHandler}; use crate::lcc::{EncryptedBody, PackedData}; -use crate::lcc::crypto::{random, Key}; -use miscreant::{Aead, Aes256SivAead}; use super::databody::DataBody; +use miscreant::{Aead, Aes256SivAead}; impl Encryptable for DataBody {} diff --git a/lockchain-crypto/src/lib.rs b/lockchain-crypto/src/lib.rs index a454a46..525a079 100644 --- a/lockchain-crypto/src/lib.rs +++ b/lockchain-crypto/src/lib.rs @@ -12,4 +12,4 @@ mod keyfold; pub use crate::databody::DataBody; pub use crate::engine::AesEngine; -pub use crate::keyfold::Keyfold;
\ No newline at end of file +pub use crate::keyfold::Keyfold; diff --git a/lockchain-files/examples/create.rs b/lockchain-files/examples/create.rs index 06558cb..cceb5c9 100644 --- a/lockchain-files/examples/create.rs +++ b/lockchain-files/examples/create.rs @@ -22,7 +22,8 @@ fn main() { .user_type(VaultType::SoloUser { username: "spacekookie".into(), secret: key.as_slice().to_vec(), - }).finalise() + }) + .finalise() .unwrap(); } diff --git a/lockchain-files/src/config.rs b/lockchain-files/src/config.rs index 155e976..ed1b875 100644 --- a/lockchain-files/src/config.rs +++ b/lockchain-files/src/config.rs @@ -7,9 +7,9 @@ use std::{ time::SystemTime, }; +use crate::utils::FileToString; use semver::Version; use serde_yaml; -use crate::utils::FileToString; use crate::lcc::{errors::VaultError, VaultType}; diff --git a/lockchain-files/src/fs/mod.rs b/lockchain-files/src/fs/mod.rs index 5a9d9cd..08f90b5 100644 --- a/lockchain-files/src/fs/mod.rs +++ b/lockchain-files/src/fs/mod.rs @@ -64,12 +64,14 @@ impl Filesystem { FileType::Record => self.root.join("records"), FileType::Metadata => self.root.join("metadata"), _ => self.root.clone(), - })?.into_iter() + })? + .into_iter() .filter_map(|r| r.ok()) .filter(|f| match f.file_type() { Ok(vf) => vf.is_file(), _ => false, - }).map(|de| de.path()) + }) + .map(|de| de.path()) .filter_map(|p| p.into_os_string().into_string().ok()) .filter_map(|s| File::open(s).ok()) .filter_map(|mut f| f.get_string().ok()) diff --git a/lockchain-files/src/lib.rs b/lockchain-files/src/lib.rs index d10ecf1..f4a2c33 100644 --- a/lockchain-files/src/lib.rs +++ b/lockchain-files/src/lib.rs @@ -11,8 +11,8 @@ extern crate semver; #[macro_use] extern crate serde_derive; -extern crate serde_yaml; extern crate serde; +extern crate serde_yaml; use crate::lcc::traits::{Body, LoadRecord, Vault}; use crate::lcc::{ diff --git a/lockchain-files/src/load.rs b/lockchain-files/src/load.rs index 034d616..524b491 100644 --- a/lockchain-files/src/load.rs +++ b/lockchain-files/src/load.rs @@ -5,10 +5,9 @@ use crate::lcc::errors::VaultError; use crate::lcc::{traits::Body, Generator}; use std::collections::HashMap; -use crate::FileVault; -use crate::config::{VaultConfig, ConfigError}; +use crate::config::{ConfigError, VaultConfig}; use crate::fs::Filesystem; - +use crate::FileVault; impl<T: Body> FileVault<T> { /// A small utility to load an existing file vault @@ -30,5 +29,4 @@ impl<T: Body> FileVault<T> { // users: UserStoreMapper::new(), // }.load() } - } diff --git a/lockchain-files/src/utils.rs b/lockchain-files/src/utils.rs index c724d32..00ecbd6 100644 --- a/lockchain-files/src/utils.rs +++ b/lockchain-files/src/utils.rs @@ -1,11 +1,9 @@ //! Small utility module for file operations -use std::io::{self, Read}; use std::fs::File; +use std::io::{self, Read}; -pub fn check_config() { - -} +pub fn check_config() {} /// A utility trait to read the conents from a file in /// a single line. |