From 156bea5f75672cc16a05af088c44bd8be410e2c6 Mon Sep 17 00:00:00 2001 From: Alexis Mousset Date: Mon, 2 Mar 2015 15:00:50 +0100 Subject: [PATCH] Update documentation --- Cargo.toml | 11 ++++------- src/client/authentication.rs | 0 src/client/mod.rs | 10 +++------- src/error.rs | 10 +++++----- src/extension.rs | 1 - src/lib.rs | 13 +++---------- 6 files changed, 15 insertions(+), 30 deletions(-) create mode 100644 src/client/authentication.rs diff --git a/Cargo.toml b/Cargo.toml index 96e640e..06e43ca 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,16 +2,13 @@ name = "smtp" version = "0.0.7" -authors = ["Alexis Mousset "] -description = "Simple SMTP client and library" - +description = "Simple SMTP client" +readme = "README.md" documentation = "http://amousset.github.io/rust-smtp/smtp/" repository = "https://github.com/amousset/rust-smtp" - license = "MIT/Apache-2.0" -readme = "README.md" - -keywords = ["email", "smtp"] +authors = ["Alexis Mousset "] +keywords = ["email", "smtp", "mailer"] [dependencies] time = "*" diff --git a/src/client/authentication.rs b/src/client/authentication.rs new file mode 100644 index 0000000..e69de29 diff --git a/src/client/mod.rs b/src/client/mod.rs index b63c3e6..41eb4e1 100644 --- a/src/client/mod.rs +++ b/src/client/mod.rs @@ -129,7 +129,7 @@ impl Client { pub fn new(addr: A) -> Client { Client{ stream: None, - server_addr: addr.to_socket_addr().unwrap(), + server_addr: addr.to_socket_addr().ok().expect("could not parse server address"), server_info: None, configuration: Configuration { connection_reuse_count_limit: 100, @@ -232,7 +232,6 @@ impl Client { if self.credentials.is_some() && self.state.connection_reuse_count == 0 { let credentials = self.credentials.clone().unwrap(); if self.server_info.as_ref().unwrap().supports_feature(Extension::CramMd5Authentication).is_some() { - let result = self.auth_cram_md5(credentials.username.as_slice(), credentials.password.as_slice()); try_smtp!(result, self); @@ -260,8 +259,6 @@ impl Client { info!("{}: from=<{}>", current_message, from_address); // Recipient - // TODO Return rejected addresses - // TODO Limit the number of recipients for to_address in to_addresses.iter() { try_smtp!(self.rcpt(to_address.as_slice()), self); // Log the rcpt command @@ -285,7 +282,7 @@ impl Client { // Test if we can reuse the existing connection if (!self.configuration.enable_connection_reuse) || - (self.state.connection_reuse_count == self.configuration.connection_reuse_count_limit) { + (self.state.connection_reuse_count >= self.configuration.connection_reuse_count_limit) { self.reset(); } @@ -306,8 +303,7 @@ impl Client { with_code!(result, [220].iter()) } - /// Sends content to the server, after checking the command sequence, and then - /// updates the transaction state + /// Sends content to the server fn send_server(&mut self, content: &str, end: &str, expected_codes: Iter) -> SmtpResult { let result = self.stream.as_mut().unwrap().send_and_get_response(content, end); with_code!(result, expected_codes) diff --git a/src/error.rs b/src/error.rs index ac07b36..8f4779c 100644 --- a/src/error.rs +++ b/src/error.rs @@ -21,13 +21,13 @@ use self::ErrorKind::{TransientError, PermanentError, UnknownError, InternalIoEr /// An enum of all error kinds. #[derive(PartialEq, Eq, Clone, Debug)] pub enum ErrorKind { - /// Transient error + /// Transient error, 4xx reply code /// - /// 4xx reply code + /// [RFC 5321, section 4.2.1](https://tools.ietf.org/html/rfc5321#section-4.2.1) TransientError(Response), - /// Permanent error + /// Permanent error, 5xx reply code /// - /// 5xx reply code + /// [RFC 5321, section 4.2.1](https://tools.ietf.org/html/rfc5321#section-4.2.1) PermanentError(Response), /// Unknown error UnknownError(String), @@ -74,7 +74,7 @@ impl FromError for SmtpError { _ => UnknownError(format! ("{:?}", response)), }; let desc = match kind { - TransientError(_) => "a permanent error occured during the SMTP transaction", + TransientError(_) => "a transient error occured during the SMTP transaction", PermanentError(_) => "a permanent error occured during the SMTP transaction", UnknownError(_) => "an unknown error occured during the SMTP transaction", InternalIoError(_) => "an I/O error occurred", diff --git a/src/extension.rs b/src/extension.rs index 7cf00e5..f4cfadd 100644 --- a/src/extension.rs +++ b/src/extension.rs @@ -42,7 +42,6 @@ pub enum Extension { } impl Extension { - // TODO: check RFC fn from_str(s: &str) -> Result, &'static str> { let splitted : Vec<&str> = s.split(' ').collect(); match (splitted[0], splitted.len()) { diff --git a/src/lib.rs b/src/lib.rs index b67781f..f57cbd4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -7,12 +7,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -//! # Rust SMTP library +//! # Rust SMTP client //! //! The client should tend to follow [RFC 5321](https://tools.ietf.org/html/rfc5321), but is still //! a work in progress. //! -//! It may eventually implement the following extensions : +//! It should eventually implement the following extensions : //! //! * 8BITMIME ([RFC 6152](https://tools.ietf.org/html/rfc6152)) //! * SMTPUTF8 ([RFC 6531](http://tools.ietf.org/html/rfc6531)) @@ -120,15 +120,8 @@ //! let _ = email_client.quit(); //! ``` -#![crate_type = "lib"] - -#![doc(html_root_url = "http://amousset.github.io/rust-smtp/smtp/")] - -#![unstable] - -#![deny(missing_docs)] - #![feature(plugin, core, old_io, io, collections)] +#![deny(missing_docs)] #[macro_use] extern crate log; extern crate "rustc-serialize" as serialize;