fletch-orm-macros 1.0.0

Procedural macros for the Fletch ORM database toolkit
Documentation
//! Procedural macros for the Fletch database toolkit.
//!
//! Provides `#[derive(Entity)]` to generate `fletch_orm::Entity` trait
//! implementations from annotated structs.

mod crate_path;
mod entity;

use proc_macro::TokenStream;

/// Derive macro to generate `fletch_orm::Entity` trait implementation.
///
/// # Struct Attributes
///
/// - `#[fletch(table = "table_name")]`: Override the table name
///   (default: `snake_case` pluralized struct name).
///
/// # Field Attributes
///
/// - `#[fletch(id)]`: Mark the primary key field (required, exactly one).
/// - `#[fletch(skip)]`: Exclude a field from persistence.
/// - `#[fletch(rename = "col_name")]`: Override the column name.
///
/// # Example
///
/// ```ignore
/// #[derive(Entity)]
/// #[fletch(table = "users")]
/// pub struct User {
///     #[fletch(id)]
///     pub id: i64,
///     pub name: String,
///     #[fletch(skip)]
///     pub cached_display: String,
/// }
/// ```
#[proc_macro_derive(Entity, attributes(fletch))]
pub fn derive_entity(input: TokenStream) -> TokenStream {
    let input = syn::parse_macro_input!(input as syn::DeriveInput);
    entity::expand_entity(input).into()
}