bitwarden_error_macro/full/
attribute.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
use darling::Error;
use quote::quote;

pub(crate) fn bitwarden_error_full(
    input: &syn::DeriveInput,
    type_identifier: &proc_macro2::Ident,
    export_as_identifier: &proc_macro2::Ident,
) -> proc_macro::TokenStream {
    if type_identifier != export_as_identifier {
        return Error::custom("`bitwarden_error(full)` does not currently support `export_as`")
            .write_errors()
            .into();
    }

    let wasm_attributes = cfg!(feature = "wasm").then(|| {
        quote! {
            #[derive(bitwarden_error::tsify_next::Tsify)]
            #[tsify(into_wasm_abi)]
        }
    });

    quote! {
        #[derive(serde::Serialize)]
        #wasm_attributes
        #input
    }
    .into()
}