mod mapper; mod parsers; use domain::{ models::{AnnotatedRow, FieldMapping, FileFormat, ImportError, ParsedFile}, ports::DocumentParser, }; pub struct ImporterDocumentParser; impl DocumentParser for ImporterDocumentParser { fn parse(&self, bytes: &[u8], format: FileFormat) -> Result { match format { FileFormat::Csv => parsers::parse_csv(bytes), FileFormat::Json => parsers::parse_json(bytes), FileFormat::Xlsx => { #[cfg(feature = "xlsx")] { parsers::parse_xlsx(bytes) } #[cfg(not(feature = "xlsx"))] { Err(ImportError::Xlsx("XLSX support not compiled in".into())) } } } } fn apply_mapping(&self, file: &ParsedFile, mappings: &[FieldMapping]) -> Vec { mapper::apply_mapping(file, mappings) } }