style(all): Run last rustfmt

This commit is contained in:
Alexis Mousset
2017-06-14 00:48:32 +02:00
parent bcf2110804
commit 3b46c56bbd
9 changed files with 53 additions and 54 deletions

View File

@@ -40,7 +40,7 @@ pub trait EmailTransport<U> {
}
/// Minimal email structure
#[derive(Debug,Clone)]
#[derive(Debug, Clone)]
pub struct SimpleSendableEmail {
/// To
to: Vec<String>,

View File

@@ -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,
}

View File

@@ -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

View File

@@ -6,7 +6,7 @@ use std::sync::{Arc, Mutex};
pub type MockCursor = Cursor<Vec<u8>>;
#[derive(Clone,Debug)]
#[derive(Clone, Debug)]
pub struct MockStream {
reader: Arc<Mutex<MockCursor>>,
writer: Arc<Mutex<MockCursor>>,

View File

@@ -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<S: Connector + Write + Read + Timeout + Debug> Client<S> {
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<S: Connector + Write + Read + Timeout + Debug> Client<S> {
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) {

View File

@@ -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
///

View File

@@ -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<SmtpResult> 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));

View File

@@ -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<Code>,
@@ -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::<Severity>().unwrap(),
category: "4".parse::<Category>().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::<Severity>().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::<Severity>().unwrap(),
category: "4".parse::<Category>().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::<Severity>().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::<Severity>().unwrap(),
@@ -549,7 +549,7 @@ mod test {
detail: 1,
},
vec![])
.first_word(),
.first_word(),
None);
assert_eq!(Response::new(Code {
severity: "2".parse::<Severity>().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::<Severity>().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::<Severity>().unwrap(),
@@ -573,7 +573,7 @@ mod test {
detail: 1,
},
vec!["".to_string()])
.first_word(),
.first_word(),
None);
}
}

View File

@@ -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<Mailbox>,
to: Vec<Mailbox>,
@@ -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<String>,
@@ -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