bitwarden_error_macro/full/
attribute.rs1use darling::Error;
2use quote::quote;
3
4pub(crate) fn bitwarden_error_full(
5 input: &syn::DeriveInput,
6 type_identifier: &proc_macro2::Ident,
7 export_as_identifier: &proc_macro2::Ident,
8) -> proc_macro::TokenStream {
9 if type_identifier != export_as_identifier {
10 return Error::custom("`bitwarden_error(full)` does not currently support `export_as`")
11 .write_errors()
12 .into();
13 }
14
15 let wasm_attributes = cfg!(feature = "wasm").then(|| {
16 quote! {
17 #[derive(bitwarden_error::tsify_next::Tsify)]
18 #[tsify(into_wasm_abi)]
19 }
20 });
21
22 quote! {
23 #[derive(serde::Serialize)]
24 #wasm_attributes
25 #input
26 }
27 .into()
28}