| Crates.io | zetamesh_flags |
| lib.rs | zetamesh_flags |
| version | 0.1.0 |
| created_at | 2026-01-13 22:45:05.075253+00 |
| updated_at | 2026-01-13 22:45:05.075253+00 |
| description | zetamesh-flags is a minimal Rust library for rule-based validation of state combinations |
| homepage | |
| repository | https://github.com/grkmgny/zetamesh-flags.git |
| max_upload_size | |
| id | 2041587 |
| size | 35,238 |
zetamesh-flags is a minimal Rust library for rule-based validation of state combinations.
It provides a small, deterministic core for enforcing consistency rules between named states without introducing a full state machine or workflow engine.
This crate is designed to be embedded as a foundational component in larger systems.
Early development. The API is not yet stable and may change before a 1.0 release.
Many systems maintain internal states such as:
Over time, it becomes easy to accidentally allow invalid combinations:
zetamesh-flags prevents these situations by construction.
The library manages a set of named flags (states) and a set of validation rules.
Rules describe relationships between states, such as:
All rules are evaluated together, every time a state change is attempted.
All rules in a FlagSet are enforced atomically.
If any rule is violated:
FlagSet state is not modifiedThis behavior is intentional and guaranteed.
The following rule types are currently supported:
Additional rule types may be introduced in the future, but the library will remain focused on static consistency constraints, not dynamic behavior.
Result)Operations that may violate rules return a Result:
Ok(()) → the operation was valid and appliedErr(reason) → the operation was rejectedImportant guarantee:
If an operation returns
Err, the internal state is unchanged.
Ignoring a returned Result does not corrupt state.
Doing so is considered a caller-side logic error, not a library bug.
This library is intentionally not:
It focuses strictly on state consistency, not control flow.
use zetamesh_flags::{FlagSet, Rule};
let mut service = FlagSet::new();
service.add_flag("Initialized");
service.add_flag("Running");
service.add_rule(Rule::dependency("Running", "Initialized"));
// Rejected: Running requires Initialized
assert!(service.activate("Running").is_err());
// State is still valid and unchanged
assert!(service.is_valid());
service.activate("Initialized").unwrap();
service.activate("Running").unwrap();
Add the crate to your project using Cargo:
cargo add zetamesh-flags
Or by editing your Cargo.toml directly:
[dependencies]
zetamesh-flags = "0.1"
This crate has no external runtime dependencies and is suitable for embedding in low-level or performance-sensitive systems.
zetamesh-flags follows Semantic Versioning (SemVer) with the following policy:
During the 0.x phase:
CHANGELOG.md.Consumers are encouraged to:
0.1.*) if stability is required.This project is licensed under the Apache License, Version 2.0.
See the LICENSE file for full details.