ltfi-wsap 2.0.2

LTFI-WSAP (Layered Transformer Framework Intelligence - Web System Alignment Protocol) Rust SDK
Documentation
use std::fmt;

/// Error types for the LTFI-WSAP SDK
#[derive(Debug)]
pub enum Error {
    /// Authentication error (missing or invalid API key)
    Authentication(String),
    /// Network error (connection issues)
    Network(String),
    /// API error (HTTP status code and message)
    Api(u16, String),
    /// JSON parsing error
    Parse(String),
    /// Validation error
    Validation(String),
}

impl fmt::Display for Error {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        match self {
            Error::Authentication(msg) => write!(f, "Authentication error: {}", msg),
            Error::Network(msg) => write!(f, "Network error: {}", msg),
            Error::Api(code, msg) => write!(f, "API error ({}): {}", code, msg),
            Error::Parse(msg) => write!(f, "Parse error: {}", msg),
            Error::Validation(msg) => write!(f, "Validation error: {}", msg),
        }
    }
}

impl std::error::Error for Error {}

/// Result type alias for the SDK
pub type Result<T> = std::result::Result<T, Error>;