summaryrefslogtreecommitdiff
path: root/src/works
diff options
context:
space:
mode:
authorWriterV2 <primary-v2@protonmail.com>2023-06-03 14:33:09 +0200
committerWriterV2 <primary-v2@protonmail.com>2023-06-03 14:33:09 +0200
commit30b707d610f4daf025da01b12247bd3b7ebd9e55 (patch)
tree2c82ac3ba39af5fde041f074e51b4fb9f56c092f /src/works
parent683ca3627f38461cbbdee321a15821b46e72ae6a (diff)
Clean command pattern for works
Diffstat (limited to 'src/works')
-rw-r--r--src/works/mod.rs8
-rw-r--r--src/works/stories.rs6
2 files changed, 7 insertions, 7 deletions
diff --git a/src/works/mod.rs b/src/works/mod.rs
index 77dd35d..0970cb1 100644
--- a/src/works/mod.rs
+++ b/src/works/mod.rs
@@ -22,15 +22,15 @@ pub trait Works: for<'a> Deserialize<'a> + Serialize {
}
// render page for every work
- fn render_single_pages(&self, tera_instance: &tera::Tera, template_name: &str) -> Result<()>;
+ fn render_single_pages(self, tera_instance: &tera::Tera, template_name: &str) -> Result<Self>;
// render corresponding overview HTML template
// with its tera context
fn render_overview_page(
- &self,
+ self,
tera_instance: &tera::Tera,
filename_without_extension: &str,
- ) -> Result<()> {
+ ) -> Result<Self> {
std::fs::write(
format!("docs/{}.html", filename_without_extension).as_str(),
tera_instance
@@ -51,6 +51,6 @@ pub trait Works: for<'a> Deserialize<'a> + Serialize {
filename_without_extension
)
})?;
- Ok(())
+ Ok(self)
}
}
diff --git a/src/works/stories.rs b/src/works/stories.rs
index f86d24a..2623db6 100644
--- a/src/works/stories.rs
+++ b/src/works/stories.rs
@@ -24,10 +24,10 @@ struct Story {
impl super::Works for Stories {
// render single pages for every story with the extracted text and a download button
fn render_single_pages(
- &self,
+ self,
tera_instance: &tera::Tera,
template_name: &str,
- ) -> Result<()> {
+ ) -> Result<Self> {
let mut result = Vec::new();
for story in self.0.iter() {
if story.update_available().with_context(|| format!("Failed to check for update for {}", story.title))? {
@@ -40,7 +40,7 @@ impl super::Works for Stories {
));
}
}
- Ok(())
+ Ok(self)
}
// create stories from stories.json and add last modification date