Skip to main content

Crate gen_macros

Crate gen_macros 

Source
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§

BackendError
#[derive(BackendError)] — auto-implement a trait with the shape:
Discriminant
#[derive(Discriminant)] — auto-implement pub const fn <method>(&self) -> &'static str returning the variant name as a stable case-folded identifier.
FromStrKind
#[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-implement pub const fn is_<variant>(&self) -> bool for every variant.
OutcomeLattice
#[derive(OutcomeLattice)] — auto-implement an OutcomeLattice trait from per-variant severity attributes.
QuirkRegistry
#[derive(QuirkRegistry)] — auto-implement gen_types::QuirkRegistry on a marker struct that points at the real registry function.
SpecShape
#[derive(SpecShape)] — auto-implement gen_types::Spec on a struct whose fields follow the conventional gen build-spec shape:
TypedDispatcher
#[derive(TypedDispatcher)] — auto-implement gen_types::TypedDispatcher on a Rust enum whose serde tag is #[serde(tag = "kind", rename_all = "kebab-case")].