From f91b755619bb3c8b65fe7018514691fced223981 Mon Sep 17 00:00:00 2001 From: davidemazzocchi Date: Tue, 30 Sep 2025 12:46:16 +0200 Subject: [PATCH] feat: add function to list entities by class --- 01.workspace/heave/src/str/catalog.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/01.workspace/heave/src/str/catalog.rs b/01.workspace/heave/src/str/catalog.rs index 2e140d9..26a6099 100644 --- a/01.workspace/heave/src/str/catalog.rs +++ b/01.workspace/heave/src/str/catalog.rs @@ -34,6 +34,18 @@ impl O { let entity = self.items.get(id); entity.map(|e| T::from(e.clone())) } + pub fn list_by_class(&self, class: &str) -> Vec + where + T: From, + { + let items: Vec = self + .items + .values() + .filter(|item| item.class == class) + .map(|item| T::from(item.clone())) + .collect(); + items + } pub fn persist(&self) { let path = path::Path::new(&self.path); sqlite::persist::catalog(path, self);