Formatting with rustfmt

This commit is contained in:
Alexis Mousset
2015-10-22 16:45:43 +02:00
parent 88b9cfb847
commit d3d7c4b44e
6 changed files with 34 additions and 23 deletions

View File

@@ -165,10 +165,10 @@ impl EmailBuilder {
/// Build the Email
pub fn build(mut self) -> Result<Email, &'static str> {
if self.from.is_none() {
return Err("No from address")
return Err("No from address");
}
if self.to.is_empty() {
return Err("No to address")
return Err("No to address");
}
if !self.date_issued {

View File

@@ -1,14 +1,18 @@
//! # Rust email client
//!
//! This client should tend to follow [RFC 5321](https://tools.ietf.org/html/rfc5321), but is still
//! a work in progress. It is designed to efficiently send emails from an application to a
//! relay email server, as it relies as much as possible on the relay server for sanity and RFC
//! This client should tend to follow [RFC
//! 5321](https://tools.ietf.org/html/rfc5321), but is still
//! a work in progress. It is designed to efficiently send emails from an
//! application to a
//! relay email server, as it relies as much as possible on the relay server
//! for sanity and RFC
//! compliance checks.
//!
//! It implements the following extensions:
//!
//! * 8BITMIME ([RFC 6152](https://tools.ietf.org/html/rfc6152))
//! * AUTH ([RFC 4954](http://tools.ietf.org/html/rfc4954)) with PLAIN and CRAM-MD5 mecanisms
//! * AUTH ([RFC 4954](http://tools.ietf.org/html/rfc4954)) with PLAIN and
//! CRAM-MD5 mecanisms
//! * STARTTLS ([RFC 2487](http://tools.ietf.org/html/rfc2487))
//! * SMTPUTF8 ([RFC 6531](http://tools.ietf.org/html/rfc6531))
//!
@@ -43,7 +47,8 @@
//! .build().unwrap();
//!
//! // Open a local connection on port 25
//! let mut mailer = Mailer::new(SmtpTransportBuilder::localhost().unwrap().build());
//! let mut mailer =
//! Mailer::new(SmtpTransportBuilder::localhost().unwrap().build());
//! // Send the email
//! let result = mailer.send(email);
//!
@@ -54,7 +59,8 @@
//!
//! ```rust,no_run
//! use lettre::email::EmailBuilder;
//! use lettre::transport::smtp::{SecurityLevel, SmtpTransport, SmtpTransportBuilder};
//! use lettre::transport::smtp::{SecurityLevel, SmtpTransport,
//! SmtpTransportBuilder};
//! use lettre::transport::smtp::authentication::Mecanism;
//! use lettre::transport::smtp::SUBMISSION_PORT;
//! use lettre::transport::EmailTransport;
@@ -74,7 +80,8 @@
//! let email = builder.build().unwrap();
//!
//! // Connect to a remote server on a custom port
//! let mut mailer = Mailer::new(SmtpTransportBuilder::new(("server.tld", SUBMISSION_PORT)).unwrap()
//! let mut mailer = Mailer::new(SmtpTransportBuilder::new(("server.tld",
//! SUBMISSION_PORT)).unwrap()
//! // Set the name sent during EHLO/HELO, default is `localhost`
//! .hello_name("my.hostname.tld")
//! // Add credentials for authentication
@@ -117,14 +124,16 @@
//! "Hello world !"
//! );
//!
//! let mut mailer = Mailer::new(SmtpTransportBuilder::localhost().unwrap().build());
//! let mut mailer =
//! Mailer::new(SmtpTransportBuilder::localhost().unwrap().build());
//! let result = mailer.send(email);
//! assert!(result.is_ok());
//! ```
//!
//! ### Lower level
//!
//! You can also send commands, here is a simple email transaction without error handling:
//! You can also send commands, here is a simple email transaction without
//! error handling:
//!
//! ```rust,no_run
//! use lettre::transport::smtp::SMTP_PORT;

View File

@@ -86,5 +86,5 @@ pub type EmailResult = Result<Response, Error>;
#[cfg(test)]
mod test {
// TODO
// TODO
}

View File

@@ -80,7 +80,6 @@ impl<S: Connector + Write + Read + Debug + Clone = NetworkStream> Client<S> {
/// Upgrades the underlying connection to SSL/TLS
pub fn upgrade_tls_stream(&mut self, ssl_context: &SslContext) -> io::Result<()> {
//let current_stream = self.stream.clone();
if self.stream.is_some() {
self.stream.as_mut().unwrap().get_mut().upgrade_tls(ssl_context)
} else {

View File

@@ -18,7 +18,8 @@ pub mod response;
pub mod client;
// Registrated port numbers:
// https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml
// https://www.iana.
// org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml
/// Default smtp port
pub static SMTP_PORT: u16 = 25;
@@ -257,7 +258,8 @@ impl EmailTransport for SmtpTransport {
}
}
// If there is a usable connection, test if the server answers and hello has been sent
// If there is a usable connection, test if the server answers and hello has
// been sent
if self.state.connection_reuse_count == 0 {
try!(self.client.connect(&self.client_info.server_addr));
@@ -305,13 +307,13 @@ impl EmailTransport for SmtpTransport {
// Mail
let mail_options = match (self.server_info
.as_ref()
.unwrap()
.supports_feature(&Extension::EightBitMime),
self.server_info
.as_ref()
.unwrap()
.supports_feature(&Extension::EightBitMime)) {
.as_ref()
.unwrap()
.supports_feature(&Extension::EightBitMime),
self.server_info
.as_ref()
.unwrap()
.supports_feature(&Extension::EightBitMime)) {
(true, true) => Some("BODY=8BITMIME SMTPUTF8"),
(true, false) => Some("BODY=8BITMIME"),
(false, _) => None,

View File

@@ -1,4 +1,5 @@
//! SMTP response, containing a mandatory return code and an optional text message
//! SMTP response, containing a mandatory return code and an optional text
//! message
use std::str::FromStr;
use std::fmt::{Display, Formatter, Result};