Skip to main content

Module codegen

Module codegen 

Source
Expand description

Proc-macro code generation.

This module generates the actual proc-macro code from resolved definitions.

§Generated Code Structure

The generated code creates attribute macros that:

  1. Parse the input item (struct/enum)
  2. Apply configured derives and attributes
  3. Handle runtime modifiers (add, omit, omit_attrs)

§Example Output

For a definition like:

[defs.serialization]
traits = ["Clone", "Serialize", "Deserialize"]
attrs = ['#[serde(rename_all = "camelCase")]']

The generated code will be:

#[proc_macro_attribute]
pub fn serialization(
    args: TokenStream,
    input: TokenStream,
) -> TokenStream {
    // Parse modifiers from args
    // Apply derives and attrs to input
}

Functions§

generate
Generate proc-macro code to the default OUT_DIR.
generate_to
Generate proc-macro code to a specific output path.