Skip to main content

ecat_orm_derive/
lib.rs

1// Copyright (c) 2026 erik <erik@erik.xyz> — https://erik.xyz
2//! `ecat-orm` 的派生宏。请勿直接依赖本 crate —— 经由 `ecat-orm` 重导出使用。
3
4use proc_macro::TokenStream;
5use syn::DeriveInput;
6
7mod attr;
8mod expand;
9
10/// 为结构体生成 [`ecat_orm::Entity`] 实现与实体元数据。
11///
12/// 属性文法见 `docs/api.md` 的 ORM 段。
13#[proc_macro_derive(Entity, attributes(entity))]
14pub fn derive_entity(input: TokenStream) -> TokenStream {
15    let input = syn::parse_macro_input!(input as DeriveInput);
16    expand::expand(input)
17        .unwrap_or_else(syn::Error::into_compile_error)
18        .into()
19}