summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2020-07-09 21:09:16 +0200
committerMatthias Beyer <mail@beyermatthias.de>2020-07-09 21:11:35 +0200
commit035fe35f262c8c5ce5d67133a19189457af3f699 (patch)
tree9103f5be926418df60f905b5c842e8d61bf009f8 /src
parentab037ee288c1206dbed05a845950c2ef83be6cf6 (diff)
Make postprocessor of loader aware of what it loads via a name
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Diffstat (limited to 'src')
-rw-r--r--src/loader.rs2
-rw-r--r--src/sidebar.rs14
2 files changed, 8 insertions, 8 deletions
diff --git a/src/loader.rs b/src/loader.rs
index 2a2d573..9aae9c8 100644
--- a/src/loader.rs
+++ b/src/loader.rs
@@ -8,7 +8,7 @@ pub trait Loader {
type PostProcessor: PostProcessor<Self::Output, Output = Self::PostProcessedOutput>;
fn load(self) -> Result<Self::Output, Self::Error>;
- fn postprocessor(&self) -> Self::PostProcessor;
+ fn postprocessor(&self, load_name: String) -> Self::PostProcessor;
}
pub trait PostProcessor<Object: Sized> {
diff --git a/src/sidebar.rs b/src/sidebar.rs
index d08418a..9da58ff 100644
--- a/src/sidebar.rs
+++ b/src/sidebar.rs
@@ -65,19 +65,19 @@ impl Sidebar {
.unwrap()
};
- let postprocessor = loader.postprocessor();
-
- // Construct the AsyncView with the loader job
- let list_view = cursive_async_view::AsyncView::new_with_bg_creator(&mut siv,
- || { loader.load() },
- move |list| { postprocessor.postprocess(list) });
-
let name = path.file_name()
.and_then(OsStr::to_str)
.map(String::from)
.ok_or_else(|| anyhow!("UTF8 error"))
.unwrap();
+ let postprocessor = loader.postprocessor(name.clone());
+
+ // Construct the AsyncView with the loader job
+ let list_view = cursive_async_view::AsyncView::new_with_bg_creator(&mut siv,
+ || { loader.load() },
+ move |list| { postprocessor.postprocess(list) });
+
// Add the AsyncView to the screen
siv.call_on_name(crate::main_view::MAIN_VIEW_NAME, move |main_view: &mut MainView| {
Some(main_view.add_tab(name, list_view))