Skip to main content

sntl_macros/
lib.rs

1//! Sentinel Macros — derive(Model), derive(Partial), #[reducer].
2
3mod model;
4mod partial;
5
6use proc_macro::TokenStream;
7
8/// Derive the `Model` trait for a struct.
9///
10/// # Example
11///
12/// ```rust,ignore
13/// #[derive(Model)]
14/// #[sentinel(table = "users")]
15/// pub struct User {
16///     #[sentinel(primary_key, default = "gen_random_uuid()")]
17///     pub id: Uuid,
18///     pub email: String,
19/// }
20/// ```
21#[proc_macro_derive(Model, attributes(sentinel))]
22pub fn derive_model(input: TokenStream) -> TokenStream {
23    model::derive_model_impl(input.into()).into()
24}
25
26/// Derive a partial select type.
27#[proc_macro_derive(Partial, attributes(sentinel))]
28pub fn derive_partial(input: TokenStream) -> TokenStream {
29    partial::derive_partial_impl(input.into()).into()
30}