Save a specific catalog to storage Saves the state of a single catalog to storage using the catalog's save method. # Arguments `catalog_name` - Name of the catalog to save # Returns `Ok(())` if catalog saved successfully `Err(CatalogError::CatalogNotFound)` if catalog doesn't exist `Err(CatalogError)` if save operation fails
(&self, catalog_name: &str)
| 129 | /// * `Err(CatalogError::CatalogNotFound)` if catalog doesn't exist |
| 130 | /// * `Err(CatalogError)` if save operation fails |
| 131 | pub fn save_catalog(&self, catalog_name: &str) -> CatalogResult<()> { |
| 132 | let catalog = self |
| 133 | .catalogs |
| 134 | .get(catalog_name) |
| 135 | .ok_or_else(|| CatalogError::CatalogNotFound(catalog_name.to_string()))?; |
| 136 | |
| 137 | let data = catalog.save().map_err(|e| { |
| 138 | CatalogError::OperationFailed(format!( |
| 139 | "Failed to save catalog '{}': {}", |
| 140 | catalog_name, e |
| 141 | )) |
| 142 | })?; |
| 143 | |
| 144 | // Save catalog provider data to storage |
| 145 | self.storage |
| 146 | .save_catalog_provider(catalog_name, &data) |
| 147 | .map_err(|e| { |
| 148 | CatalogError::OperationFailed(format!( |
| 149 | "Failed to persist catalog '{}': {}", |
| 150 | catalog_name, e |
| 151 | )) |
| 152 | })?; |
| 153 | |
| 154 | log::debug!("Saved catalog '{}': {} bytes", catalog_name, data.len()); |
| 155 | Ok(()) |
| 156 | } |
| 157 | |
| 158 | /// Save all catalogs to storage |
| 159 | /// |
no test coverage detected