vyre-build-scan 0.1.0

Build-time filesystem scanner for flat trait-impl registries
Documentation
  • Coverage
  • 100%
    15 out of 15 items documented0 out of 0 items with examples
  • Size
  • Source code size: 48.13 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.98 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 49s Average build duration of successful builds.
  • all releases: 49s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • santhsecurity

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

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)

pub struct Atomics;
impl crate::gates::EnforceGate for Atomics {}
pub const GATE: Atomics = Atomics;

3. Parent module (src/gates/mod.rs)

automod::dir!(pub "src/gates");
include!(concat!(env!("OUT_DIR"), "/gates_registry.rs"));

4. Generated constant

$OUT_DIR/gates_registry.rs emits:

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.