summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilipp Korber <philippkorber@gmail.com>2018-05-30 18:45:53 +0200
committerPhilipp Korber <philippkorber@gmail.com>2018-05-30 18:55:23 +0200
commitf1bce3d69c1a2fd8ec801a00d9691d2e068453c4 (patch)
tree4b831fc18ce4797a889bdd0cfa0e5566b75dd77d
parent43c2df6cc263bdda125faae2e4e79598b0f12769 (diff)
refactor(BodyPart): moved BodyPart to builder_extension module
-rw-r--r--src/builder_extension.rs16
-rw-r--r--src/compositor/impl_compose.rs6
-rw-r--r--src/error.rs10
-rw-r--r--src/template_engine.rs16
4 files changed, 21 insertions, 27 deletions
diff --git a/src/builder_extension.rs b/src/builder_extension.rs
index 9d5c7a4..fb59bc3 100644
--- a/src/builder_extension.rs
+++ b/src/builder_extension.rs
@@ -7,11 +7,25 @@ use headers::components::{Disposition, MediaType};
use mail::{Resource, Mail, Builder};
use mail::error::OtherBuilderErrorKind;
-use ::template_engine::BodyPart;
use ::resource::EmbeddedWithCId;
use ::error::{ExtendedBuilderError, ExtendedBuilderErrorKind};
+/// A mail body likely created by a template engine
+pub struct BodyPart {
+ /// a body created by a template
+ pub body_resource: Resource,
+
+ /// embeddings added by the template engine
+ ///
+ /// It is a mapping of the name under which a embedding had been made available in the
+ /// template engine to the embedding (which has to contain a CId, as it already
+ /// was used in the template engine and CIds are used to link to the content which should
+ /// be embedded)
+ pub embeddings: Vec<EmbeddedWithCId>,
+
+}
+
/// Ext. Trait which adds helper methods to the Builder type.
///
pub trait BuilderExt {
diff --git a/src/compositor/impl_compose.rs b/src/compositor/impl_compose.rs
index fc6663d..8856885 100644
--- a/src/compositor/impl_compose.rs
+++ b/src/compositor/impl_compose.rs
@@ -13,9 +13,11 @@ use ::resource::{
Embedded, EmbeddedWithCId,
InspectEmbeddedResources, Disposition
};
-use ::builder_extension::BuilderExt;
+use ::builder_extension::{
+ BodyPart, BuilderExt
+};
use ::template_engine::{
- BodyPart, TemplateEngine, MailParts
+ TemplateEngine, MailParts
};
use ::error::CompositionError;
diff --git a/src/error.rs b/src/error.rs
index 01590ff..d25b7a7 100644
--- a/src/error.rs
+++ b/src/error.rs
@@ -142,16 +142,6 @@ pub enum ExtendedBuilderError {
}
-//TODO[rust/bug?else specialization from]: use wildcard for transitive impl
-// impl<T> From<T> for ExtendedBuilderError
-// where BuilderError: From<T>
-// {
-// fn from(err: T) -> Self {
-// let be = BuilderError::from(err);
-// ExtendedBuilderError::Normal(be)
-// }
-// }
-
impl From<BuilderError> for ExtendedBuilderError {
fn from(error: BuilderError) -> Self {
ExtendedBuilderError::Normal(error)
diff --git a/src/template_engine.rs b/src/template_engine.rs
index 1483097..d522ad4 100644
--- a/src/template_engine.rs
+++ b/src/template_engine.rs
@@ -5,9 +5,10 @@ use std::rc::Rc;
use failure::Fail;
use vec1::Vec1;
-use mail::{Resource, Context};
+use mail::Context;
use ::resource::{EmbeddedWithCId, InspectEmbeddedResources};
+use ::builder_extension::BodyPart;
///
/// # Why is Context a generic of the Type?
@@ -43,20 +44,7 @@ pub struct MailParts {
}
//TODO move this to BuilderExt and just use it here (oh and rename it)
-/// A mail body created by a template engine
-pub struct BodyPart {
- /// a body created by a template
- pub body_resource: Resource,
-
- /// embeddings added by the template engine
- ///
- /// It is a mapping of the name under which a embedding had been made available in the
- /// template engine to the embedding (which has to contain a CId, as it already
- /// was used in the template engine and CIds are used to link to the content which should
- /// be embedded)
- pub embeddings: Vec<EmbeddedWithCId>,
-}
macro_rules! impl_for_1elem_container {
($($name:ident),*) => ($(