#codegen #orm #proc-macro #macro-derive

macro prax-codegen

Procedural macros for code generation in the Prax ORM

7 releases (4 breaking)

Uses new Rust 2024

0.6.0 Feb 13, 2026
0.5.0 Jan 7, 2026
0.4.0 Dec 29, 2025
0.3.2 Dec 24, 2025
0.2.0 Dec 20, 2025

#2041 in Procedural macros


Used in 3 crates

MIT/Apache

1MB
20K SLoC

Procedural macros for the Prax ORM.

This crate provides compile-time code generation for Prax, transforming schema definitions into type-safe Rust code.

Macros

  • prax_schema! - Generate models from a .prax schema file
  • Model - Derive macro for manual model definition

Plugins

Code generation can be extended with plugins enabled via environment variables:

# Enable debug information
PRAX_PLUGIN_DEBUG=1 cargo build

# Enable JSON Schema generation
PRAX_PLUGIN_JSON_SCHEMA=1 cargo build

# Enable GraphQL SDL generation
PRAX_PLUGIN_GRAPHQL=1 cargo build

# Enable custom serialization helpers
PRAX_PLUGIN_SERDE=1 cargo build

# Enable runtime validation
PRAX_PLUGIN_VALIDATOR=1 cargo build

# Enable all plugins
PRAX_PLUGINS_ALL=1 cargo build

Example

// Generate models from schema file
prax::prax_schema!("schema.prax");

// Or manually define with derive macro
#[derive(prax::Model)]
#[prax(table = "users")]
struct User {
    #[prax(id, auto)]
    id: i32,
    #[prax(unique)]
    email: String,
    name: Option<String>,
}

prax-codegen

Procedural macro code generation for Prax ORM.

Overview

prax-codegen provides proc-macros for generating type-safe Rust code from Prax schema definitions.

Features

  • #[derive(Model)] macro for struct generation
  • prax_schema! macro for schema-based code generation
  • Plugin system for extensible code generation
  • Built-in plugins: debug, JSON Schema, GraphQL, serde, validator

Usage

use prax_codegen::prax_schema;

prax_schema!("prax/schema.prax");

// Generated code includes:
// - User struct with all fields
// - user module with filter functions
// - Type-safe query builders

Plugins

Enable plugins in your schema:

generator client {
    provider = "prax-rust"
    plugins  = ["graphql", "validator", "json-schema"]
}

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.

Dependencies

~18MB
~264K SLoC