summaryrefslogtreecommitdiffstats
path: root/mail/examples/mail_from_template/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'mail/examples/mail_from_template/main.rs')
-rw-r--r--mail/examples/mail_from_template/main.rs29
1 files changed, 11 insertions, 18 deletions
diff --git a/mail/examples/mail_from_template/main.rs b/mail/examples/mail_from_template/main.rs
index deeda80..0ff2c42 100644
--- a/mail/examples/mail_from_template/main.rs
+++ b/mail/examples/mail_from_template/main.rs
@@ -2,15 +2,13 @@
//! (and then printed)
//!
-extern crate mail;
+extern crate failure;
extern crate futures;
-extern crate soft_ascii_string;
+extern crate mail;
extern crate serde;
-extern crate failure;
+extern crate soft_ascii_string;
-use std::{
- path::Path
-};
+use std::path::Path;
use failure::Error;
use futures::Future;
@@ -19,22 +17,15 @@ use soft_ascii_string::SoftAsciiString;
use serde::Serialize;
use mail::{
- Domain,
- MailType,
default_impl::simple_context,
- template::{
- load_toml_template_from_path,
- handlebars::Handlebars,
- TemplateExt
- },
headers,
- HeaderTryFrom,
- HeaderKind
+ template::{handlebars::Handlebars, load_toml_template_from_path, TemplateExt},
+ Domain, HeaderKind, HeaderTryFrom, MailType,
};
#[derive(Debug, Serialize)]
struct UserData {
- name: &'static str
+ name: &'static str,
}
fn main() {
@@ -49,7 +40,8 @@ fn main() {
let ctx = simple_context::new(msg_id_domain, unique_part).unwrap();
let engine = Handlebars::new();
- let template_path = Path::new("example_resources/templates/template_a/template.toml").to_owned();
+ let template_path =
+ Path::new("example_resources/templates/template_a/template.toml").to_owned();
let fut = load_toml_template_from_path(engine, template_path, &ctx)
.and_then(|template| -> Result<_, Error> {
// If our "user data" would contain additional inline_emebeddings/attachments
@@ -61,7 +53,8 @@ fn main() {
mail.insert_header(headers::_From::auto_body(["a@b.example"])?);
mail.insert_header(headers::_To::auto_body(["d@e.example"])?);
Ok(mail)
- }).and_then(|mail| mail.into_encodable_mail(ctx.clone()).map_err(Into::into));
+ })
+ .and_then(|mail| mail.into_encodable_mail(ctx.clone()).map_err(Into::into));
let enc_mail = fut.wait().unwrap();
let bytes = enc_mail.encode_into_bytes(MailType::Ascii).unwrap();