prax-codegen 0.2.0

Procedural macros for code generation in the Prax ORM
Documentation

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>,
}