Reorganize common constants

This commit is contained in:
Alexis Mousset
2015-03-02 15:22:55 +01:00
parent 22b436d53b
commit 375900b7aa
8 changed files with 39 additions and 51 deletions

View File

@@ -22,8 +22,9 @@ use crypto::hmac::Hmac;
use crypto::md5::Md5;
use crypto::mac::Mac;
use SMTP_PORT;
use tools::get_first_word;
use common::{NUL, CRLF, MESSAGE_ENDING, SMTP_PORT};
use tools::{NUL, CRLF, MESSAGE_ENDING};
use response::Response;
use extension::Extension;
use error::{SmtpResult, ErrorKind};

View File

@@ -1,42 +0,0 @@
// Copyright 2014 Alexis Mousset. See the COPYRIGHT
// file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
//! Constants defined in SMTP RFCs
use std::old_io::net::ip::Port;
/// Default smtp port
pub static SMTP_PORT: Port = 25;
/// Default smtps port
pub static SMTPS_PORT: Port = 465;
/// Default submission port
pub static SUBMISSION_PORT: Port = 587;
/// The word separator for SMTP transactions
pub static SP: &'static str = " ";
/// The line ending for SMTP transactions (carriage return + line feed)
pub static CRLF: &'static str = "\r\n";
/// Carriage return
pub static CR: &'static str = "\r";
/// Line feed
pub static LF: &'static str = "\n";
/// Colon
pub static COLON: &'static str = ":";
/// The ending of message content
pub static MESSAGE_ENDING: &'static str = "\r\n.\r\n";
/// NUL unicode character
pub static NUL: &'static str = "\0";

View File

@@ -12,7 +12,7 @@
use std::str::FromStr;
use std::result::Result;
use common::CRLF;
use tools::CRLF;
use response::Response;
use self::Extension::{PlainAuthentication, CramMd5Authentication, EightBitMime, SmtpUtfEight, StartTls};

View File

@@ -111,11 +111,21 @@ extern crate crypto;
extern crate time;
extern crate uuid;
mod tools;
mod extension;
pub mod client;
pub mod extension;
pub mod response;
pub mod common;
pub mod error;
pub mod tools;
pub mod sendable_email;
pub mod mailer;
use std::old_io::net::ip::Port;
/// Default smtp port
pub static SMTP_PORT: Port = 25;
/// Default smtps port
pub static SMTPS_PORT: Port = 465;
/// Default submission port
pub static SUBMISSION_PORT: Port = 587;

View File

@@ -11,7 +11,7 @@
use std::fmt::{Display, Formatter, Result};
use common::SP;
use tools::SP;
/// Converts an adress or an address with an alias to an `Address`
pub trait ToAddress {

View File

@@ -13,7 +13,7 @@ use time::Tm;
use std::fmt::{Display, Formatter, Result};
use common::{SP, COLON};
use tools::{SP, COLON};
use mailer::address::Address;
/// Converts to an `Header`

View File

@@ -15,7 +15,7 @@ use time::{now, Tm};
use mailer::header::{ToHeader, Header};
use mailer::address::ToAddress;
use common::CRLF;
use tools::CRLF;
use sendable_email::SendableEmail;
pub mod header;

View File

@@ -11,7 +11,26 @@
use std::string::String;
use common::{CR, LF, CRLF};
/// The word separator for SMTP transactions
pub static SP: &'static str = " ";
/// The line ending for SMTP transactions (carriage return + line feed)
pub static CRLF: &'static str = "\r\n";
/// Carriage return
pub static CR: &'static str = "\r";
/// Line feed
pub static LF: &'static str = "\n";
/// Colon
pub static COLON: &'static str = ":";
/// The ending of message content
pub static MESSAGE_ENDING: &'static str = "\r\n.\r\n";
/// NUL unicode character
pub static NUL: &'static str = "\0";
/// Removes the trailing line return at the end of a string
#[inline]