summaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs25
1 files changed, 18 insertions, 7 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 2d60293..e8797d2 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -530,16 +530,27 @@ impl Engine {
530 /// 530 ///
531 /// # Arguments 531 /// # Arguments
532 /// * `name`: Represents the primary name of the resource, often a filename 532 /// * `name`: Represents the primary name of the resource, often a filename
533 /// * `content_type`: How to interpret the resource data within `content` 533 /// * `content_type`: How to interpret the resource data within `content`.
534 /// Use `"template"` if wanting to specify a template resource type.
534 /// * `content`: The resource data, encoded using standard base64 configuration 535 /// * `content`: The resource data, encoded using standard base64 configuration
535 #[pyo3(text_signature = "($self, name, content_type, content)")] 536 /// * `aliases`: List of aliases for the resource
536 pub fn add_resource(&mut self, name: &str, content_type: &str, content: &str) -> PyResult<()> { 537 #[pyo3(text_signature = "($self, name, content_type, content, aliases)")]
538 pub fn add_resource(
539 &mut self,
540 name: &str,
541 content_type: &str,
542 content: &str,
543 aliases: Option<Vec<String>>,
544 ) -> PyResult<()> {
537 let result = self.engine.add_resource(Resource { 545 let result = self.engine.add_resource(Resource {
538 name: name.to_string(), 546 name: name.to_string(),
539 aliases: vec![], 547 aliases: aliases.unwrap_or_default(),
540 kind: ResourceType::Mime(MimeType::from(std::borrow::Cow::from( 548 kind: match content_type {
541 content_type.to_string(), 549 "template" => ResourceType::Template,
542 ))), 550 _ => ResourceType::Mime(MimeType::from(std::borrow::Cow::from(
551 content_type.to_string(),
552 ))),
553 },
543 content: content.to_string(), 554 content: content.to_string(),
544 }); 555 });
545 556