paft-domain 0.9.0

Domain modeling primitives (instrument, exchange, period, market state) for the paft ecosystem.
Documentation
//! Domain-specific error types for `paft-domain`.

use thiserror::Error;

/// Errors produced by domain models.
#[derive(Debug, Error, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub enum DomainError {
    /// Invalid period format provided for parsing.
    #[error(
        "Invalid period format: '{format}' - expected formats like '2023Q4', '2023', 'FY2023', '2023-12-31', or '12/31/2023'"
    )]
    InvalidPeriodFormat {
        /// The invalid format string that could not be parsed.
        format: String,
    },

    /// Invalid structured period year.
    #[error("Invalid period year: {year} - expected a year in 0..=9999")]
    InvalidPeriodYear {
        /// The invalid structured period year.
        year: i32,
    },

    /// Invalid structured period quarter.
    #[error("Invalid period quarter: {quarter} - expected a quarter in 1..=4")]
    InvalidPeriodQuarter {
        /// The invalid structured period quarter.
        quarter: u8,
    },

    /// Invalid horizon format provided for parsing.
    #[error("Invalid horizon format: '{format}' - expected forms like '7d', '1mo', or '1y'")]
    InvalidHorizonFormat {
        /// The invalid horizon string that could not be parsed.
        format: String,
    },

    /// Invalid horizon count.
    #[error("Invalid horizon count: {count} - expected a non-zero positive integer")]
    InvalidHorizonCount {
        /// The invalid horizon count.
        count: u32,
    },

    /// Invalid exchange token encountered while parsing.
    #[error("Invalid exchange value: '{value}'")]
    InvalidExchangeValue {
        /// The invalid exchange token.
        value: String,
    },

    /// Invalid asset kind token encountered while parsing.
    #[error("Invalid asset kind value: '{value}'")]
    InvalidAssetKindValue {
        /// The invalid asset kind token.
        value: String,
    },

    /// Invalid market state token encountered while parsing.
    #[error("Invalid market state value: '{value}'")]
    InvalidMarketStateValue {
        /// The invalid market state token.
        value: String,
    },

    /// Invalid ISIN encountered while parsing or validating.
    #[error("Invalid ISIN: '{value}'")]
    InvalidIsin {
        /// The original invalid ISIN input.
        value: String,
    },

    /// Invalid FIGI encountered while parsing or validating.
    #[error("Invalid FIGI: '{value}'")]
    InvalidFigi {
        /// The original invalid FIGI input.
        value: String,
    },

    /// Invalid symbol encountered while parsing or validating.
    #[error("Invalid symbol: '{value}'")]
    InvalidSymbol {
        /// The original invalid symbol input.
        value: String,
    },
}