Expand description
gen-macros — proc-macros that auto-implement the universal
gen_types::ecosystem traits.
Materializes the Pillar 12 directive (generation over composition):
a new package-manager adapter declares its typed shapes and the
macros emit the Spec / QuirkRegistry impls. The author writes
N lines of typed data; the trait surface is mechanical.
See theory/ECOSYSTEM-INTAKE.md § “The macros” for the contract.
ⓘ
#[derive(SpecShape, serde::Serialize, serde::Deserialize)]
#[spec(args = "BuildRustCrateArgs", quirk = "CrateQuirk")]
pub struct BuildSpec {
pub version: u32,
pub crates: indexmap::IndexMap<String, CrateSpec>,
pub root_crate: String,
pub workspace_members: Vec<String>,
}emits:
ⓘ
impl gen_types::Spec for BuildSpec {
type Args = BuildRustCrateArgs;
type Quirk = CrateQuirk;
fn schema_version(&self) -> u32 { self.version }
fn root_key(&self) -> &str { self.root_crate.as_str() }
fn member_keys(&self) -> Vec<&str> { self.workspace_members.iter().map(String::as_str).collect() }
fn args_for(&self, key: &str) -> Option<&Self::Args> {
self.crates.get(key).map(|c| &c.build_rust_crate_args)
}
fn quirks_for(&self, key: &str) -> &[Self::Quirk] {
self.crates.get(key).map(|c| c.quirks.as_slice()).unwrap_or(&[])
}
}Attribute Macros§
- fsm
- Attribute macro that bundles the typed-FSM derive quintet + serde tag + catalog registration. Use on a closed enum:
Derive Macros§
- Backend
Error #[derive(BackendError)]— auto-implement a trait with the shape:- Discriminant
#[derive(Discriminant)]— auto-implementpub const fn <method>(&self) -> &'static strreturning the variant name as a stable case-folded identifier.- From
StrKind #[derive(FromStrKind)]— the inverse of Discriminant. Parses a string back to a variant using the same case-folded variant name. Only unit variants are supported (data variants need caller-supplied payloads — out of scope for a string-only parse).- IsVariant
#[derive(IsVariant)]— auto-implementpub const fn is_<variant>(&self) -> boolfor every variant.- Outcome
Lattice #[derive(OutcomeLattice)]— auto-implement an OutcomeLattice trait from per-variant severity attributes.- Quirk
Registry #[derive(QuirkRegistry)]— auto-implementgen_types::QuirkRegistryon a marker struct that points at the real registry function.- Spec
Shape #[derive(SpecShape)]— auto-implementgen_types::Specon a struct whose fields follow the conventional gen build-spec shape:- Typed
Dispatcher #[derive(TypedDispatcher)]— auto-implementgen_types::TypedDispatcheron a Rust enum whose serde tag is#[serde(tag = "kind", rename_all = "kebab-case")].