openprxl 0.1.0

A Rust spreadsheet library inspired by Python's openpyxl
Documentation
//! Error and result types for `openprxl`.

/// The main error type returned by `openprxl` operations.
#[derive(Debug, thiserror::Error)]
pub enum Error {
    /// An I/O error occurred while reading or writing a file.
    #[error("io error: {0}")]
    Io(#[from] std::io::Error),

    /// An error occurred while processing the zip archive.
    #[error("zip error: {0}")]
    Zip(#[from] zip::result::ZipError),

    /// An XML parsing or serialization error occurred.
    #[error("xml error: {0}")]
    Xml(#[from] quick_xml::Error),

    /// A string reference could not be parsed.
    #[error("invalid reference: {0}")]
    InvalidReference(String),

    /// A worksheet name is invalid or already exists.
    #[error("invalid worksheet name: {0}")]
    InvalidWorksheetName(String),

    /// A worksheet was not found by name or index.
    #[error("worksheet not found: {0}")]
    WorksheetNotFound(String),

    /// A requested cell or range is out of supported bounds.
    #[error("cell out of bounds: {0}")]
    OutOfBounds(String),

    /// A shared string was not found in the shared string table.
    #[error("shared string not found at index {0}")]
    SharedStringNotFound(usize),

    /// A style id referenced by a cell is invalid.
    #[error("invalid style id {0}")]
    InvalidStyleId(usize),

    /// A date value could not be converted to/from an Excel serial date.
    #[error("date conversion error: {0}")]
    DateConversion(String),

    /// A generic error with a message.
    #[error("{0}")]
    Message(String),
}

/// A specialized `Result` type for `openprxl` operations.
pub type Result<T> = std::result::Result<T, Error>;

impl Error {
    /// Create a generic error from a message.
    pub fn msg<S: Into<String>>(msg: S) -> Self {
        Self::Message(msg.into())
    }
}