use std::path::PathBuf;
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
#[non_exhaustive]
pub enum ExportFormat {
Csv,
Xlsx,
Parquet,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(default, deny_unknown_fields)]
pub struct ExportConfig {
pub csv_delimiter: char,
pub csv_include_bom: bool,
pub xlsx_max_rows: u64,
pub parquet_max_rows: u64,
pub xlsx_temp_dir: Option<PathBuf>,
pub max_concurrent_xlsx: usize,
pub export_formats: Vec<ExportFormat>,
}
impl Default for ExportConfig {
fn default() -> Self {
Self {
csv_delimiter: ',',
csv_include_bom: true,
xlsx_max_rows: 100_000,
parquet_max_rows: 1_000_000,
xlsx_temp_dir: None,
max_concurrent_xlsx: 10,
export_formats: vec![ExportFormat::Csv, ExportFormat::Xlsx, ExportFormat::Parquet],
}
}
}
impl ExportConfig {
#[must_use]
pub fn serves(&self, format: ExportFormat) -> bool {
self.export_formats.contains(&format)
}
}