zenmanage 1.0.0

Official Zenmanage feature flags SDK for Rust
Documentation
use thiserror::Error;

/// Error type for all Zenmanage SDK operations.
#[derive(Debug, Error)]
#[non_exhaustive]
pub enum ZenmanageError {
    /// The SDK was configured incorrectly.
    #[error("configuration error: {0}")]
    Configuration(String),

    /// A flag couldn't be evaluated, for example because it doesn't exist and has no default.
    #[error("evaluation error: {0}")]
    Evaluation(String),

    /// The rules couldn't be fetched.
    #[error("failed to fetch rules: {message}")]
    FetchRules {
        /// What went wrong.
        message: String,
        /// The HTTP status, when the API answered.
        status_code: Option<u16>,
    },

    /// The API returned something that couldn't be read.
    #[error("invalid rules payload: {0}")]
    InvalidRules(String),

    /// A cache backend failed.
    #[error("cache error: {0}")]
    Cache(String),

    /// A request couldn't be sent or its response couldn't be read.
    #[error("network error: {0}")]
    Network(String),

    /// JSON couldn't be written or read.
    #[error("serialization error: {0}")]
    Serialization(#[from] serde_json::Error),

    /// A file couldn't be read or written.
    #[error("io error: {0}")]
    Io(#[from] std::io::Error),
}

/// The result type returned by the SDK.
pub type Result<T> = std::result::Result<T, ZenmanageError>;