summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilipp Korber <philippkorber@gmail.com>2018-11-22 14:05:51 +0100
committerPhilipp Korber <philippkorber@gmail.com>2018-11-22 14:05:51 +0100
commitff0d27240642d8b5b0b1e70656f9411afabb5000 (patch)
treefe4e5a72120c403e9323b15b740d980d60631b26
parentd2592ba37b45c919eed8d8dd79ea03b47913aa37 (diff)
chore(StandardLazyBodyImpl) added media_type field
-rw-r--r--src/lib.rs9
-rw-r--r--src/serde_impl.rs14
2 files changed, 14 insertions, 9 deletions
diff --git a/src/lib.rs b/src/lib.rs
index b568527..dc9f529 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -169,10 +169,9 @@ impl<TE> Template<TE>
/// Represents one of potentially many alternate bodies in a template.
#[derive(Debug)]
pub struct BodyTemplate<TE: TemplateEngine> {
- template_id: TE::Id,
- media_type: MediaType,
- embeddings: HashMap<String, Resource>
- //TODO potential additional fields like file_name maybe attachments
+ pub template_id: TE::Id,
+ pub media_type: MediaType,
+ pub inline_embeddings: HashMap<String, Resource>
}
impl<TE> BodyTemplate<TE>
@@ -187,7 +186,7 @@ impl<TE> BodyTemplate<TE>
}
pub fn inline_embeddings(&self) -> &HashMap<String, Resource> {
- &self.embeddings
+ &self.inline_embeddings
}
}
diff --git a/src/serde_impl.rs b/src/serde_impl.rs
index a6dc54b..2ab709d 100644
--- a/src/serde_impl.rs
+++ b/src/serde_impl.rs
@@ -14,6 +14,7 @@ use futures::{Future, future::{self, Either}};
use vec1::Vec1;
use mail_core::{Resource, Source, IRI, Context};
+use mail_headers::header_components::MediaType;
use super::{
Template,
@@ -204,7 +205,8 @@ pub fn deserialize_attachments<'de, D>(deserializer: D)
#[derive(Debug, Serialize)]
pub struct StandardLazyBodyTemplate {
pub path: PathBuf,
- pub embeddings: HashMap<String, Resource>
+ pub embeddings: HashMap<String, Resource>,
+ pub media_type: Option<MediaType>
}
@@ -231,7 +233,9 @@ enum StandardLazyBodyTemplateDeserializationHelper {
path: PathBuf,
#[serde(default)]
#[serde(deserialize_with="deserialize_embeddings")]
- embeddings: HashMap<String, Resource>
+ embeddings: HashMap<String, Resource>,
+ #[serde(default)]
+ media_type: Option<MediaType>
}
}
@@ -246,10 +250,12 @@ impl<'de> Deserialize<'de> for StandardLazyBodyTemplate {
ShortForm(string) => {
StandardLazyBodyTemplate {
path: string.into(),
- embeddings: Default::default()
+ embeddings: Default::default(),
+ media_type: Default::default()
}
},
- LongForm {path, embeddings} => StandardLazyBodyTemplate { path, embeddings }
+ LongForm {path, embeddings, media_type} =>
+ StandardLazyBodyTemplate { path, embeddings, media_type }
};
Ok(ok_val)
}