diff options
author | Philipp Korber <philippkorber@gmail.com> | 2018-05-17 16:51:29 +0200 |
---|---|---|
committer | Philipp Korber <philippkorber@gmail.com> | 2018-05-17 16:51:29 +0200 |
commit | 0ec5035676902887c64d6826ce869ef3b764f7fb (patch) | |
tree | 2857970976c79c2dc69aafc0d64f96aa9b6fe20e | |
parent | b585bb24f48bfaf49fecdeb35c47eae8fce99023 (diff) |
chore(api): removed EnvelopData as it is not needed
- don't confuse this with the new-tokio-smtp EnvelopData
type, they are similar but work on different abstraction
levels
-rw-r--r-- | src/compositor/_impl.rs | 7 | ||||
-rw-r--r-- | src/compositor/mod.rs | 41 | ||||
-rw-r--r-- | src/lib.rs | 3 | ||||
-rw-r--r-- | tests/tera/main.rs | 2 |
4 files changed, 6 insertions, 47 deletions
diff --git a/src/compositor/_impl.rs b/src/compositor/_impl.rs index 9fa803c..4b82242 100644 --- a/src/compositor/_impl.rs +++ b/src/compositor/_impl.rs @@ -22,7 +22,7 @@ use ::template::{ use ::error::CompositionError; use super::mail_send_data::MailSendData; -use super::{CompositionBase, EnvelopData}; +use super::CompositionBase; pub(crate) trait InnerCompositionBaseExt: CompositionBase { @@ -31,12 +31,11 @@ pub(crate) trait InnerCompositionBaseExt: CompositionBase { send_data: MailSendData< <Self::TemplateEngine as TemplateEngine<Self::Context>>::TemplateId, D> ) -> Result< - (Mail, EnvelopData), + Mail, CompositionError<<Self::TemplateEngine as TemplateEngine<Self::Context>>::Error> > where D: Serialize { - let envelop = EnvelopData::from(&send_data); //compose display name => create Address with display name; let (core_headers, data, template_id) = self.process_mail_send_data(send_data)?; @@ -46,7 +45,7 @@ pub(crate) trait InnerCompositionBaseExt: CompositionBase { let mail = self.build_mail(alternative_bodies, shared_embeddings.into_iter(), attachments, core_headers)?; - Ok((mail, envelop)) + Ok(mail) } fn process_mail_send_data<'a, D>( diff --git a/src/compositor/mod.rs b/src/compositor/mod.rs index c26101a..acd6f5f 100644 --- a/src/compositor/mod.rs +++ b/src/compositor/mod.rs @@ -1,9 +1,6 @@ -use std::borrow::ToOwned; - use serde::Serialize; use mail::Mail; -use headers::components::{MailboxList, Mailbox}; use ::context::Context; use ::template::TemplateEngine; @@ -37,7 +34,7 @@ pub trait CompositionBase { send_data: MailSendData< <Self::TemplateEngine as TemplateEngine<Self::Context>>::TemplateId, D> ) -> Result< - (Mail, EnvelopData), + Mail, CompositionError<<Self::TemplateEngine as TemplateEngine<Self::Context>>::Error> > where D: Serialize @@ -47,40 +44,4 @@ pub trait CompositionBase { fn template_engine(&self) -> &Self::TemplateEngine; fn context(&self) -> &Self::Context; -} - - -//NOTE: this might get more complex at some point, wrt. e.g. cc, bcc, resent etc. -pub struct EnvelopData { - sender: Mailbox, - to: MailboxList - //cc: MailboxList, //add if added to MailSendData - //bcc: MailboxList, //add if added to MailSendData -} - -impl EnvelopData { - - pub fn new(sender: Mailbox, to: MailboxList) -> Self { - EnvelopData { - sender, to - } - } - - pub fn sender(&self) -> &Mailbox { - &self.sender - } - - pub fn _to(&self) -> &MailboxList { - &self.to - } -} - -impl<'a, T: ?Sized, D> From<&'a MailSendData<'a, T, D>> for EnvelopData - where T: ToOwned, D: Serialize -{ - fn from(msd: &'a MailSendData<'a, T, D>) -> Self { - let sender = msd.sender().clone(); - let to = msd._to().clone(); - EnvelopData::new(sender, to) - } }
\ No newline at end of file @@ -55,8 +55,7 @@ pub use self::builder_extension::BuilderExt; pub use self::compositor::{ CompositionBase, NameComposer, MailSendData, MailSendDataBuilder, - SharedCompositionBase, SimpleCompositionBase, - EnvelopData + SharedCompositionBase, SimpleCompositionBase }; pub use self::context::{ Context, diff --git a/tests/tera/main.rs b/tests/tera/main.rs index 6cc89d7..854fd25 100644 --- a/tests/tera/main.rs +++ b/tests/tera/main.rs @@ -90,7 +90,7 @@ fn use_tera_template_a() { template_id, data ); - let (mail, _envelop) = compositor.compose_mail(send_data).unwrap(); + let mail = compositor.compose_mail(send_data).unwrap(); let out_string = send_mail_to_string(mail, &context); |