Skip to main content

export_items

Function export_items 

Source
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 of Item objects to be exported.
  • format - The export format, represented as an ExportFormat enum. 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<()> - Returns Ok(()) if the export operation succeeds, or an Err if an error occurs.

§Errors

This function will return an error in any of the following cases:

  • The specified output_path is 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.