paramdef
Universal Form Schema System for Rust โ Define once, use everywhere
Like Zod + React Hook Form for TypeScript, but for Rust with compile-time safety. Inspired by Blender RNA, Unreal UPROPERTY, and Qt Property System.
The missing link between backend schemas and frontend forms in Rust.
Overview
paramdef is a form schema definition system that works across your entire stack:
- ๐ง Backend: Define schemas in Rust, validate API requests, generate OpenAPI specs
- ๐จ Frontend: Same schemas render forms in WASM (Leptos, Yew, Dioxus)
- โ๏ธ CLI: Interactive prompts and configuration wizards
- ๐ฎ Tools: Property editors, node-based workflows, no-code builders
Not just validation โ Rich metadata, layout hints, and semantic types built-in.
Quick Start
use *;
// Define parameter schema
let schema = builder
.parameter
.parameter
.parameter
.build;
// Create runtime context
let mut ctx = new;
// Set and get values
ctx.set;
ctx.set;
assert_eq!;
Why paramdef?
๐ vs JSON Schema + React JSON Schema Form
- โ Type-safe: Compile-time validation, not just runtime
- โ Universal: Backend, frontend (WASM), CLI โ not just React
- โ Rich types: 23 semantic types (Mode, Vector, Matrix, etc.) vs 7 JSON primitives
- โ Layout system: Built-in Panel/Group organization
๐ vs Zod + React Hook Form
- โ Backend-first: Perfect for Rust servers generating forms
- โ Zero overhead: Many checks at compile-time, not runtime
- โ Units system: Physical units (Meters, Celsius, Pixels) built-in
- โ Discriminated unions: Native Mode containers, not workarounds
๐ vs Bevy Reflection
- โ Not tied to ECS: Use in any project, not just game engines
- โ Form-oriented: Labels, descriptions, groups out of the box
- โ Schema/Runtime split: Immutable definitions, mutable state
๐ vs validator/garde
- โ Not just validation: Full schema definition with UI metadata
- โ Form generation: Render forms automatically from schemas
- โ Layout hints: Panel, Group, Decoration types for UI structure
โก One Schema, Everywhere
// Define once
let user_form = builder
.field
.field
.build;
// Use in Axum backend
async
// Render in Leptos frontend
// Interactive CLI prompt
Key Features
๐๏ธ Three-Layer Architecture
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Schema Layer (Immutable) โ โ Shared definitions (Arc)
โ - Metadata, flags, validators โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Runtime Layer (Mutable) โ โ Per-instance state
โ - Current values, dirty flags โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Value Layer โ โ Runtime representation
โ - Unified Value enum โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ 23 Node Types
| Category | Own Value | Children | Types |
|---|---|---|---|
| Group | โ | โ | 2 - Root aggregators |
| Decoration | โ | โ | 8 - Display elements |
| Container | โ | โ | 7 - Structured data |
| Leaf | โ | โ | 6 - Terminal values |
Leaf Types: Text, Number, Boolean, Vector, Select, File Containers: Object, List, Mode, Matrix, Routing, Expirable, Reference Decorations: Notice, Separator, Link, Code, Image, Html, Video, Progress Group: Group, Panel
๐ฏ Type-Safe Subtypes
Compile-time constraints for specialized parameters:
use ;
use ;
// Email validation (compile-time enforced)
let email: = email;
// Port numbers (integer-only)
let port: = port
.default
.build;
// Percentage (float-only, 0-100 range)
let opacity: = percentage
.default
.build;
// Fixed-size vectors (compile-time size)
let position =
.default
.build;
๐ง Blender-Style Subtype + Unit Pattern
Separate semantic meaning from measurement system:
use NumberUnit;
// Subtype = WHAT it is (semantic)
// Unit = HOW to measure (system)
let distance = builder
.unit
.default
.build;
// 60 subtypes ร 17 unit categories = powerful combinations!
๐ Performance
Excellent performance characteristics:
- Schema creation: ~100-500ns per parameter
- Context (100 params): ~50ยตs initialization
- Runtime node: ~200ns creation
- Container ops: ~2-10ยตs for nested structures
Optimizations:
SmartStringfor stack-allocated short strings (<23 bytes)Arcfor cheap cloning of immutable data- Const generics for fixed-size vectors (on stack, no heap)
Feature Flags
[]
= { = "0.2", = ["serde", "validation"] }
| Feature | Description |
|---|---|
serde |
Serialization/deserialization support |
validation |
Validation system with custom validators |
visibility |
Visibility conditions and expressions |
events |
Event system with tokio channels |
i18n |
Internationalization with Fluent |
chrono |
Chrono type conversions |
full |
Enable all features |
Core library has zero UI dependencies - works headless (servers, CLI).
Examples
Complex Nested Schemas
use Object;
use ;
let address = builder
.field
.field
.field
.build
.unwrap;
let user = builder
.field
.field
.field
.field
.build
.unwrap;
Mode Container (Discriminated Unions)
use Mode;
// Output can be file, database, or API
let output = builder
.variant
.variant
.variant
.build
.unwrap;
// Runtime value: {"mode": "database", "value": {...}}
Using Flags
use Flags;
let password = builder
.flags
.build;
assert!;
assert!;
Real-World: Workflow Engine Node
use Object;
use ;
use NumberUnit;
// Image resize node with rich metadata
let resize_node = builder
.field
.field
.field
.build
.unwrap;
// โ
Backend validates incoming JSON
// โ
Frontend renders form with labels, units, tooltips
// โ
CLI creates interactive wizard
Real-World: Scientific Tool with Units
use NumberUnit;
// Physics simulation parameters
let simulation = builder
.field
.field
.field
.build
.unwrap;
// Units displayed in UI: "60 s", "20 ยฐC", "1 kg"
Real-World: Admin Panel CRUD Form
// Single schema definition works everywhere!
let product_form = builder
.field
.field
.field
.field
.build
.unwrap;
// โ
Axum/Actix: Validate POST /api/products
// โ
Leptos/Yew: Render create/edit forms
// โ
OpenAPI: Generate spec automatically
Architecture
Node Categories
Group (2 types)
- Root aggregators with NO own value
- Provides
ValueAccessat runtime - Types: Group, Panel
- Can contain: Decoration, Container, Leaf
Decoration (8 types)
- Display-only, NO value, NO children
- Types: Notice, Separator, Link, Code, Image, Html, Video, Progress
Container (7 types)
- HAS own value + children
- Provides
ValueAccessat runtime - Types: Object, List, Mode, Matrix, Routing, Expirable, Reference
Leaf (6 types)
- Terminal values, NO children
- Types: Text, Number, Boolean, Vector, Select, File
Current Status
Version 0.2.0 - Production-Ready Core
โ Complete:
- Core schema system - 23 semantic types (Group, Container, Leaf, Decoration)
- Type safety - Compile-time constraints via subtypes (Port, Email, Percentage, etc.)
- Blender-style units - 60 subtypes ร 17 unit categories
- Three-layer architecture - Schema (immutable) / Runtime (mutable) / Value
- Rich metadata - Labels, descriptions, groups, icons, tooltips
- Zero-warning build - Production-ready code quality
๐ง Coming Soon (v0.3):
- Form renderers - Leptos, Yew, Dioxus bindings
- OpenAPI generation - Auto-generate specs from schemas
- CLI prompts - Interactive wizards via
dialoguerintegration - Validation - Custom validators, async validation
- Serialization - Full serde support with JSON Schema export
๐ฎ Roadmap (v0.4+):
- Event system - Undo/redo, change tracking
- Visibility expressions - Conditional fields (show/hide based on values)
- i18n - Fluent integration for multilingual forms
- UI theming - CSS-in-Rust styling hints
๐ Documentation:
- 18 comprehensive design documents in
docs/ - Full API documentation on docs.rs
- Real-world examples and cookbook
Installation
Add to your Cargo.toml:
[]
= "0.2"
Ecosystem Integrations
paramdef is designed to be a universal foundation for parameter systems across different ecosystems:
๐ Workflow Engines (like n8n, Temporal)
// Each node in your workflow has a paramdef schema
// โ
Visual editor renders form from schema
// โ
Runtime validates with same schema
// โ
Export to JSON for sharing
๐ฎ Game Engines (Bevy, Macroquad)
use *;
use *;
// Alternative to Bevy's Reflect for properties
// โ
Inspector UI auto-generated from schema
// โ
Serialization built-in
// โ
Undo/redo support (coming in v0.4)
๐ผ๏ธ GUI Frameworks (egui, iced, Dioxus)
use ;
// Auto-generate egui widgets from paramdef schemas
// โ
No manual UI code - schema drives everything
// โ
Consistent forms across your app
๐ Full-Stack Rust (Axum + Leptos/Dioxus)
// Shared types crate
// Backend (Axum)
async
// Frontend (Leptos)
// โ
Single source of truth
// โ
Type-safe across the stack
// โ
No JSON Schema duplication
๐ ๏ธ Desktop Apps (Tauri, Slint)
// Settings panel auto-generated from schema
let app_settings = builder
.field
.field
.build
.unwrap;
// โ
Settings UI rendered from schema
// โ
Persistence via serde
// โ
Validation built-in
๐ Plugin Systems
// Plugins register their parameters via paramdef
// Host app can:
// โ
Discover plugin parameters automatically
// โ
Generate UI for any plugin
// โ
Validate plugin configs
// โ
Serialize plugin state
Community Integrations Welcome!
Building a paramdef integration for your framework? Let us know - we'd love to feature it here!
Documentation
MSRV
Minimum Supported Rust Version: 1.85
Uses Rust 2024 Edition.
Contributing
Contributions are welcome! Please open an issue or pull request on GitHub.
License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.