style(all): Run rustfmt and clippy

This commit is contained in:
Alexis Mousset
2018-05-28 23:46:05 +02:00
parent c52c28ab80
commit 7f545301e1
16 changed files with 39 additions and 33 deletions

View File

@@ -3,9 +3,9 @@
extern crate lettre;
extern crate test;
use lettre::smtp::ConnectionReuseParameters;
use lettre::{ClientSecurity, Envelope, SmtpTransport};
use lettre::{EmailAddress, SendableEmail, Transport};
use lettre::smtp::ConnectionReuseParameters;
#[bench]
fn bench_simple_send(b: &mut test::Bencher) {

View File

@@ -3,9 +3,9 @@
//! It can be useful for testing purposes, or if you want to keep track of sent messages.
//!
use Transport;
use Envelope;
use SendableEmail;
use Transport;
use file::error::FileResult;
use serde_json;
use std::fs::File;

View File

@@ -27,27 +27,27 @@ extern crate serde_derive;
#[cfg(feature = "file-transport")]
extern crate serde_json;
#[cfg(feature = "smtp-transport")]
pub mod smtp;
#[cfg(feature = "sendmail-transport")]
pub mod sendmail;
pub mod stub;
#[cfg(feature = "file-transport")]
pub mod file;
#[cfg(feature = "sendmail-transport")]
pub mod sendmail;
#[cfg(feature = "smtp-transport")]
pub mod smtp;
pub mod stub;
#[cfg(feature = "file-transport")]
pub use file::FileTransport;
#[cfg(feature = "sendmail-transport")]
pub use sendmail::SendmailTransport;
#[cfg(feature = "smtp-transport")]
pub use smtp::{ClientSecurity, SmtpClient, SmtpTransport};
#[cfg(feature = "smtp-transport")]
pub use smtp::client::net::ClientTlsParameters;
use std::fmt::{self, Display, Formatter};
use std::io::Read;
use std::io::Cursor;
use std::io;
#[cfg(feature = "smtp-transport")]
pub use smtp::{ClientSecurity, SmtpClient, SmtpTransport};
use std::error::Error as StdError;
use std::fmt::{self, Display, Formatter};
use std::io;
use std::io::Cursor;
use std::io::Read;
use std::str::FromStr;
/// Error type for email content

View File

@@ -1,8 +1,8 @@
//! The sendmail transport sends the email using the local sendmail command.
//!
use Transport;
use SendableEmail;
use Transport;
use sendmail::error::SendmailResult;
use std::io::Read;
use std::io::prelude::*;

View File

@@ -40,7 +40,10 @@ pub struct Credentials {
impl Credentials {
/// Create a `Credentials` struct from username and password
pub fn new(username: String, password: String) -> Credentials {
Credentials { authentication_identity: username, secret: password }
Credentials {
authentication_identity: username,
secret: password,
}
}
}
@@ -113,7 +116,7 @@ impl Mechanism {
}
Err(Error::Client("Unrecognized challenge"))
},
}
Mechanism::Xoauth2 => match challenge {
Some(_) => Err(Error::Client("This mechanism does not expect a challenge")),
None => Ok(format!(
@@ -163,7 +166,10 @@ mod test {
fn test_xoauth2() {
let mechanism = Mechanism::Xoauth2;
let credentials = Credentials::new("username".to_string(), "vF9dft4qmTc2Nvb3RlckBhdHRhdmlzdGEuY29tCg==".to_string());
let credentials = Credentials::new(
"username".to_string(),
"vF9dft4qmTc2Nvb3RlckBhdHRhdmlzdGEuY29tCg==".to_string(),
);
assert_eq!(
mechanism.response(&credentials, None).unwrap(),

View File

@@ -13,8 +13,8 @@ use std::net::ToSocketAddrs;
use std::string::String;
use std::time::Duration;
pub mod net;
pub mod mock;
pub mod net;
/// The codec used for transparency
#[derive(Default, Clone, Copy, Debug)]
@@ -218,7 +218,7 @@ impl<S: Connector + Write + Read + Timeout + Debug> InnerClient<S> {
self.write(out_buf.as_slice())?;
}
self.write("\r\n.\r\n".as_bytes())?;
self.write(b"\r\n.\r\n")?;
self.read_response()
}

View File

@@ -4,8 +4,8 @@ use EmailAddress;
use base64;
use smtp::authentication::{Credentials, Mechanism};
use smtp::error::Error;
use smtp::extension::{MailParameter, RcptParameter};
use smtp::extension::ClientId;
use smtp::extension::{MailParameter, RcptParameter};
use smtp::response::Response;
use std::fmt::{self, Display, Formatter};

View File

@@ -13,7 +13,6 @@
//! * SMTPUTF8 ([RFC 6531](http://tools.ietf.org/html/rfc6531))
//!
use {SendableEmail, Transport};
use native_tls::TlsConnector;
use smtp::authentication::{Credentials, Mechanism, DEFAULT_ENCRYPTED_MECHANISMS,
DEFAULT_UNENCRYPTED_MECHANISMS};
@@ -25,13 +24,14 @@ use smtp::error::{Error, SmtpResult};
use smtp::extension::{ClientId, Extension, MailBodyParameter, MailParameter, ServerInfo};
use std::net::{SocketAddr, ToSocketAddrs};
use std::time::Duration;
use {SendableEmail, Transport};
pub mod extension;
pub mod commands;
pub mod authentication;
pub mod response;
pub mod client;
pub mod commands;
pub mod error;
pub mod extension;
pub mod response;
pub mod util;
// Registered port numbers:
@@ -404,7 +404,7 @@ impl<'a> Transport<'a> for SmtpTransport {
for to_address in email.envelope().to() {
try_smtp!(
self.client
.command(RcptCommand::new(to_address.clone(), vec![]),),
.command(RcptCommand::new(to_address.clone(), vec![])),
self
);
// Log the rcpt command

View File

@@ -1,8 +1,8 @@
//! SMTP response, containing a mandatory return code and an optional text
//! message
use nom::{crlf, ErrorKind as NomErrorKind, IResult as NomResult};
use nom::simple_errors::Err as NomError;
use nom::{crlf, ErrorKind as NomErrorKind, IResult as NomResult};
use std::fmt::{Display, Formatter, Result};
use std::result;
use std::str::{FromStr, from_utf8};

View File

@@ -2,8 +2,8 @@
//! testing purposes.
//!
use Transport;
use SendableEmail;
use Transport;
/// This transport logs the message envelope and returns the given response
#[derive(Debug, Clone, Copy)]

View File

@@ -1,8 +1,8 @@
extern crate glob;
use self::glob::glob;
use std::env::consts::EXE_EXTENSION;
use std::env;
use std::env::consts::EXE_EXTENSION;
use std::path::Path;
use std::process::Command;

View File

@@ -4,8 +4,8 @@ extern crate lettre;
#[cfg(feature = "file-transport")]
mod test {
use lettre::{EmailAddress, Envelope, SendableEmail, Transport};
use lettre::file::FileTransport;
use lettre::{EmailAddress, Envelope, SendableEmail, Transport};
use std::env::temp_dir;
use std::fs::File;
use std::fs::remove_file;

View File

@@ -3,8 +3,8 @@ extern crate lettre;
#[cfg(test)]
#[cfg(feature = "sendmail-transport")]
mod test {
use lettre::{EmailAddress, Envelope, SendableEmail, Transport};
use lettre::sendmail::SendmailTransport;
use lettre::{EmailAddress, Envelope, SendableEmail, Transport};
#[test]
fn sendmail_transport_simple() {

View File

@@ -1,7 +1,7 @@
extern crate lettre;
use lettre::{EmailAddress, Envelope, SendableEmail, Transport};
use lettre::stub::StubTransport;
use lettre::{EmailAddress, Envelope, SendableEmail, Transport};
#[test]
fn stub_transport() {

View File

@@ -22,9 +22,9 @@ use mime::Mime;
use std::fs::File;
use std::io::Read;
use std::path::Path;
use std::str::FromStr;
use time::{now, Tm};
use uuid::Uuid;
use std::str::FromStr;
/// Builds a `MimeMessage` structure
#[derive(PartialEq, Eq, Clone, Debug)]

View File

@@ -1,8 +1,8 @@
extern crate glob;
use self::glob::glob;
use std::env::consts::EXE_EXTENSION;
use std::env;
use std::env::consts::EXE_EXTENSION;
use std::path::Path;
use std::process::Command;