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);