cast_derive/lib.rs
1//! Cast derive macros. `#[derive(Model)]` generates the trait impl, columns
2//! accessor, FromRow impl, and inherent helpers. Attribute macros for relationships.
3
4mod model;
5mod relation;
6
7use proc_macro::TokenStream;
8
9#[proc_macro_derive(Model, attributes(table, primary_key, has_many, has_one, belongs_to, soft_deletes))]
10pub fn derive_model(input: TokenStream) -> TokenStream {
11 let input = syn::parse_macro_input!(input as syn::DeriveInput);
12 match model::expand(&input) {
13 Ok(ts) => ts.into(),
14 Err(err) => err.to_compile_error().into(),
15 }
16}