dataload 0.1.1

A flexible data loading library for CSV and Excel files with automatic delimiter detection
Documentation
//! Error types for the dataload library.

use thiserror::Error;

/// All errors that can occur during data loading operations.
#[derive(Debug, Error)]
pub enum DataLoadError {
    /// The file content was not valid UTF-8.
    #[error("invalid UTF-8 in file content: {0}")]
    Utf8(#[from] std::str::Utf8Error),

    /// An error occurred in the Polars library.
    #[error("polars error: {0}")]
    Polars(#[from] polars::prelude::PolarsError),

    /// An error occurred while reading an Excel file.
    #[cfg(feature = "excel")]
    #[error("excel parsing error: {0}")]
    Excel(#[from] calamine::Error),

    /// The file type is not supported.
    #[error("unsupported file type: {0}")]
    UnsupportedFileType(String),

    /// No sheets were found in the Excel workbook.
    #[error("no sheets found in excel file")]
    NoSheetsFound,

    /// The file is empty or contains no data.
    #[error("file is empty or contains no data")]
    EmptyFile,

    /// An I/O error occurred.
    #[error("I/O error: {0}")]
    Io(#[from] std::io::Error),

    /// Failed to detect a valid delimiter for CSV parsing.
    #[error("could not detect a valid delimiter in CSV file")]
    DelimiterDetectionFailed,
}

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