doc: add doc comments for delete and improve doc comment for persist

This commit is contained in:
2025-10-06 14:50:15 +02:00
parent 8c0afe0c9c
commit 5c4562afc2

View File

@@ -138,6 +138,11 @@ impl O {
.map(|item| T::from(item.clone())) .map(|item| T::from(item.clone()))
} }
/// Schedules an entity for deletion. Actual delition will take place when 'persist' is called.
///
/// # Arguments
///
/// * `id` - The ID of the entity to delete.
pub fn delete(&mut self, id: &str) { pub fn delete(&mut self, id: &str) {
let entity = self.items.get_mut(id); let entity = self.items.get_mut(id);
if let Some(entity) = entity { if let Some(entity) = entity {
@@ -146,6 +151,9 @@ impl O {
} }
/// Persists the current state of the catalog to the database. /// Persists the current state of the catalog to the database.
///
/// - new entities will be written onto DB
/// - marked for delition entities will be deleted
pub fn persist(&self) -> result::Result<(), FailedTo> { pub fn persist(&self) -> result::Result<(), FailedTo> {
let path = path::Path::new(&self.path); let path = path::Path::new(&self.path);
sqlite::persist::catalog(path, self).map_err(|_| FailedTo::PersistCatalog)?; sqlite::persist::catalog(path, self).map_err(|_| FailedTo::PersistCatalog)?;