invariance 0.1.1

A Rust crate providing type-safe, validated configuration to prevent runtime crashes from invalid config data.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use crate::error::ConfigError;

/// Trait for validating configuration types.
///
/// By default, validation passes with no error.
/// Override `validate` to implement custom invariants.
///
/// If not overridden, the config is considered valid.
pub trait Validate {
    /// Perform validation checks on the configuration.
    ///
    /// Returns `Ok(())` if the config is valid,
    /// or a `ConfigError` describing the failure.
    fn validate(&self) -> Result<(), ConfigError> {
        Ok(())
    }
}