Skip to main content

rspack_cacheable_macros/
lib.rs

1mod cacheable;
2mod cacheable_dyn;
3
4#[proc_macro_attribute]
5pub fn enable_cacheable(
6  args: proc_macro::TokenStream,
7  tokens: proc_macro::TokenStream,
8) -> proc_macro::TokenStream {
9  cacheable::cacheable(args, tokens)
10}
11
12#[proc_macro_attribute]
13pub fn disable_cacheable(
14  args: proc_macro::TokenStream,
15  tokens: proc_macro::TokenStream,
16) -> proc_macro::TokenStream {
17  cacheable::disable_cacheable(args, tokens)
18}
19
20#[proc_macro_attribute]
21pub fn enable_cacheable_dyn(
22  _args: proc_macro::TokenStream,
23  tokens: proc_macro::TokenStream,
24) -> proc_macro::TokenStream {
25  let input = syn::parse_macro_input!(tokens as syn::Item);
26
27  match input {
28    syn::Item::Trait(input) => cacheable_dyn::impl_trait(input),
29    syn::Item::Impl(input) => cacheable_dyn::impl_impl(input),
30    _ => panic!("expect Trait or Impl"),
31  }
32}
33
34#[proc_macro_attribute]
35pub fn disable_cacheable_dyn(
36  _args: proc_macro::TokenStream,
37  tokens: proc_macro::TokenStream,
38) -> proc_macro::TokenStream {
39  cacheable_dyn::disable_cacheable_dyn(tokens)
40}