| Crates.io | invariance |
| lib.rs | invariance |
| version | 0.1.2 |
| created_at | 2025-08-17 16:53:21.344787+00 |
| updated_at | 2025-08-18 16:33:24.03195+00 |
| description | A Rust crate providing type-safe, validated configuration to prevent runtime crashes from invalid config data. |
| homepage | https://github.com/ParkBlake/invariance |
| repository | https://github.com/ParkBlake/invariance |
| max_upload_size | |
| id | 1799575 |
| size | 32,347 |
A Rust crate providing type-safe, validated configuration for preventing runtime crashes caused by invalid config data.
invariance helps you define configuration structs with strong typing and validation logic. It ensures that configurations loaded from files (currently TOML and JSON) are always validated before use, preventing null pointer errors, invalid states, and unexpected runtime failures.
The crate provides:
A Config trait with default implementations for parsing configuration from strings in multiple formats (currently TOML and JSON), enabling flexible config loading without boilerplate.
A Validate trait for implementing custom, domain-specific validation logic to enforce invariants and prevent invalid config states at runtime.
Clear and descriptive error handling with the ConfigError type, supporting error chaining and categorisation for easier debugging and reporting.
Basic schema generation by printing default configuration instances as example outputs in both JSON and TOML formats.
To use invariance in your Rust project, add it to your Cargo.toml using:
cargo add invariance