Type-Safe Schema Definitions
Oxide SQL provides derive macros for defining database tables as Rust structs. This enables compile-time validation of column names, preventing typos and ensuring queries are valid before runtime.
Overview
Instead of using string column names, you define your schema as Rust structs
with #[derive(Table)]. The macro generates table metadata types, column
types, and accessor methods for type-safe queries.
Benefits
- Compile-time validation - Misspelled column names fail to compile
- IDE support - Autocomplete for column names
- Refactoring safety - Renaming columns is checked by the compiler
- Self-documenting - Schema is visible in your Rust code
Usage
See the following guides:
- Defining Tables - How to define table schemas
- Typed Queries - Building queries with type safety
- Column Attributes - Available column configurations
API Reference
See the derive macro rustdoc for macro documentation and the typed builder module rustdoc for the typed query builders.