# vyre-build-scan
Build-time filesystem scanner for flat trait-impl registries.
## What this crate does
`vyre-build-scan` turns a flat directory of `.rs` files into a typed, static registry constant at build time. The contributor drops a new file into the scanned directory and runs `cargo build`. No `mod.rs` edits, no central arrays, no linker tricks. The filesystem is the registry.
## Usage
**1. `build.rs`**
```rust
fn main() {
vyre_build_scan::scan(&vyre_build_scan::Registry {
scan_dir: "src/gates",
const_name: "ALL_GATES",
element_type: "&dyn crate::gates::EnforceGate",
item_const_name: "GATE",
output_file: "gates_registry.rs",
module_prefix: "crate::gates",
});
}
```
**2. Leaf file** (`src/gates/atomics.rs`)
```rust
pub struct Atomics;
impl crate::gates::EnforceGate for Atomics {}
pub const GATE: Atomics = Atomics;
```
**3. Parent module** (`src/gates/mod.rs`)
```rust
automod::dir!(pub "src/gates");
include!(concat!(env!("OUT_DIR"), "/gates_registry.rs"));
```
**4. Generated constant**
`$OUT_DIR/gates_registry.rs` emits:
```rust
pub static ALL_GATES: &[&dyn crate::gates::EnforceGate] = &[
&crate::gates::atomics::GATE,
&crate::gates::barrier::GATE,
];
```
Access it anywhere in the crate as `crate::gates::ALL_GATES`.
## Why it exists
Central lists create merge conflicts. Every new gate, backend, or rule fights for the same line in `mod.rs` or the same slot in a global array. `vyre-build-scan` removes the contention entirely: the filesystem is the registry. Drop a file, expose a `pub const`, and the next build wires it in. Pure build-time codegen, zero runtime overhead, no linker-section magic.
## Example scenarios
- **Enforcement gates**: one file per gate, `ALL_GATES` drives a validation pipeline.
- **Plugin backends**: one file per backend, `ALL_BACKENDS` populates a static dispatcher.
- **Detection rules**: one file per rule, `ALL_RULES` feeds a scanning engine.
## License
MIT OR Apache-2.0.