extern crate emailmessage; extern crate futures; extern crate tokio; use emailmessage::Message; use futures::{Future, Stream}; use std::str::from_utf8; use tokio::run; fn main() { let m: Message = Message::builder() .from("NoBody ".parse().unwrap()) .reply_to("Yuin ".parse().unwrap()) .to("Hei ".parse().unwrap()) .subject("Happy new year") .body("Be happy!".into()); let f = m .into_stream() .map(|chunk| { println!("CHUNK[[\n{}]]", from_utf8(&chunk).unwrap()); chunk }).concat2() .map(|message| { println!("MESSAGE[[\n{}]]", from_utf8(&message).unwrap()); }).map_err(|error| { eprintln!("ERROR: {}", error); }); run(f); }