memea::export

Function export

Source
pub fn export(
    reports: &HashMap<String, Reports>,
    filename: &Option<PathBuf>,
) -> Result<(), MemeaError>
Expand description

Exports analysis results to various formats based on file extension.

This function determines the output format from the file extension and handles file creation with overwrite confirmation. Supported formats include CSV, JSON, YAML, and direct console output.

§Arguments

  • reports - HashMap of configuration names to their corresponding reports
  • filename - Optional output file path. If None, outputs to stdout

§Returns

  • Ok(()) - Export completed successfully
  • Err(MemeaError) - File I/O error, serialization error, or unsupported format

§Examples

use memea::export::export;
use std::path::PathBuf;
use std::collections::HashMap;

let reports = HashMap::new(); // populated with analysis results
let output_file = Some(PathBuf::from("results.csv"));
export(&reports, &output_file).expect("Export failed");