diff --git a/01.workspace/heave/src/imp/catalog_load_by_class.rs b/01.workspace/heave/src/imp/catalog_load.rs similarity index 88% rename from 01.workspace/heave/src/imp/catalog_load_by_class.rs rename to 01.workspace/heave/src/imp/catalog_load.rs index 9f39423..ce26f06 100644 --- a/01.workspace/heave/src/imp/catalog_load_by_class.rs +++ b/01.workspace/heave/src/imp/catalog_load.rs @@ -1,7 +1,7 @@ use crate::*; impl Catalog { - /// Loads all entities of a specific class from the database into the in-memory catalog. + /// Loads all entities of a specific type from the database into the in-memory catalog. /// /// This method fetches all entities matching the given class from the database. /// If any of the loaded entities have IDs that match entities already in the @@ -23,7 +23,7 @@ impl Catalog { /// /// Returns `Err(FailedTo::LoadFromDB)` if there is an issue loading entities /// from the database. - pub fn load_by_class(&mut self) -> Result<(), FailedTo> + pub fn load(&mut self) -> Result<(), FailedTo> where T: EAV, { diff --git a/01.workspace/heave/src/imp/mod.rs b/01.workspace/heave/src/imp/mod.rs index b3bf8bf..edfbed7 100644 --- a/01.workspace/heave/src/imp/mod.rs +++ b/01.workspace/heave/src/imp/mod.rs @@ -11,7 +11,7 @@ pub mod catalog_is_empty; pub mod catalog_len; pub mod catalog_list_by_class; pub mod catalog_list_by_class_and_subclass; -pub mod catalog_load_by_class; +pub mod catalog_load; pub mod catalog_load_by_filter; pub mod catalog_load_by_id; pub mod catalog_persist; diff --git a/01.workspace/heave/src/tst/catalog_integration.rs b/01.workspace/heave/src/tst/catalog_integration.rs index f3d3b13..fa8a3ee 100644 --- a/01.workspace/heave/src/tst/catalog_integration.rs +++ b/01.workspace/heave/src/tst/catalog_integration.rs @@ -69,7 +69,7 @@ mod tests { catalog1.persist().unwrap(); // 2. new catalog -> 'load_by_class' -> 'list_by_class' let mut catalog2 = Catalog::new(db_path); - catalog2.load_by_class::().unwrap(); + catalog2.load::().unwrap(); let mut loaded_items: Vec = catalog2 .list_by_class::() .unwrap() diff --git a/01.workspace/heave/src/tst/catalog_load_by_class.rs b/01.workspace/heave/src/tst/catalog_load_by_class.rs index 6ea7884..55f0089 100644 --- a/01.workspace/heave/src/tst/catalog_load_by_class.rs +++ b/01.workspace/heave/src/tst/catalog_load_by_class.rs @@ -36,7 +36,7 @@ mod tests { catalog1.persist().unwrap(); // 2. Create a new catalog and load the items by class let mut catalog2 = Catalog::new(db_path); - let result = catalog2.load_by_class::(); + let result = catalog2.load::(); assert!(result.is_ok()); // 3. Verify that all items of that class were loaded let len = catalog2.len().unwrap(); @@ -102,7 +102,7 @@ mod tests { "Memory Version" ); // 3. Load from the database, which should overwrite the in-memory version. - let result = catalog2.load_by_class::(); + let result = catalog2.load::(); assert!(result.is_ok()); // 4. Verify that the in-memory entity has been replaced with the one from the DB. let len = catalog2.len().unwrap(); @@ -131,7 +131,7 @@ mod tests { let mut catalog = Catalog::new(db_path); catalog.init().unwrap(); // 2. Attempt to load from the empty DB. - let result = catalog.load_by_class::(); + let result = catalog.load::(); assert!(result.is_ok()); let is_empty = catalog.is_empty().unwrap(); assert!(is_empty); @@ -148,7 +148,7 @@ mod tests { let _ = catalog.upsert(item_in_memory.clone()); let len = catalog.len().unwrap(); assert_eq!(len, 1); - let result2 = catalog.load_by_class::(); + let result2 = catalog.load::(); assert!(result2.is_ok()); // 4. Verify the in-memory item is untouched because nothing was loaded from DB. let len = catalog.len().unwrap(); @@ -166,7 +166,7 @@ mod tests { std::fs::create_dir_all(invalid_path).unwrap(); let mut catalog = Catalog::new(invalid_path); // Attempt to load from the invalid path. - let result = catalog.load_by_class::(); + let result = catalog.load::(); assert!(result.is_err()); // Based on `load_by_id`, the error should be `LoadFromDB`. // This assumes `From` is implemented to produce `FailedTo::LoadFromDB`. diff --git a/01.workspace/heave/src/tst/catalog_persist.rs b/01.workspace/heave/src/tst/catalog_persist.rs index 5a9f6ec..faf5708 100644 --- a/01.workspace/heave/src/tst/catalog_persist.rs +++ b/01.workspace/heave/src/tst/catalog_persist.rs @@ -167,7 +167,7 @@ mod tests { catalog_setup.persist().unwrap(); // 2. Manipulation: Load the data and perform mixed operations. let mut catalog_ops = Catalog::new(db_path); - catalog_ops.load_by_class::().unwrap(); // Load all items + catalog_ops.load::().unwrap(); // Load all items // A new item to be inserted. let item_to_add = Item { id: "add-me".to_string(), @@ -197,7 +197,7 @@ mod tests { catalog_ops.persist().unwrap(); // 4. Verification: Load into a new catalog and check the final state of the DB. let mut catalog_verify = Catalog::new(db_path); - catalog_verify.load_by_class::().unwrap(); + catalog_verify.load::().unwrap(); // Check total count assert_eq!(catalog_verify.len().unwrap(), 3); // Verify added item diff --git a/01.workspace/heave/src/tst/catalog_thread_safety.rs b/01.workspace/heave/src/tst/catalog_thread_safety.rs index 0a3e515..c1d2c3e 100644 --- a/01.workspace/heave/src/tst/catalog_thread_safety.rs +++ b/01.workspace/heave/src/tst/catalog_thread_safety.rs @@ -40,7 +40,7 @@ mod tests { assert_eq!(total_items, 1000); catalog.persist().unwrap(); let mut new_catalog = Catalog::new(db_path); - new_catalog.load_by_class::().unwrap(); + new_catalog.load::().unwrap(); let total_items_after_load = new_catalog.with_items(|items| Ok(items.len())).unwrap(); assert_eq!(total_items_after_load, 1000); std::fs::remove_file(path).unwrap();