diff options
author | Philipp Korber <p.korber@1aim.com> | 2018-11-19 19:29:27 +0100 |
---|---|---|
committer | Philipp Korber <p.korber@1aim.com> | 2018-11-19 19:29:27 +0100 |
commit | d621d9b15ae64ddbb7bff4662c3f5086eab8ec0b (patch) | |
tree | 04d9658562e95ce3e063c39ce688984668ffd0be /core | |
parent | c435424f5cb1f31711e071c660dada87b13eaaae (diff) |
chore(Resource) added a `content_id` method
Diffstat (limited to 'core')
-rw-r--r-- | core/src/resource/mod.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/core/src/resource/mod.rs b/core/src/resource/mod.rs index 0070f24..8b7e9e1 100644 --- a/core/src/resource/mod.rs +++ b/core/src/resource/mod.rs @@ -114,6 +114,7 @@ Source->| | | - Use QuotedPrintable - NotHint */ +use headers::header_components::ContentId; mod source; mod data; @@ -180,4 +181,13 @@ impl Resource { pub fn plain_text(content: impl Into<String>, ctx: &impl Context) -> Resource { Resource::Data(Data::plain_text(content, ctx.generate_content_id())) } + + /// Return the content id, if there is any. + pub fn content_id(&self) -> Option<&ContentId> { + match self { + &Resource::Source(..) => None, + &Resource::Data(ref data) => Some(data.content_id()), + &Resource::EncData(ref enc_data) => Some(enc_data.content_id()) + } + } }
\ No newline at end of file |