From 26abcd35e8698d8f30785321493f2616ccf353d9 Mon Sep 17 00:00:00 2001 From: librelois <elois@ifee.fr> Date: Wed, 7 Mar 2018 00:40:52 +0100 Subject: [PATCH] [fix] #38 Comply to fmt and Clippy --- protocol/blockchain/v10/documents/identity.rs | 4 ++-- protocol/blockchain/v10/documents/membership.rs | 12 ++++++------ protocol/blockchain/v10/documents/mod.rs | 13 +++++-------- wotb/legacy.rs | 6 +++--- wotb/lib.rs | 10 +++++----- wotb/rusty.rs | 2 +- 6 files changed, 22 insertions(+), 25 deletions(-) diff --git a/protocol/blockchain/v10/documents/identity.rs b/protocol/blockchain/v10/documents/identity.rs index 5e901d74..05762ee5 100644 --- a/protocol/blockchain/v10/documents/identity.rs +++ b/protocol/blockchain/v10/documents/identity.rs @@ -116,7 +116,7 @@ impl<'a> IdentityDocumentBuilder<'a> { signatures: Vec<ed25519::Signature>, ) -> IdentityDocument { IdentityDocument { - text: text, + text, currency: self.currency.to_string(), unique_id: self.unique_id.to_string(), blockstamp: *self.blockstamp, @@ -183,7 +183,7 @@ impl StandardTextDocumentParser for IdentityDocumentParser { text: doc.to_owned(), currency: currency.to_owned(), unique_id: uid.to_owned(), - blockstamp: blockstamp, + blockstamp, issuers: vec![issuer], signatures, })) diff --git a/protocol/blockchain/v10/documents/membership.rs b/protocol/blockchain/v10/documents/membership.rs index 2710cfea..88b5e262 100644 --- a/protocol/blockchain/v10/documents/membership.rs +++ b/protocol/blockchain/v10/documents/membership.rs @@ -26,10 +26,10 @@ use blockchain::v10::documents::{StandardTextDocumentParser, TextDocument, TextD lazy_static! { static ref MEMBERSHIP_REGEX: Regex = Regex::new( "^Issuer: (?P<issuer>[1-9A-Za-z][^OIl]{43,44})\n\ -Block: (?P<blockstamp>[0-9]+-[0-9A-F]{64})\n\ -Membership: (?P<membership>(IN|OUT))\n\ -UserID: (?P<ity_user>[[:alnum:]_-]+)\n\ -CertTS: (?P<ity_block>[0-9]+-[0-9A-F]{64})\n$" + Block: (?P<blockstamp>[0-9]+-[0-9A-F]{64})\n\ + Membership: (?P<membership>(IN|OUT))\n\ + UserID: (?P<ity_user>[[:alnum:]_-]+)\n\ + CertTS: (?P<ity_block>[0-9]+-[0-9A-F]{64})\n$" ).unwrap(); } @@ -141,7 +141,7 @@ impl<'a> MembershipDocumentBuilder<'a> { signatures: Vec<ed25519::Signature>, ) -> MembershipDocument { MembershipDocument { - text: text, + text, currency: self.currency.to_string(), issuers: vec![*self.issuer], blockstamp: *self.blockstamp, @@ -227,7 +227,7 @@ impl StandardTextDocumentParser for MembershipDocumentParser { text: doc.to_owned(), issuers: vec![issuer], currency: currency.to_owned(), - blockstamp: blockstamp, + blockstamp, membership, identity_username: username.to_owned(), identity_blockstamp: ity_block, diff --git a/protocol/blockchain/v10/documents/mod.rs b/protocol/blockchain/v10/documents/mod.rs index 684028d2..b97bf576 100644 --- a/protocol/blockchain/v10/documents/mod.rs +++ b/protocol/blockchain/v10/documents/mod.rs @@ -30,15 +30,12 @@ pub use blockchain::v10::documents::membership::{MembershipDocument, MembershipD lazy_static! { static ref DOCUMENT_REGEX: Regex = Regex::new( "^(?P<doc>Version: 10\n\ - Type: (?P<type>[[:alpha:]]+)\n\ - Currency: (?P<currency>[[:alnum:] _-]+)\n\ - (?P<body>(?:.*\n)+?))\ - (?P<sigs>([[:alnum:]+/=]+\n)*([[:alnum:]+/=]+))$" - ).unwrap(); - - static ref SIGNATURES_REGEX: Regex = Regex::new( - "[[:alnum:]+/=]+\n?" + Type: (?P<type>[[:alpha:]]+)\n\ + Currency: (?P<currency>[[:alnum:] _-]+)\n\ + (?P<body>(?:.*\n)+?))\ + (?P<sigs>([[:alnum:]+/=]+\n)*([[:alnum:]+/=]+))$" ).unwrap(); + static ref SIGNATURES_REGEX: Regex = Regex::new("[[:alnum:]+/=]+\n?").unwrap(); } /// List of wrapped document types. diff --git a/wotb/legacy.rs b/wotb/legacy.rs index fb8ffbe7..3cdd3e1b 100644 --- a/wotb/legacy.rs +++ b/wotb/legacy.rs @@ -13,7 +13,7 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see <https://www.gnu.org/licenses/>. -//! Provide a legacy implementation of *WoT* storage and calculations. +//! Provide a legacy implementation of `WebOfTrust` storage and calculations. //! Its mostly translated directly from the original C++ code. use WotDistance; @@ -143,7 +143,7 @@ impl LegacyWebOfTrust { } } - /// Read *WoT* from file. + /// Read `WoT` from file. pub fn legacy_from_file(path: &str) -> Option<LegacyWebOfTrust> { let mut file = match File::open(path) { Ok(file) => file, @@ -161,7 +161,7 @@ impl LegacyWebOfTrust { } } - /// Write *WoT* to file. + /// Write `WoT` to file. pub fn legacy_to_file(&self, path: &str) -> bool { let encoded: Vec<u8> = serialize(self, Infinite).unwrap(); diff --git a/wotb/lib.rs b/wotb/lib.rs index 8cd0cf6a..b9582366 100644 --- a/wotb/lib.rs +++ b/wotb/lib.rs @@ -85,7 +85,7 @@ pub enum RemLinkResult { UnknownTarget(), } -/// Results of WebOfTrust parsing from binary file. +/// Results of `WebOfTrust` parsing from binary file. #[derive(Debug)] pub enum WotParseError { /// FailToOpenFile @@ -101,7 +101,7 @@ impl From<std::io::Error> for WotParseError { } } -/// Results of WebOfTrust writing to binary file. +/// Results of `WebOfTrust` writing to binary file. #[derive(Debug)] pub enum WotWriteError { /// WrongWotSize @@ -131,7 +131,7 @@ pub enum HasLinkResult { UnknownTarget(), } -/// Paramters for *WoT* distance calculations +/// Paramters for `WoT` distance calculations #[derive(Debug, Copy, Clone, PartialEq)] pub struct WotDistanceParameters { /// Node from where distances are calculated. @@ -158,7 +158,7 @@ pub struct WotDistance { } /// Trait for a Web Of Trust. -/// Allow to provide other implementations of the *WoT* logic instead of the legacy C++ +/// Allow to provide other implementations of the `WoT` logic instead of the legacy C++ /// translated one. pub trait WebOfTrust { /// Get the maximum number of links per user. @@ -359,7 +359,7 @@ pub trait WebOfTrust { let mut bytes = Vec::with_capacity(1); bytes.write_u8(sources.len() as u8).unwrap(); buffer.append(&mut bytes); - for source in sources { + for source in &sources { // Write source let mut bytes: Vec<u8> = Vec::with_capacity(3); bytes.write_u24::<BigEndian>(source.0 as u32).unwrap(); diff --git a/wotb/rusty.rs b/wotb/rusty.rs index 4e58cea5..1f8b2ae7 100644 --- a/wotb/rusty.rs +++ b/wotb/rusty.rs @@ -27,7 +27,7 @@ use NewLinkResult; use NodeId; -/// A node in the *WoT* graph. +/// A node in the `WoT` graph. #[derive(Debug, Clone, PartialEq, Eq)] struct Node { /// Is this node enabled ? -- GitLab