use syn::{DeriveInput, LitStr};
pub fn parse_custom_fn(input: &DeriveInput) -> Option<LitStr> {
let custom_fn = input
.attrs
.iter()
.find(|attr| attr.path().is_ident("response"));
if let Some(custom_fn) = custom_fn {
let result = custom_fn.parse_args_with(|input: syn::parse::ParseStream| {
let ident: syn::Ident = input.parse()?;
if ident != "custom_fn" {
return Err(syn::Error::new(ident.span(), "Expected 'custom_fn'"));
}
let _: syn::Token![=] = input.parse()?;
let lit_str: syn::LitStr = input.parse()?;
Ok(lit_str)
});
match result {
Ok(function_name) => Some(function_name),
Err(_) => None,
}
} else {
None
}
}