1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
//! # Status //! //! The API is still very much subject to change. Until you see the release of version 1.0.0, don't expect much stability. //! See the README.md file and project open issues for current status. //! //! The use case of running the server as a standalone application should be described in the README.md (tbd) //! Here we focus on using the library. //! //! # Installation //! //! Add this to your `Cargo.toml`: //! //! ```toml //! [dependencies] //! samotop = "0.4" //! ``` //! //! # Usage //! //! There are a few interesting provisions one could take away here: //! * The server (through `samotop::builder()`) - it takes IP:port's to listen `on()` and you can use it `with()` your own implementation of `TcpService`. //! * The SMTP service (`SamotopService`) - it takes a `tokio::net::TcpStream` into the `Sink` created by `start()`. //! * The low level `SmtpCodec` - it implements `tokio_codec::Encoder` and `tokio_codec::Decoder`. It handles SMTP mail data as well. //! * The SMTP session parser (`SmtpParser`) - it takes `&str` and returns parsed commands or session. //! * The SMTP session and domain model (`model::session`, `model::command`, `model::response`) - these describe the domain and behavior. //! * The mail handling stuff that is yet to be written (`MailService`)... //! //! The individual components may later be split out into their own crates, but we shall have the samotop crate re-export them then. //! //! # Builder //! The simplest way is to run the server with a builder: //! //! ```no_run //! extern crate env_logger; //! extern crate samotop; //! extern crate tokio; //! #[macro_use] //! extern crate structopt; //! //! use structopt::StructOpt; //! //! fn main() { //! env_logger::init(); //! //! let opt = Opt::from_args(); //! //! //SamotopService is the default, but you can set your own name here. //! let svc = samotop::service::tcp::default() //! .serve(samotop::service::mail::ConsoleMail::new("MySamotop")); //! //! tokio::run(samotop::builder() //! .with(svc) //! .on_all(opt.ports) //! .as_task()); //! } //! //! #[derive(StructOpt, Debug)] //! #[structopt(name = "samotop")] //! struct Opt { //! /// SMTP server address:port //! #[structopt(short = "p", long = "port")] //! ports: Vec<String>, //! } //! ``` #[macro_use] extern crate log; extern crate bytes; extern crate env_logger; extern crate regex; #[macro_use] extern crate futures; extern crate hostname; extern crate tokio; extern crate tokio_codec; extern crate uuid; pub mod grammar; pub mod model; pub mod protocol; pub mod server; pub mod service; pub mod util; pub use server::builder;