appstruct-codegen 0.2.0

Deterministic Rust, SQL, OpenAPI, TypeScript, and React generation for AppStruct
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use appstruct_ir::FieldTypeIr;
use proc_macro2::TokenStream;
use quote::quote;

pub(super) fn attributes(ty: &FieldTypeIr, option_depth: u8) -> TokenStream {
    if !matches!(ty, FieldTypeIr::Bigint) {
        return if option_depth >= 2 {
            quote! { #[serde(default, deserialize_with = "appstruct_runtime::deserialize_patch")] }
        } else {
            TokenStream::new()
        };
    }
    match option_depth {
        0 => quote! { #[serde(with = "appstruct_runtime::bigint")] },
        1 => quote! { #[serde(default, with = "appstruct_runtime::bigint::optional")] },
        _ => quote! { #[serde(default, with = "appstruct_runtime::bigint::patch")] },
    }
}