summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilipp Korber <philippkorber@gmail.com>2018-07-14 18:48:57 +0200
committerPhilipp Korber <philippkorber@gmail.com>2018-07-14 18:48:57 +0200
commit9e40e2afb0be5d3e76f8186f53b9562f2e8d7d1f (patch)
tree41bda69e517808dd3e3afa552581c7a10d1b9c4f
parent05656a08f1f90f4481df371098e21cd91fc6a039 (diff)
doc(EmbeddedWithCId) added more documentation
-rw-r--r--src/resource/mod.rs19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/resource/mod.rs b/src/resource/mod.rs
index dc35617..3f16a96 100644
--- a/src/resource/mod.rs
+++ b/src/resource/mod.rs
@@ -223,25 +223,37 @@ impl Deref for EmbeddedWithCId {
}
}
-
-
-
impl EmbeddedWithCId {
+ /// create a new embedding with an inline disposition
+ ///
+ /// The context is used to generate a fitting content id.
pub fn inline(resource: Resource, ctx: &impl Context) -> Self {
EmbeddedWithCId::new(resource, Disposition::Inline, ctx)
}
+ /// create a new embedding with an attachment disposition
+ ///
+ /// The context is used to generate a fitting content id.
pub fn attachment(resource: Resource, ctx: &impl Context) -> Self {
EmbeddedWithCId::new(resource, Disposition::Attachment, ctx)
}
+ /// create a new embedding
+ ///
+ /// The context is used to generate a fitting content id.
pub fn new(resource: Resource, disposition: Disposition, ctx: &impl Context) -> Self {
EmbeddedWithCId {
inner: Embedded::with_content_id(resource, disposition, ctx.generate_content_id())
}
}
+ /// Tries to convert an `Embedded` instance to an `EmbeddedWithCId` instance.
+ ///
+ /// # Error
+ ///
+ /// If the `Embedded` instance doesn't have a content id the passed in
+ /// `Embedded` instance is returned as error.
pub fn try_from(emb: Embedded) -> Result<EmbeddedWithCId, Embedded> {
if emb.content_id().is_some() {
Ok(EmbeddedWithCId { inner: emb })
@@ -250,6 +262,7 @@ impl EmbeddedWithCId {
}
}
+ /// return the content id
pub fn content_id(&self) -> &ContentId {
self.inner.content_id().unwrap()
}