annotate-rs
annotate is a Rust annotation and reflection framework.
- mark functions and modules with
#[pragma(...)] - create custom annotations
- attach structured metadata such as strings, booleans, integers, and Rust types
- generate a static annotation environment during
build.rs - query annotated items at runtime with predicates over modules and functions
- call discovered functions when their signature is known
The workspace is split into:
annotate: runtime API and public macro re-exportsannotate-build: build-time scanner and code generatorannotate-derive: procedural macro implementation
Installation
Add annotate to your crate dependencies and annotate-build to your build dependencies:
[]
= "x.y.z"
[]
= "x.y.z"
Quick Start
Create a build.rs file that scans the crate and generates the annotation environment:
Annotate functions or modules in your crate and include the generated environment:
environment!;
Query the functions at runtime:
use Value;
Querying modules by associated type:
environment!;
What Gets Generated
At build time, annotate-build scans the crate source and generates a static Environment containing:
- annotated functions
- annotated modules
- their paths
- their attributes
- links between modules and functions
The generated Rust code is written into OUT_DIR and included through annotate::environment!().
Limitations
#[pragma]currently supports functions and modules only.- Calling discovered functions still requires the caller to know the exact function signature.
- Dynamic return support is limited and primarily intended for zero-argument functions.
- Build-time code generation is required; this crate is not purely macro-only.
License
Copyright feenk gmbh.
Licensed under MIT. See LICENSE.