Fix compilation

This commit is contained in:
Alexis Mousset
2014-10-13 12:47:11 +02:00
parent c33abcb1aa
commit 85d3607cac
12 changed files with 63 additions and 48 deletions

8
.gitignore vendored
View File

@@ -1,3 +1,5 @@
target/
TAGS
doc/
/target/
/doc/
/Cargo.lock
*~
*.swp

View File

@@ -1,14 +1,16 @@
language: rust
env:
global:
- secure: OQR++Fdd4QL2qSCTChrWHyBQDwWAfcbupveh+c7EEZO6Gb+8OMEQLKX50rr9MzLvr64BTbFBS9yJEBAcyQUxQFJRM0qfJlT6dkkm2Kfp+FagIOQmz9f7PQhf/NNPyR0RxxkpEkd4OeQUy8bcPq0xhBV9WzviZo8fh7WLoeejfaU=
before_install:
- wget http://static.rust-lang.org/dist/rust-nightly-x86_64-unknown-linux-gnu.tar.gz
- tar xf rust-nightly-x86_64-unknown-linux-gnu.tar.gz
install:
- sudo ./rust-nightly-x86_64-unknown-linux-gnu/install.sh
- rustc -v
os:
- osx
- linux
script:
- make examples
- make check
after_script:
- curl http://www.rust-ci.org/artifacts/put?t=$RUSTCI_TOKEN | sh
- cargo build
- cargo test
- cargo doc
after_success: |
[ $TRAVIS_BRANCH = master ] &&
[ $TRAVIS_PULL_REQUEST = false ] &&
cd target/doc &&
(curl http://www.rust-ci.org/artifacts/put?t=$RUSTCI_TOKEN | sh)

View File

@@ -1,16 +1,11 @@
[package]
name = "rust-smtp"
version = "0.0.1"
name = "smtp"
version = "0.0.1-pre"
#readme = "README.md"
authors = [ "Alexis Mousset <contact@amousset.eu>" ]
authors = ["Alexis Mousset <contact@amousset.eu>"]
#tags = ["smtp", "email", "library"]
[[lib]]
[lib]
name = "smtpcommon"
path = "src/smtpcommon/lib.rs"
#[[lib]]
#name = "smtpc"
#path = "src/smtpc/lib.rs"
path = "src/lib.rs"

View File

@@ -4,15 +4,15 @@ Rust SMTP library
.. image:: https://travis-ci.org/amousset/rust-smtp.png?branch=master
:target: https://travis-ci.org/amousset/rust-smtp
This library implements an SMTP client, and maybe later a simple SMTP server.
This library implements an SMTP library and a simple client.
Rust versions
-------------
This library is designed for Rust 0.11.0-nightly (master).
This library is designed for Rust 0.13.0-nightly (master).
Install
------
-------
Use Cargo to build this library.

View File

@@ -27,7 +27,7 @@
//!
//! ## Usage
//!
//! ```rust
//! ```tmp
//! extern crate smtp;
//! use std::io::net::tcp::TcpStream;
//! use smtp::client::SmtpClient;
@@ -46,9 +46,9 @@
#![crate_type = "dylib"]
#![desc = "Rust SMTP library"]
#![comment = "Simple and modern SMTP library"]
#![comment = "Simple SMTP client and library"]
#![license = "MIT/ASL2"]
#![doc(html_root_url = "http://amousset.github.io/rust-smtp/smtpcommon/")]
#![doc(html_root_url = "http://www.rust-ci.org/amousset/rust-smtp/doc")]
#![feature(macro_rules)]
#![feature(phase)]
@@ -59,8 +59,15 @@
#![deny(unnecessary_typecast)]
#![deny(unused_result)]
pub mod common;
pub mod command;
pub mod extension;
pub mod response;
pub mod transaction;
#![feature(phase)] #[phase(plugin, link)] extern crate log;
pub mod smtpcommon;
//pub mod smtpc;
//pub mod client;
//pub mod connecter;
//pub mod common;
//pub mod command;
//pub mod extension;
//pub mod response;
//pub mod transaction;

View File

View File

@@ -80,7 +80,7 @@ impl Show for SmtpCommand {
#[cfg(test)]
mod test {
use command;
use smtpcommon::command;
#[test]
fn test_command_fmt() {

View File

@@ -28,7 +28,7 @@ pub static CRLF: &'static str = "\r\n";
/// Adds quotes to emails if needed
pub fn quote_email_address(address: String) -> String {
match address.len() {
0..1 => format!("<{:s}>", address),
0 ... 1 => format!("<{:s}>", address),
_ => match (address.as_slice().slice_to(1), address.as_slice().slice_from(address.len() - 1)) {
("<", ">") => address,
_ => format!("<{:s}>", address)
@@ -39,7 +39,7 @@ pub fn quote_email_address(address: String) -> String {
/// Removes quotes from emails if needed
pub fn unquote_email_address(address: String) -> String {
match address.len() {
0..1 => address,
0 ... 1 => address,
_ => match (address.as_slice().slice_to(1), address.as_slice().slice_from(address.len() - 1)) {
("<", ">") => address.as_slice().slice(1, address.len() - 1).to_string(),
_ => address
@@ -60,7 +60,7 @@ pub fn remove_trailing_crlf(string: String) -> String {
/// Returns the first word of a string, or the string if it contains no space
pub fn get_first_word(string: String) -> String {
string.as_slice().split_str(CRLF).next().unwrap().splitn(' ', 1).next().unwrap().to_string()
string.as_slice().split_str(CRLF).next().unwrap().splitn(1, ' ').next().unwrap().to_string()
}
#[cfg(test)]

View File

@@ -43,14 +43,14 @@ impl Show for SmtpExtension {
impl FromStr for SmtpExtension {
fn from_str(s: &str) -> Option<SmtpExtension> {
let splitted : Vec<&str> = s.splitn(' ', 1).collect();
let splitted : Vec<&str> = s.splitn(1, ' ').collect();
match splitted.len() {
1 => match *splitted.get(0) {
1 => match splitted[0] {
"8BITMIME" => Some(EightBitMime),
"SMTPUTF8" => Some(SmtpUtfEight),
_ => None
},
2 => match (*splitted.get(0), from_str::<uint>(*splitted.get(1))) {
2 => match (splitted[0], from_str::<uint>(splitted[1])) {
("SIZE", Some(size)) => Some(Size(size)),
_ => None
},
@@ -74,8 +74,8 @@ impl SmtpExtension {
#[cfg(test)]
mod test {
use extension;
use extension::SmtpExtension;
use smtpcommon::extension;
use smtpcommon::extension::SmtpExtension;
#[test]
fn test_extension_same_extension_as() {

7
src/smtpcommon/mod.rs Normal file
View File

@@ -0,0 +1,7 @@
//! SMTP library
pub mod common;
pub mod command;
pub mod extension;
pub mod response;
pub mod transaction;

View File

@@ -9,9 +9,11 @@
//! SMTP responses, contaiing a mandatory return code, and an optional text message
//extern crate common;
use std::from_str::FromStr;
use std::fmt::{Show, Formatter, Result};
use common::remove_trailing_crlf;
use smtpcommon::common::remove_trailing_crlf;
use std::result;
/// Contains an SMTP reply, with separed code and message
@@ -84,7 +86,7 @@ impl SmtpResponse {
#[cfg(test)]
mod test {
use response::SmtpResponse;
use smtpcommon::response::SmtpResponse;
#[test]
fn test_response_fmt() {

View File

@@ -11,8 +11,8 @@
use std::fmt;
use std::fmt::{Show, Formatter};
use command;
use command::SmtpCommand;
use smtpcommon::command;
use smtpcommon::command::SmtpCommand;
/// Contains the state of the current transaction
#[deriving(PartialEq,Eq,Clone)]
@@ -102,7 +102,7 @@ impl TransactionState {
#[cfg(test)]
mod test {
use command;
use smtpcommon::command;
#[test]
fn test_transaction_state_is_command_possible() {