| Crates.io | praborrow-defense |
| lib.rs | praborrow-defense |
| version | 1.2.2 |
| created_at | 2026-01-09 15:08:05.446472+00 |
| updated_at | 2026-01-14 03:30:58.122745+00 |
| description | Procedural macros for invariant verification. Generates runtime checks and SMT-based formal verification. |
| homepage | |
| repository | https://github.com/ireddragonicy/PraBorrow |
| max_upload_size | |
| id | 2032224 |
| size | 43,767 |
English | Indonesia
Procedural macros for the "Garuda" invariant verification system. This crate generates runtime checks to enforce constitutional integrity on data structures.
Derive Constitution on your structs and use the #[invariant] attribute to define validation logic.
use praborrow_defense::Constitution;
use praborrow_core::CheckProtocol; // Trait definition
#[derive(Constitution)]
struct StateBudget {
#[invariant(self.amount > 0)]
amount: i32,
#[invariant(self.year >= 2024)]
year: i32,
}
fn main() {
let budget = StateBudget { amount: 1000, year: 2025 };
budget.enforce_law(); // Passes
let corrupt = StateBudget { amount: -50, year: 2025 };
// corrupt.enforce_law(); // Panics: "CONSTITUTIONAL CRISIS"
}
The macro generates an implementation of the CheckProtocol trait. Note that CheckProtocol must be in scope.