fusionsql_macros/lib.rs
1#![allow(clippy::all)]
2#![warn(clippy::exhaustive_structs)]
3
4// region: --- Modules
5
6mod derives_field;
7mod derives_filter;
8mod utils;
9
10use crate::derives_filter::derive_filter_nodes_inner;
11use proc_macro::TokenStream;
12
13// endregion: --- Modules
14
15#[proc_macro_derive(FilterNodes, attributes(fusionsql))]
16pub fn derive_filter_nodes(input: TokenStream) -> TokenStream {
17 derive_filter_nodes_inner(input)
18}
19
20// region: --- with-sea-query
21
22#[proc_macro_derive(Fields, attributes(field, fusionsql))]
23pub fn derive_fields(input: TokenStream) -> TokenStream {
24 derives_field::derive_fields_inner(input)
25}
26
27/// Implements `From<T> for sea_query::Value` and `sea_query::Nullable for T`
28/// where T is the struct or enum annotated with `#[derive(Field)]` for simple
29/// tuple structs or enums.
30///
31/// For more complex types, implement both of these traits for the type.
32///
33/// For example:
34///
35/// - On simple type and single element tuple struct
36///
37/// Notes:
38/// - Supports only primitive types (no array yet)
39/// - Supports only one tuple field.
40///
41/// Notes:
42/// - Will be treated a sea_query::Value::String with the name of the variant.
43/// - No rename for now.
44#[proc_macro_derive(SeaFieldValue)]
45pub fn derive_field_sea_value(input: TokenStream) -> TokenStream {
46 derives_field::derive_field_sea_value_inner(input)
47}
48
49// endregion: --- with-sea-query