use stemedb_storage::StorageError;
use stemedb_wal::QuarantineError;
use thiserror::Error;

/// Result type for ingestion operations.
pub type Result<T> = std::result::Result<T, IngestError>;

/// Errors that can occur during ingestion.
#[derive(Error, Debug)]
pub enum IngestError {
    /// Error from the WAL.
    #[error("WAL error: {0}")]
    Wal(#[from] QuarantineError),

    /// Error from the storage engine.
    #[error("Storage error: {0}")]
    Storage(#[from] StorageError),

    /// Serialization/Deserialization error.
    #[error("Serialization error: {0}")]
    Serialization(String),

    /// Worker task panicked or failed.
    #[error("Worker error: {0}")]
    Worker(String),

    /// Invalid cryptographic signature on assertion.
    #[error("Invalid signature: {0}")]
    InvalidSignature(String),

    /// Input validation failed (e.g., out-of-range values, oversized fields).
    #[error("Input validation failed: {0}")]
    InputValidation(String),
}
