From 7aac0458564da5c63f9d20457bb578bf6b4d1a19 Mon Sep 17 00:00:00 2001 From: Alexis Mousset Date: Fri, 14 Nov 2014 02:18:36 +0100 Subject: [PATCH] Code formatting --- examples/client.rs | 7 ++++--- src/client/mod.rs | 15 ++++++++------- src/command.rs | 7 +++++-- src/lib.rs | 8 ++++---- 4 files changed, 21 insertions(+), 16 deletions(-) diff --git a/examples/client.rs b/examples/client.rs index 51c0680..78cb083 100644 --- a/examples/client.rs +++ b/examples/client.rs @@ -50,9 +50,10 @@ fn main() { let program = args[0].clone(); let description = format!("Usage: {0} [options...] recipients\n\n\ - This program reads a message on standard input until it reaches EOF,\ - then tries to send it using the given paramters.\n\n\ - Example: {0} -r user@example.org user@example.com < message.txt", program); + This program reads a message on standard input until it reaches\ + EOF, then tries to send it using the given paramters.\n\n\ + Example: {0} -r user@example.org user@example.com < message.txt", + program); let opts = [ optopt("r", "reverse-path", "set the sender address", "FROM_ADDRESS"), diff --git a/src/client/mod.rs b/src/client/mod.rs index b706a68..4eea89f 100644 --- a/src/client/mod.rs +++ b/src/client/mod.rs @@ -66,7 +66,9 @@ macro_rules! fail_with_err ( macro_rules! check_command_sequence ( ($command: ident $client: ident) => ({ if !$client.state.is_command_allowed(&$command) { - fail_with_err!(Response{code: 503, message: Some("Bad sequence of commands".to_string())} $client); + fail_with_err!( + Response{code: 503, message: Some("Bad sequence of commands".to_string())} $client + ); } }) ) @@ -98,7 +100,6 @@ impl Client { /// Sends an email pub fn send_mail(&mut self, from_address: &str, to_addresses: &[&str], message: &str) -> SmtpResult { - // Connect to the server try!(self.connect()); @@ -199,7 +200,7 @@ impl Client { ), None => self.stream.as_mut().unwrap().send_and_get_response( command.to_string().as_slice(), CRLF - ) + ), }); let checked_result = try!(command.test_success(result)); @@ -244,7 +245,7 @@ impl Client { name: get_first_word(result.message.as_ref().unwrap().as_slice()).to_string(), esmtp_features: Extension::parse_esmtp_response( result.message.as_ref().unwrap().as_slice() - ) + ), } ); Ok(result) @@ -257,7 +258,7 @@ impl Client { Some(info) => info, None => fail_with_err!(Response{ code: 503, - message: Some("Bad sequence of commands".to_string()) + message: Some("Bad sequence of commands".to_string()), } self), }; @@ -292,7 +293,7 @@ impl Client { Some(info) => info, None => fail_with_err!(Response{ code: 503, - message: Some("Bad sequence of commands".to_string()) + message: Some("Bad sequence of commands".to_string()), } self) }; @@ -308,7 +309,7 @@ impl Client { Some(extension::Size(max)) if message_content.len() > max => fail_with_err!(Response{ code: 552, - message: Some("Message exceeds fixed maximum message size".to_string()) + message: Some("Message exceeds fixed maximum message size".to_string()), } self), _ => () }; diff --git a/src/command.rs b/src/command.rs index 826b49d..a1c2323 100644 --- a/src/command.rs +++ b/src/command.rs @@ -157,10 +157,13 @@ mod test { assert!(super::ExtendedHello("my_name".to_string()).is_ascii()); assert!(!super::ExtendedHello("my_namé".to_string()).is_ascii()); assert!( - super::Mail("test".to_string(), Some(vec!["option".to_string(), "option2".to_string()])) + super::Mail("test".to_string(), Some(vec!["test".to_string(), "test".to_string()])) .is_ascii()); assert!( - !super::Mail("test".to_string(), Some(vec!["option".to_string(), "option2à".to_string()])) + !super::Mail("test".to_string(), Some(vec!["est".to_string(), "testà".to_string()])) + .is_ascii()); + assert!( + !super::Mail("testé".to_string(), Some(vec!["est".to_string(), "test".to_string()])) .is_ascii()); } } diff --git a/src/lib.rs b/src/lib.rs index 3943890..ac267af 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -9,10 +9,10 @@ //! # Rust SMTP library //! -//! The client does its best to follow [RFC 5321](https://tools.ietf.org/html/rfc5321), but is still +//! The client should tend to follow [RFC 5321](https://tools.ietf.org/html/rfc5321), but is still //! a work in progress. //! -//! It will eventually implement the following extensions : +//! It may eventually implement the following extensions : //! //! * 8BITMIME ([RFC 6152](https://tools.ietf.org/html/rfc6152)) //! * SMTPUTF8 ([RFC 6531](http://tools.ietf.org/html/rfc6531)) @@ -36,9 +36,9 @@ //! Some("myhost"), // my hostname (default is localhost) //! ); //! let result = email_client.send_mail::( -//! "user@example.com", // sender (reverse-path) +//! "user@example.com", // sender (reverse-path) //! ["user@example.org"], // recipient list -//! "Test email", // email content +//! "Test email", // email content //! ); //! ``` //!