br-invoice-parser 0.1.10

A Rust library for parsing invoices and bills from PDF and XLSX files
Documentation
use thiserror::Error;

#[derive(Error, Debug)]
pub enum InvoiceParserError {
    #[error("Failed to read file: {0}")]
    FileReadError(#[from] std::io::Error),

    #[error("PDF extraction failed: {0}")]
    PdfExtractionError(String),

    #[error("XLSX parsing failed: {0}")]
    XlsxParsingError(String),

    #[error("Invalid file format: expected {expected}, got {actual}")]
    InvalidFileFormat { expected: String, actual: String },

    #[error("Failed to parse date: {0}")]
    DateParseError(String),

    #[error("Failed to parse amount: {0}")]
    AmountParseError(String),

    #[error("Missing required field: {0}")]
    MissingField(String),

    #[error("Regex pattern error: {0}")]
    RegexError(#[from] regex::Error),

    #[error("JSON serialization error: {0}")]
    JsonError(#[from] serde_json::Error),

    #[error("Unsupported file type: {0}")]
    UnsupportedFileType(String),

    #[error("Empty document: no content found")]
    EmptyDocument,

    #[error("Parse error: {0}")]
    ParseError(String),
}

pub type Result<T> = std::result::Result<T, InvoiceParserError>;