chore: rename list_by_class to list

This commit is contained in:
2025-11-15 08:34:57 +01:00
parent 7847394d13
commit 3b3e495254
6 changed files with 9 additions and 9 deletions

View File

@@ -131,7 +131,7 @@ fn main() {
new_catalog.load_by_filter(&filter).unwrap(); new_catalog.load_by_filter(&filter).unwrap();
// Get the list of loaded components. // Get the list of loaded components.
let loaded_components: Vec<Component> = new_catalog let loaded_components: Vec<Component> = new_catalog
.list_by_class::<Component>() .list::<Component>()
.unwrap() .unwrap()
.into_iter() .into_iter()
.map(|c| c.unwrap()) .map(|c| c.unwrap())

View File

@@ -142,7 +142,7 @@ fn main() -> Result<(), FailedTo> {
laptop_catalog.load_by_filter(&laptop_filter)?; laptop_catalog.load_by_filter(&laptop_filter)?;
let laptops: Vec<Product> = laptop_catalog let laptops: Vec<Product> = laptop_catalog
.list_by_class() .list()
.unwrap() .unwrap()
.into_iter() .into_iter()
.map(|p| p.unwrap()) .map(|p| p.unwrap())
@@ -170,7 +170,7 @@ fn main() -> Result<(), FailedTo> {
expensive_catalog.load_by_filter(&expensive_filter)?; expensive_catalog.load_by_filter(&expensive_filter)?;
let expensive_products: Vec<Product> = expensive_catalog let expensive_products: Vec<Product> = expensive_catalog
.list_by_class() .list()
.unwrap() .unwrap()
.into_iter() .into_iter()
.map(|p| p.unwrap()) .map(|p| p.unwrap())
@@ -202,7 +202,7 @@ fn main() -> Result<(), FailedTo> {
all_products_catalog.load_by_filter(&all_products_filter)?; all_products_catalog.load_by_filter(&all_products_filter)?;
let all_products: Vec<Product> = all_products_catalog let all_products: Vec<Product> = all_products_catalog
.list_by_class() .list()
.unwrap() .unwrap()
.into_iter() .into_iter()
.map(|p| p.unwrap()) .map(|p| p.unwrap())

View File

@@ -20,7 +20,7 @@ impl Catalog {
/// ///
/// Returns `Err(FailedTo::LockCatalog)` if the catalog's internal mutex /// Returns `Err(FailedTo::LockCatalog)` if the catalog's internal mutex
/// could not be locked. /// could not be locked.
pub fn list_by_class<T>(&self) -> Result<Vec<Result<T, FailedTo>>, FailedTo> pub fn list<T>(&self) -> Result<Vec<Result<T, FailedTo>>, FailedTo>
where where
T: EAV, T: EAV,
{ {

View File

@@ -10,7 +10,7 @@ pub mod catalog_init;
pub mod catalog_insert_many; pub mod catalog_insert_many;
pub mod catalog_is_empty; pub mod catalog_is_empty;
pub mod catalog_len; pub mod catalog_len;
pub mod catalog_list_by_class; pub mod catalog_list;
pub mod catalog_list_by_subclass; pub mod catalog_list_by_subclass;
pub mod catalog_load; pub mod catalog_load;
pub mod catalog_load_by_filter; pub mod catalog_load_by_filter;

View File

@@ -71,7 +71,7 @@ mod tests {
let mut catalog2 = Catalog::new(db_path); let mut catalog2 = Catalog::new(db_path);
catalog2.load::<Item>().unwrap(); catalog2.load::<Item>().unwrap();
let mut loaded_items: Vec<Item> = catalog2 let mut loaded_items: Vec<Item> = catalog2
.list_by_class::<Item>() .list::<Item>()
.unwrap() .unwrap()
.into_iter() .into_iter()
.map(|item| item.unwrap()) .map(|item| item.unwrap())

View File

@@ -25,7 +25,7 @@ mod tests {
}; };
let _ = catalog.upsert(item1.clone()); let _ = catalog.upsert(item1.clone());
let _ = catalog.upsert(item2.clone()); let _ = catalog.upsert(item2.clone());
let results = catalog.list_by_class::<Item>().unwrap(); let results = catalog.list::<Item>().unwrap();
assert_eq!(results.len(), 2); assert_eq!(results.len(), 2);
assert!(results.contains(&Ok(item1))); assert!(results.contains(&Ok(item1)));
assert!(results.contains(&Ok(item2))); assert!(results.contains(&Ok(item2)));
@@ -34,7 +34,7 @@ mod tests {
fn list_by_class_should_return_empty_iterator_if_no_match() { fn list_by_class_should_return_empty_iterator_if_no_match() {
// Should return an empty iterator if no entities of that class exist. // Should return an empty iterator if no entities of that class exist.
let catalog = Catalog::new("dummy.db"); let catalog = Catalog::new("dummy.db");
let results: Vec<_> = catalog.list_by_class::<Item>().unwrap(); let results: Vec<_> = catalog.list::<Item>().unwrap();
assert!(results.is_empty()); assert!(results.is_empty());
} }
} }