1use syn::DeriveInput;
2
3pub fn derive_fmt(input: &DeriveInput) -> syn::Result<proc_macro2::TokenStream> {
4 if std::env::var("OSIRIS_DEBUG_DEFMT").is_ok() {
6 Ok(derive_fmt_defmt(input))
7 } else {
8 Ok(derive_fmt_debug(input))
9 }
10}
11
12fn derive_fmt_defmt(input: &DeriveInput) -> proc_macro2::TokenStream {
13 quote::quote! {
14 #[derive(defmt::Format)]
15 #input
16 }
17}
18
19fn derive_fmt_debug(input: &DeriveInput) -> proc_macro2::TokenStream {
20 quote::quote! {
21 #[derive(core::fmt::Debug)]
22 #input
23 }
24}