feature-flag 0.1.0

Server-side feature flag evaluation for async Rust: targeting rules, sticky percentage rollouts, hot reload, zero RNG.
Documentation
//! Crate-wide error type.

use std::path::PathBuf;

use thiserror::Error;

/// Anything that can go wrong inside the crate.
#[derive(Debug, Error)]
pub enum FeatureFlagError {
    /// Failed to parse a JSON flagset.
    #[error("failed to parse flagset: {0}")]
    Parse(#[from] serde_json::Error),

    /// Failed to read a flagset file.
    #[error("failed to read flagset {path:?}: {source}")]
    Io {
        /// Path the caller was reading.
        path: PathBuf,
        /// Underlying io error.
        #[source]
        source: std::io::Error,
    },

    /// The flagset is structurally valid but invalid as a logical config
    /// (e.g. a rollout that totals > 100, a variant referenced from a rule
    /// that doesn't appear in the flag's variants list).
    #[error("invalid flagset: {0}")]
    Invalid(String),

    /// Asked to evaluate a flag that isn't in the loaded flagset. The caller's
    /// default value is returned via the `Evaluation::Default` outcome.
    #[error("unknown flag: {0}")]
    UnknownFlag(String),
}