From 3b46c56bbd4f9f92fc7b11dc78263e46225dd782 Mon Sep 17 00:00:00 2001 From: Alexis Mousset Date: Wed, 14 Jun 2017 00:48:32 +0200 Subject: [PATCH] style(all): Run last rustfmt --- lettre/src/lib.rs | 2 +- lettre/src/sendmail/mod.rs | 2 +- lettre/src/smtp/authentication.rs | 2 +- lettre/src/smtp/client/mock.rs | 2 +- lettre/src/smtp/client/mod.rs | 22 ++++++++-------- lettre/src/smtp/extension.rs | 4 +-- lettre/src/smtp/mod.rs | 17 ++++++------ lettre/src/smtp/response.rs | 44 +++++++++++++++---------------- lettre_email/src/email.rs | 12 ++++----- 9 files changed, 53 insertions(+), 54 deletions(-) diff --git a/lettre/src/lib.rs b/lettre/src/lib.rs index 5acdefa..6d38f9f 100644 --- a/lettre/src/lib.rs +++ b/lettre/src/lib.rs @@ -40,7 +40,7 @@ pub trait EmailTransport { } /// Minimal email structure -#[derive(Debug,Clone)] +#[derive(Debug, Clone)] pub struct SimpleSendableEmail { /// To to: Vec, diff --git a/lettre/src/sendmail/mod.rs b/lettre/src/sendmail/mod.rs index 1c22be6..17500c5 100644 --- a/lettre/src/sendmail/mod.rs +++ b/lettre/src/sendmail/mod.rs @@ -25,7 +25,7 @@ use std::process::{Command, Stdio}; pub mod error; /// Sends an email using the `sendmail` command -#[derive(Debug,Default)] +#[derive(Debug, Default)] pub struct SendmailTransport { command: String, } diff --git a/lettre/src/smtp/authentication.rs b/lettre/src/smtp/authentication.rs index d1442c4..24cec09 100644 --- a/lettre/src/smtp/authentication.rs +++ b/lettre/src/smtp/authentication.rs @@ -10,7 +10,7 @@ use std::fmt; use std::fmt::{Display, Formatter}; /// Represents authentication mechanisms -#[derive(PartialEq,Eq,Copy,Clone,Hash,Debug)] +#[derive(PartialEq, Eq, Copy, Clone, Hash, Debug)] pub enum Mechanism { /// PLAIN authentication mechanism /// RFC 4616: https://tools.ietf.org/html/rfc4616 diff --git a/lettre/src/smtp/client/mock.rs b/lettre/src/smtp/client/mock.rs index f1c158f..7753548 100644 --- a/lettre/src/smtp/client/mock.rs +++ b/lettre/src/smtp/client/mock.rs @@ -6,7 +6,7 @@ use std::sync::{Arc, Mutex}; pub type MockCursor = Cursor>; -#[derive(Clone,Debug)] +#[derive(Clone, Debug)] pub struct MockStream { reader: Arc>, writer: Arc>, diff --git a/lettre/src/smtp/client/mod.rs b/lettre/src/smtp/client/mod.rs index ef9c85d..70b28f1 100644 --- a/lettre/src/smtp/client/mod.rs +++ b/lettre/src/smtp/client/mod.rs @@ -24,11 +24,10 @@ pub mod mock; #[inline] fn escape_dot(string: &str) -> String { if string.starts_with('.') { - format!(".{}", string) - } else { - string.to_string() - } - .replace("\r.", "\r..") + format!(".{}", string) + } else { + string.to_string() + }.replace("\r.", "\r..") .replace("\n.", "\n..") } @@ -204,12 +203,12 @@ impl Client { if mechanism.supports_initial_response() { self.command(&format!("AUTH {} {}", - mechanism, - base64::encode_config(try!(mechanism.response(username, + mechanism, + base64::encode_config(try!(mechanism.response(username, password, None)) - .as_bytes(), - base64::STANDARD))) + .as_bytes(), + base64::STANDARD))) } else { let encoded_challenge = match try!(self.command(&format!("AUTH {}", mechanism))) .first_word() { @@ -234,10 +233,11 @@ impl Client { let mut challenge_expected = 3; while challenge_expected > 0 { - let response = try!(self.command(&base64::encode_config(&try!(mechanism.response(username, + let response = + try!(self.command(&base64::encode_config(&try!(mechanism.response(username, password, Some(&decoded_challenge))) - .as_bytes(), + .as_bytes(), base64::STANDARD))); if !response.has_code(334) { diff --git a/lettre/src/smtp/extension.rs b/lettre/src/smtp/extension.rs index e65acc0..3291666 100644 --- a/lettre/src/smtp/extension.rs +++ b/lettre/src/smtp/extension.rs @@ -9,7 +9,7 @@ use std::fmt::{Display, Formatter}; use std::result::Result; /// Supported ESMTP keywords -#[derive(PartialEq,Eq,Hash,Clone,Debug)] +#[derive(PartialEq, Eq, Hash, Clone, Debug)] pub enum Extension { /// 8BITMIME keyword /// @@ -39,7 +39,7 @@ impl Display for Extension { } /// Contains information about an SMTP server -#[derive(Clone,Debug,Eq,PartialEq)] +#[derive(Clone, Debug, Eq, PartialEq)] pub struct ServerInfo { /// Server name /// diff --git a/lettre/src/smtp/mod.rs b/lettre/src/smtp/mod.rs index b6ddf44..9a1717b 100644 --- a/lettre/src/smtp/mod.rs +++ b/lettre/src/smtp/mod.rs @@ -148,7 +148,7 @@ pub const MESSAGE_ENDING: &'static str = "\r\n.\r\n"; pub const NUL: &'static str = "\0"; /// TLS security level -#[derive(PartialEq,Eq,Copy,Clone,Debug)] +#[derive(PartialEq, Eq, Copy, Clone, Debug)] pub enum SecurityLevel { /// Use a TLS wrapped connection /// @@ -401,14 +401,13 @@ impl EmailTransport for SmtpTransport { } if self.state.connection_reuse_count == 0 { - try!(self.client - .connect(&self.client_info.server_addr, - match self.client_info.security_level { - SecurityLevel::EncryptedWrapper => { - Some(&self.client_info.ssl_context) - } - _ => None, - })); + try!(self.client.connect( + &self.client_info.server_addr, + match self.client_info.security_level { + SecurityLevel::EncryptedWrapper => Some(&self.client_info.ssl_context), + _ => None, + }, + )); try!(self.client.set_timeout(self.client_info.timeout)); diff --git a/lettre/src/smtp/response.rs b/lettre/src/smtp/response.rs index 9a249e9..918f8a1 100644 --- a/lettre/src/smtp/response.rs +++ b/lettre/src/smtp/response.rs @@ -9,7 +9,7 @@ use std::result; use std::str::FromStr; /// First digit indicates severity -#[derive(PartialEq,Eq,Copy,Clone,Debug)] +#[derive(PartialEq, Eq, Copy, Clone, Debug)] pub enum Severity { /// 2yx PositiveCompletion, @@ -46,7 +46,7 @@ impl Display for Severity { } /// Second digit -#[derive(PartialEq,Eq,Copy,Clone,Debug)] +#[derive(PartialEq, Eq, Copy, Clone, Debug)] pub enum Category { /// x0z Syntax, @@ -91,7 +91,7 @@ impl Display for Category { } /// Represents a 3 digit SMTP response code -#[derive(PartialEq,Eq,Clone,Debug)] +#[derive(PartialEq, Eq, Clone, Debug)] pub struct Code { /// First digit of the response code severity: Severity, @@ -142,7 +142,7 @@ impl Code { } /// Parses an SMTP response -#[derive(PartialEq,Eq,Clone,Debug,Default)] +#[derive(PartialEq, Eq, Clone, Debug, Default)] pub struct ResponseParser { /// Response code code: Option, @@ -192,7 +192,7 @@ impl ResponseParser { /// Contains an SMTP reply, with separated code and message /// /// The text message is optional, only the code is mandatory -#[derive(PartialEq,Eq,Clone,Debug)] +#[derive(PartialEq, Eq, Clone, Debug)] pub struct Response { /// Response code code: Code, @@ -396,7 +396,7 @@ mod test { vec!["me".to_string(), "8BITMIME".to_string(), "SIZE 42".to_string()]) - .is_positive()); + .is_positive()); assert!(!Response::new(Code { severity: "5".parse::().unwrap(), category: "4".parse::().unwrap(), @@ -405,7 +405,7 @@ mod test { vec!["me".to_string(), "8BITMIME".to_string(), "SIZE 42".to_string()]) - .is_positive()); + .is_positive()); } #[test] @@ -418,7 +418,7 @@ mod test { vec!["me".to_string(), "8BITMIME".to_string(), "SIZE 42".to_string()]) - .message(), + .message(), vec!["me".to_string(), "8BITMIME".to_string(), "SIZE 42".to_string()]); @@ -429,7 +429,7 @@ mod test { detail: 1, }, vec![]) - .message(), + .message(), empty_message); } @@ -443,7 +443,7 @@ mod test { vec!["me".to_string(), "8BITMIME".to_string(), "SIZE 42".to_string()]) - .severity(), + .severity(), Severity::PositiveCompletion); assert_eq!(Response::new(Code { severity: "5".parse::().unwrap(), @@ -453,7 +453,7 @@ mod test { vec!["me".to_string(), "8BITMIME".to_string(), "SIZE 42".to_string()]) - .severity(), + .severity(), Severity::PermanentNegativeCompletion); } @@ -467,7 +467,7 @@ mod test { vec!["me".to_string(), "8BITMIME".to_string(), "SIZE 42".to_string()]) - .category(), + .category(), Category::Unspecified4); } @@ -481,7 +481,7 @@ mod test { vec!["me".to_string(), "8BITMIME".to_string(), "SIZE 42".to_string()]) - .detail(), + .detail(), 1); } @@ -495,7 +495,7 @@ mod test { vec!["me".to_string(), "8BITMIME".to_string(), "SIZE 42".to_string()]) - .code(), + .code(), "241"); } @@ -509,7 +509,7 @@ mod test { vec!["me".to_string(), "8BITMIME".to_string(), "SIZE 42".to_string()]) - .has_code(241)); + .has_code(241)); assert!(!Response::new(Code { severity: "2".parse::().unwrap(), category: "4".parse::().unwrap(), @@ -518,7 +518,7 @@ mod test { vec!["me".to_string(), "8BITMIME".to_string(), "SIZE 42".to_string()]) - .has_code(251)); + .has_code(251)); } #[test] @@ -531,7 +531,7 @@ mod test { vec!["me".to_string(), "8BITMIME".to_string(), "SIZE 42".to_string()]) - .first_word(), + .first_word(), Some("me".to_string())); assert_eq!(Response::new(Code { severity: "2".parse::().unwrap(), @@ -541,7 +541,7 @@ mod test { vec!["me mo".to_string(), "8BITMIME".to_string(), "SIZE 42".to_string()]) - .first_word(), + .first_word(), Some("me".to_string())); assert_eq!(Response::new(Code { severity: "2".parse::().unwrap(), @@ -549,7 +549,7 @@ mod test { detail: 1, }, vec![]) - .first_word(), + .first_word(), None); assert_eq!(Response::new(Code { severity: "2".parse::().unwrap(), @@ -557,7 +557,7 @@ mod test { detail: 1, }, vec![" ".to_string()]) - .first_word(), + .first_word(), None); assert_eq!(Response::new(Code { severity: "2".parse::().unwrap(), @@ -565,7 +565,7 @@ mod test { detail: 1, }, vec![" ".to_string()]) - .first_word(), + .first_word(), None); assert_eq!(Response::new(Code { severity: "2".parse::().unwrap(), @@ -573,7 +573,7 @@ mod test { detail: 1, }, vec!["".to_string()]) - .first_word(), + .first_word(), None); } } diff --git a/lettre_email/src/email.rs b/lettre_email/src/email.rs index 56291c6..773482f 100644 --- a/lettre_email/src/email.rs +++ b/lettre_email/src/email.rs @@ -108,7 +108,7 @@ impl IntoEmail for SimpleEmail { /// Simple representation of an email, useful for some transports -#[derive(PartialEq,Eq,Clone,Debug,Default)] +#[derive(PartialEq, Eq, Clone, Debug, Default)] pub struct SimpleEmail { from: Option, to: Vec, @@ -236,14 +236,14 @@ impl SimpleEmail { } /// Builds a `MimeMessage` structure -#[derive(PartialEq,Eq,Clone,Debug)] +#[derive(PartialEq, Eq, Clone, Debug)] pub struct PartBuilder { /// Message message: MimeMessage, } /// Builds an `Email` structure -#[derive(PartialEq,Eq,Clone,Debug)] +#[derive(PartialEq, Eq, Clone, Debug)] pub struct EmailBuilder { /// Message message: PartBuilder, @@ -266,7 +266,7 @@ pub struct EmailBuilder { } /// Simple email enveloppe representation -#[derive(PartialEq,Eq,Clone,Debug,Default)] +#[derive(PartialEq, Eq, Clone, Debug, Default)] pub struct Envelope { /// The envelope recipients' addresses pub to: Vec, @@ -303,7 +303,7 @@ impl Envelope { } /// Simple email representation -#[derive(PartialEq,Eq,Clone,Debug)] +#[derive(PartialEq, Eq, Clone, Debug)] pub struct Email { /// Message message: MimeMessage, @@ -828,7 +828,7 @@ mod test { .headers .insert(Header::new_with_value("Message-ID".to_string(), format!("<{}@rust-smtp>", current_message)) - .unwrap()); + .unwrap()); email .message