pub fn export_items(
items: &[Item],
format: &ExportFormat,
output_path: &Path,
) -> Result<()>Expand description
Exports a list of items to a specified file format and writes the output to a given file path.
§Arguments
items- A slice ofItemobjects to be exported.format- The export format, represented as anExportFormatenum. Possible formats include:ExportFormat::Json- Exports the data in JSON format.ExportFormat::Csv- Exports the data in CSV format.ExportFormat::ChamberBackup- Exports the data in a custom chamber backup format.
output_path- The file path where the exported data will be saved.
§Returns
Result<()>- ReturnsOk(())if the export operation succeeds, or anErrif an error occurs.
§Errors
This function will return an error in any of the following cases:
- The specified
output_pathis invalid or inaccessible. - An I/O error occurs while writing to the file.
- Serialization to the chosen export format fails.
§Note
Ensure that the directory specified in output_path exists and has write permissions before calling this function.