style(all): Run rustfmt and clippy
This commit is contained in:
@@ -3,9 +3,9 @@
|
|||||||
extern crate lettre;
|
extern crate lettre;
|
||||||
extern crate test;
|
extern crate test;
|
||||||
|
|
||||||
|
use lettre::smtp::ConnectionReuseParameters;
|
||||||
use lettre::{ClientSecurity, Envelope, SmtpTransport};
|
use lettre::{ClientSecurity, Envelope, SmtpTransport};
|
||||||
use lettre::{EmailAddress, SendableEmail, Transport};
|
use lettre::{EmailAddress, SendableEmail, Transport};
|
||||||
use lettre::smtp::ConnectionReuseParameters;
|
|
||||||
|
|
||||||
#[bench]
|
#[bench]
|
||||||
fn bench_simple_send(b: &mut test::Bencher) {
|
fn bench_simple_send(b: &mut test::Bencher) {
|
||||||
|
|||||||
@@ -3,9 +3,9 @@
|
|||||||
//! It can be useful for testing purposes, or if you want to keep track of sent messages.
|
//! It can be useful for testing purposes, or if you want to keep track of sent messages.
|
||||||
//!
|
//!
|
||||||
|
|
||||||
use Transport;
|
|
||||||
use Envelope;
|
use Envelope;
|
||||||
use SendableEmail;
|
use SendableEmail;
|
||||||
|
use Transport;
|
||||||
use file::error::FileResult;
|
use file::error::FileResult;
|
||||||
use serde_json;
|
use serde_json;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
|
|||||||
@@ -27,27 +27,27 @@ extern crate serde_derive;
|
|||||||
#[cfg(feature = "file-transport")]
|
#[cfg(feature = "file-transport")]
|
||||||
extern crate serde_json;
|
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")]
|
#[cfg(feature = "file-transport")]
|
||||||
pub mod file;
|
pub mod file;
|
||||||
|
#[cfg(feature = "sendmail-transport")]
|
||||||
|
pub mod sendmail;
|
||||||
|
#[cfg(feature = "smtp-transport")]
|
||||||
|
pub mod smtp;
|
||||||
|
pub mod stub;
|
||||||
|
|
||||||
#[cfg(feature = "file-transport")]
|
#[cfg(feature = "file-transport")]
|
||||||
pub use file::FileTransport;
|
pub use file::FileTransport;
|
||||||
#[cfg(feature = "sendmail-transport")]
|
#[cfg(feature = "sendmail-transport")]
|
||||||
pub use sendmail::SendmailTransport;
|
pub use sendmail::SendmailTransport;
|
||||||
#[cfg(feature = "smtp-transport")]
|
#[cfg(feature = "smtp-transport")]
|
||||||
pub use smtp::{ClientSecurity, SmtpClient, SmtpTransport};
|
|
||||||
#[cfg(feature = "smtp-transport")]
|
|
||||||
pub use smtp::client::net::ClientTlsParameters;
|
pub use smtp::client::net::ClientTlsParameters;
|
||||||
use std::fmt::{self, Display, Formatter};
|
#[cfg(feature = "smtp-transport")]
|
||||||
use std::io::Read;
|
pub use smtp::{ClientSecurity, SmtpClient, SmtpTransport};
|
||||||
use std::io::Cursor;
|
|
||||||
use std::io;
|
|
||||||
use std::error::Error as StdError;
|
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;
|
use std::str::FromStr;
|
||||||
|
|
||||||
/// Error type for email content
|
/// Error type for email content
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
//! The sendmail transport sends the email using the local sendmail command.
|
//! The sendmail transport sends the email using the local sendmail command.
|
||||||
//!
|
//!
|
||||||
|
|
||||||
use Transport;
|
|
||||||
use SendableEmail;
|
use SendableEmail;
|
||||||
|
use Transport;
|
||||||
use sendmail::error::SendmailResult;
|
use sendmail::error::SendmailResult;
|
||||||
use std::io::Read;
|
use std::io::Read;
|
||||||
use std::io::prelude::*;
|
use std::io::prelude::*;
|
||||||
|
|||||||
@@ -40,7 +40,10 @@ pub struct Credentials {
|
|||||||
impl Credentials {
|
impl Credentials {
|
||||||
/// Create a `Credentials` struct from username and password
|
/// Create a `Credentials` struct from username and password
|
||||||
pub fn new(username: String, password: String) -> Credentials {
|
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"))
|
Err(Error::Client("Unrecognized challenge"))
|
||||||
},
|
}
|
||||||
Mechanism::Xoauth2 => match challenge {
|
Mechanism::Xoauth2 => match challenge {
|
||||||
Some(_) => Err(Error::Client("This mechanism does not expect a challenge")),
|
Some(_) => Err(Error::Client("This mechanism does not expect a challenge")),
|
||||||
None => Ok(format!(
|
None => Ok(format!(
|
||||||
@@ -163,7 +166,10 @@ mod test {
|
|||||||
fn test_xoauth2() {
|
fn test_xoauth2() {
|
||||||
let mechanism = Mechanism::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!(
|
assert_eq!(
|
||||||
mechanism.response(&credentials, None).unwrap(),
|
mechanism.response(&credentials, None).unwrap(),
|
||||||
|
|||||||
@@ -13,8 +13,8 @@ use std::net::ToSocketAddrs;
|
|||||||
use std::string::String;
|
use std::string::String;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
pub mod net;
|
|
||||||
pub mod mock;
|
pub mod mock;
|
||||||
|
pub mod net;
|
||||||
|
|
||||||
/// The codec used for transparency
|
/// The codec used for transparency
|
||||||
#[derive(Default, Clone, Copy, Debug)]
|
#[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(out_buf.as_slice())?;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.write("\r\n.\r\n".as_bytes())?;
|
self.write(b"\r\n.\r\n")?;
|
||||||
self.read_response()
|
self.read_response()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ use EmailAddress;
|
|||||||
use base64;
|
use base64;
|
||||||
use smtp::authentication::{Credentials, Mechanism};
|
use smtp::authentication::{Credentials, Mechanism};
|
||||||
use smtp::error::Error;
|
use smtp::error::Error;
|
||||||
use smtp::extension::{MailParameter, RcptParameter};
|
|
||||||
use smtp::extension::ClientId;
|
use smtp::extension::ClientId;
|
||||||
|
use smtp::extension::{MailParameter, RcptParameter};
|
||||||
use smtp::response::Response;
|
use smtp::response::Response;
|
||||||
use std::fmt::{self, Display, Formatter};
|
use std::fmt::{self, Display, Formatter};
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,6 @@
|
|||||||
//! * SMTPUTF8 ([RFC 6531](http://tools.ietf.org/html/rfc6531))
|
//! * SMTPUTF8 ([RFC 6531](http://tools.ietf.org/html/rfc6531))
|
||||||
//!
|
//!
|
||||||
|
|
||||||
use {SendableEmail, Transport};
|
|
||||||
use native_tls::TlsConnector;
|
use native_tls::TlsConnector;
|
||||||
use smtp::authentication::{Credentials, Mechanism, DEFAULT_ENCRYPTED_MECHANISMS,
|
use smtp::authentication::{Credentials, Mechanism, DEFAULT_ENCRYPTED_MECHANISMS,
|
||||||
DEFAULT_UNENCRYPTED_MECHANISMS};
|
DEFAULT_UNENCRYPTED_MECHANISMS};
|
||||||
@@ -25,13 +24,14 @@ use smtp::error::{Error, SmtpResult};
|
|||||||
use smtp::extension::{ClientId, Extension, MailBodyParameter, MailParameter, ServerInfo};
|
use smtp::extension::{ClientId, Extension, MailBodyParameter, MailParameter, ServerInfo};
|
||||||
use std::net::{SocketAddr, ToSocketAddrs};
|
use std::net::{SocketAddr, ToSocketAddrs};
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
use {SendableEmail, Transport};
|
||||||
|
|
||||||
pub mod extension;
|
|
||||||
pub mod commands;
|
|
||||||
pub mod authentication;
|
pub mod authentication;
|
||||||
pub mod response;
|
|
||||||
pub mod client;
|
pub mod client;
|
||||||
|
pub mod commands;
|
||||||
pub mod error;
|
pub mod error;
|
||||||
|
pub mod extension;
|
||||||
|
pub mod response;
|
||||||
pub mod util;
|
pub mod util;
|
||||||
|
|
||||||
// Registered port numbers:
|
// Registered port numbers:
|
||||||
@@ -404,7 +404,7 @@ impl<'a> Transport<'a> for SmtpTransport {
|
|||||||
for to_address in email.envelope().to() {
|
for to_address in email.envelope().to() {
|
||||||
try_smtp!(
|
try_smtp!(
|
||||||
self.client
|
self.client
|
||||||
.command(RcptCommand::new(to_address.clone(), vec![]),),
|
.command(RcptCommand::new(to_address.clone(), vec![])),
|
||||||
self
|
self
|
||||||
);
|
);
|
||||||
// Log the rcpt command
|
// Log the rcpt command
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
//! SMTP response, containing a mandatory return code and an optional text
|
//! SMTP response, containing a mandatory return code and an optional text
|
||||||
//! message
|
//! message
|
||||||
|
|
||||||
use nom::{crlf, ErrorKind as NomErrorKind, IResult as NomResult};
|
|
||||||
use nom::simple_errors::Err as NomError;
|
use nom::simple_errors::Err as NomError;
|
||||||
|
use nom::{crlf, ErrorKind as NomErrorKind, IResult as NomResult};
|
||||||
use std::fmt::{Display, Formatter, Result};
|
use std::fmt::{Display, Formatter, Result};
|
||||||
use std::result;
|
use std::result;
|
||||||
use std::str::{FromStr, from_utf8};
|
use std::str::{FromStr, from_utf8};
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
//! testing purposes.
|
//! testing purposes.
|
||||||
//!
|
//!
|
||||||
|
|
||||||
use Transport;
|
|
||||||
use SendableEmail;
|
use SendableEmail;
|
||||||
|
use Transport;
|
||||||
|
|
||||||
/// This transport logs the message envelope and returns the given response
|
/// This transport logs the message envelope and returns the given response
|
||||||
#[derive(Debug, Clone, Copy)]
|
#[derive(Debug, Clone, Copy)]
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
extern crate glob;
|
extern crate glob;
|
||||||
|
|
||||||
use self::glob::glob;
|
use self::glob::glob;
|
||||||
use std::env::consts::EXE_EXTENSION;
|
|
||||||
use std::env;
|
use std::env;
|
||||||
|
use std::env::consts::EXE_EXTENSION;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
|
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ extern crate lettre;
|
|||||||
#[cfg(feature = "file-transport")]
|
#[cfg(feature = "file-transport")]
|
||||||
mod test {
|
mod test {
|
||||||
|
|
||||||
use lettre::{EmailAddress, Envelope, SendableEmail, Transport};
|
|
||||||
use lettre::file::FileTransport;
|
use lettre::file::FileTransport;
|
||||||
|
use lettre::{EmailAddress, Envelope, SendableEmail, Transport};
|
||||||
use std::env::temp_dir;
|
use std::env::temp_dir;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::fs::remove_file;
|
use std::fs::remove_file;
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ extern crate lettre;
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
#[cfg(feature = "sendmail-transport")]
|
#[cfg(feature = "sendmail-transport")]
|
||||||
mod test {
|
mod test {
|
||||||
use lettre::{EmailAddress, Envelope, SendableEmail, Transport};
|
|
||||||
use lettre::sendmail::SendmailTransport;
|
use lettre::sendmail::SendmailTransport;
|
||||||
|
use lettre::{EmailAddress, Envelope, SendableEmail, Transport};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn sendmail_transport_simple() {
|
fn sendmail_transport_simple() {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
extern crate lettre;
|
extern crate lettre;
|
||||||
|
|
||||||
use lettre::{EmailAddress, Envelope, SendableEmail, Transport};
|
|
||||||
use lettre::stub::StubTransport;
|
use lettre::stub::StubTransport;
|
||||||
|
use lettre::{EmailAddress, Envelope, SendableEmail, Transport};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn stub_transport() {
|
fn stub_transport() {
|
||||||
|
|||||||
@@ -22,9 +22,9 @@ use mime::Mime;
|
|||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::Read;
|
use std::io::Read;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
use std::str::FromStr;
|
||||||
use time::{now, Tm};
|
use time::{now, Tm};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
use std::str::FromStr;
|
|
||||||
|
|
||||||
/// Builds a `MimeMessage` structure
|
/// Builds a `MimeMessage` structure
|
||||||
#[derive(PartialEq, Eq, Clone, Debug)]
|
#[derive(PartialEq, Eq, Clone, Debug)]
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
extern crate glob;
|
extern crate glob;
|
||||||
|
|
||||||
use self::glob::glob;
|
use self::glob::glob;
|
||||||
use std::env::consts::EXE_EXTENSION;
|
|
||||||
use std::env;
|
use std::env;
|
||||||
|
use std::env::consts::EXE_EXTENSION;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user