pub fn generate_trait_methods(
        &self,
        provider: &ProviderTraitGenerator,
        struct_type_path: &syn::Path,
    ) -> TracersResult<TokenStream> {
        let vis = &self.spec.vis;

        //The original method will be implemented as a call to the impl method.  It's only purpose
        //is to ensure the user can call the original method and get our warning reminding them ot
        //use the `probe!` macro instead.  Otherwise it would be confusing to not be able to call a
        //method they think should exist on a trait they themselves defined, even if doing so is
        //not the intended use of this crate.
        let original_method = self.spec.original_method.sig.clone();

        //Generate an _enabled method which tests if this probe is enabled at runtime
        let mut enabled_method = original_method.clone();
        enabled_method.ident = syn_helpers::add_suffix_to_ident(&enabled_method.ident, "_enabled");
        enabled_method.inputs = syn::punctuated::Punctuated::new();
        enabled_method.output = syn::ReturnType::Default;

        //Generate an get_(probe)_probe method which returns the raw Option<ProviderProbe>
        let mut probe_method = original_method.clone();
        probe_method.ident = syn::Ident::new(
            &format!("get_{}_probe", probe_method.ident),
            probe_method.ident.span(),
        );
        probe_method.inputs = syn::punctuated::Punctuated::new();
        probe_method.output = syn::ReturnType::Default;
        let probe_method_ret_type = self.generate_provider_probe_type();
        let a_lifetime = syn::Lifetime::new("'a", self.spec.span);
        probe_method
            .generics
            .params
            .push(syn::GenericParam::Lifetime(syn::LifetimeDef::new(
                a_lifetime,
            )));
        for param in self.args_lifetime_parameters().iter() {
            probe_method
                .generics
                .params
                .push(syn::GenericParam::Lifetime(syn::LifetimeDef::new(
                    param.clone(),
                )))
        }

        //Generate an _impl method that actually fires the probe when called
        let mut impl_method = original_method.clone();
        impl_method.ident = syn_helpers::add_suffix_to_ident(&impl_method.ident, "_impl");

        //Generate the body of the original method, simply passing its arguments directly to the
        //impl method
        let probe_args_tuple = self.args_as_tuple_value();

        //Keep the original probe method, but mark it deprecated with a helpful message so that if the
        //user calls the probe method directly they will at least be reminded that they should use the
        //macro instead.
        let probe_ident = &self.spec.method_name;
        let deprecation_attribute = self.generate_probe_deprecation_attribute(&provider.spec);

        //Keep any attributes that were on the original method, and add `doc` attributes at the end
        //to provide some more information about the generated probe mechanics
        let attrs = &self.spec.original_method.attrs;
        let probe_doc_comment = self.generate_probe_doc_comment(&provider.spec);

        // Note that we don't put an #[allow(dead_code)] attribute on the original method, because
        // the user declared that method.  If it's not being used, let the compiler warn them about
        // it just like it would any other unused method.  The methods we generate, however, won't
        // be directly visible to the user and thus should not cause a warning if left un-called
        let span = original_method.span();
        Ok(quote_spanned! {span=>
            #(#attrs)*

            #probe_doc_comment

            #deprecation_attribute
            #[allow(dead_code)]
            #vis #original_method {
                if let Ok(probes) = #struct_type_path::get() {
                    if probes.#probe_ident.is_enabled() {
                        probes.#probe_ident.fire(#probe_args_tuple)
                    }
                };
            }

            #[allow(dead_code)]
            #[doc(hidden)]
            #vis #enabled_method -> bool {
                if let Ok(probes) = #struct_type_path::get() {
                    probes.#probe_ident.is_enabled()
                } else {
                    false
                }
            }

            #[doc(hidden)]
            #vis #probe_method -> Option<&'static #probe_method_ret_type> {
                #struct_type_path::get().ok().map(|probes| &probes.#probe_ident)
            }
        })
    }
/// For each probe the user defines on the trait, we will generate multiple implementation
/// methods:
///
/// * `(probe_name)` - This is the same name as the method the user declared.  It takes the same
/// arguments the user specified, and when called it checks to see if the probe is enabled and
/// if so fires the probe.  This is implemented as a normal Rust function call, so the
/// arguments to the probe function are evaluated unconditionally, whether the probe is enabled
/// or not.
/// * `(probe_name)_is_enabled` - This takes no args and returns a `bool` indicating if the
/// probe is enabled or not.  Most situations won't require this method, but in some rare cases
/// where some specific operation is conditional upon the enabling of a specific probe, this is
/// available.
/// * `if_(probe_name)_enabled` - This is a more complex version of `(probe_name)_is_enabled`
/// which takes as an argument a `FnOnce` closure, which itself is passed a `FnOnce` closure
/// which when called will fire the probe.  If the probe is not enabled, this closure never
/// gets called.  Thus, in this way callers can implement potentially expensive logic to
/// prepare information for a probe, and only run this code when the probe is activated.
For each probe the user defines on the trait, we will generate multiple implementation
methods.

`(probe_name)` - This is the same name as the method the user declared.  It takes the same
arguments the user specified, and when called it checks to see if the probe is enabled and
if so fires the probe.  This is implemented as a normal Rust function call, so the
arguments to the probe function are evaluated unconditionally, whether the probe is enabled
or not.
`(probe_name)_is_enabled` - This takes no args and returns a `bool` indicating if the
probe is enabled or not.  Most situations won't require this method, but in some rare cases
where some specific operation is conditional upon the enabling of a specific probe, this is
available.
For each probe the user defines on the trait we will generate multiple implementation methods . ` ( probe_name ) ` - This is the same name as the method the user declared . It takes the same arguments the user specified and when called it checks to see if the probe is enabled and if so fires the probe . This is implemented as a normal Rust function call so the arguments to the probe function are evaluated unconditionally whether the probe is enabled or not . ` ( probe_name ) _is_enabled ` - This takes no args and returns a ` bool ` indicating if the probe is enabled or not . Most situations won ' t require this method but in some rare cases where some specific operation is conditional upon the enabling of a specific probe this is available .
pub fn generate_trait_methods(
        &self,
        provider: &ProviderTraitGenerator,
        struct_type_path: &syn::Path,
    ) -> TracersResult<TokenStream> {
        let vis = &self.spec.vis;
        //The original method will be implemented as a call to the impl method.  It's only purpose
        //is to ensure the user can call the original method and get our warning reminding them ot
        //use the `probe!` macro instead.  Otherwise it would be confusing to not be able to call a
        //method they think should exist on a trait they themselves defined, even if doing so is
        //not the intended use of this crate.
        let original_method = self.spec.original_method.sig.clone();
        //Generate an _enabled method which tests if this probe is enabled at runtime
        let mut enabled_method = original_method.clone();
        enabled_method.ident = syn_helpers::add_suffix_to_ident(&enabled_method.ident, "_enabled");
        enabled_method.inputs = syn::punctuated::Punctuated::new();
        enabled_method.output = syn::ReturnType::Default;
        //Generate an get_(probe)_probe method which returns the raw Option<ProviderProbe>
        let mut probe_method = original_method.clone();
        probe_method.ident = syn::Ident::new(
            &format!("get_{}_probe", probe_method.ident),
            probe_method.ident.span(),
        );
        probe_method.inputs = syn::punctuated::Punctuated::new();
        probe_method.output = syn::ReturnType::Default;
        let probe_method_ret_type = self.generate_provider_probe_type();
        let a_lifetime = syn::Lifetime::new("'a", self.spec.span);
        probe_method
            .generics
            .params
            .push(syn::GenericParam::Lifetime(syn::LifetimeDef::new(
                a_lifetime,
            )));
        for param in self.args_lifetime_parameters().iter() {
            probe_method
                .generics
                .params
                .push(syn::GenericParam::Lifetime(syn::LifetimeDef::new(
                    param.clone(),
                )))
        }
        //Generate an _impl method that actually fires the probe when called
        let mut impl_method = original_method.clone();
        impl_method.ident = syn_helpers::add_suffix_to_ident(&impl_method.ident, "_impl");
        //Generate the body of the original method, simply passing its arguments directly to the
        //impl method
        let probe_args_tuple = self.args_as_tuple_value();
        //Keep the original probe method, but mark it deprecated with a helpful message so that if the
        //user calls the probe method directly they will at least be reminded that they should use the
        //macro instead.
        let probe_ident = &self.spec.method_name;
        let deprecation_attribute = self.generate_probe_deprecation_attribute(&provider.spec);
        //Keep any attributes that were on the original method, and add `doc` attributes at the end
        //to provide some more information about the generated probe mechanics
        let attrs = &self.spec.original_method.attrs;
        let probe_doc_comment = self.generate_probe_doc_comment(&provider.spec);
        // Note that we don't put an #[allow(dead_code)] attribute on the original method, because
        // the user declared that method.  If it's not being used, let the compiler warn them about
        // it just like it would any other unused method.  The methods we generate, however, won't
        // be directly visible to the user and thus should not cause a warning if left un-called
        let span = original_method.span();
        Ok(quote_spanned! {span=>
            #(#attrs)*
            #probe_doc_comment
            #deprecation_attribute
            #[allow(dead_code)]
            #vis #original_method {
                if let Ok(probes) = #struct_type_path::get() {
                    if probes.#probe_ident.is_enabled() {
                        probes.#probe_ident.fire(#probe_args_tuple)
                    }
                };
            }
            #[allow(dead_code)]
            #[doc(hidden)]
            #vis #enabled_method -> bool {
                if let Ok(probes) = #struct_type_path::get() {
                    probes.#probe_ident.is_enabled()
                } else {
                    false
                }
            }
            #[doc(hidden)]
            #vis #probe_method -> Option<&'static #probe_method_ret_type> {
                #struct_type_path::get().ok().map(|probes| &probes.#probe_ident)
            }
        })
    }
pub fn generate_trait_methods ( & self , provider : & ProviderTraitGenerator , struct_type_path : & syn :: Path , ) -> TracersResult < TokenStream > { let vis = & self . spec . vis ; //The original method will be implemented as a call to the impl method.  It's only purpose //is to ensure the user can call the original method and get our warning reminding them ot //use the `probe!` macro instead.  Otherwise it would be confusing to not be able to call a //method they think should exist on a trait they themselves defined, even if doing so is //not the intended use of this crate. let original_method = self . spec . original_method . sig . clone ( ) ; //Generate an _enabled method which tests if this probe is enabled at runtime let mut enabled_method = original_method . clone ( ) ; enabled_method . ident = syn_helpers :: add_suffix_to_ident ( & enabled_method . ident , " " ) ; enabled_method . inputs = syn :: punctuated :: Punctuated :: new ( ) ; enabled_method . output = syn :: ReturnType :: Default ; //Generate an get_(probe)_probe method which returns the raw Option<ProviderProbe> let mut probe_method = original_method . clone ( ) ; probe_method . ident = syn :: Ident :: new ( & format ! ( " " probe_method ident ) , probe_method . ident . span ( ) , ) ; probe_method . inputs = syn :: punctuated :: Punctuated :: new ( ) ; probe_method . output = syn :: ReturnType :: Default ; let probe_method_ret_type = self . generate_provider_probe_type ( ) ; let a_lifetime = syn :: Lifetime :: new ( " " , self . spec . span ) ; probe_method . generics . params . push ( syn :: GenericParam :: Lifetime ( syn :: LifetimeDef :: new ( a_lifetime , ) ) ) ; for param in self . args_lifetime_parameters ( ) . iter ( ) { probe_method . generics . params . push ( syn :: GenericParam :: Lifetime ( syn :: LifetimeDef :: new ( param . clone ( ) , ) ) ) } //Generate an _impl method that actually fires the probe when called let mut impl_method = original_method . clone ( ) ; impl_method . ident = syn_helpers :: add_suffix_to_ident ( & impl_method . ident , " " ) ; //Generate the body of the original method, simply passing its arguments directly to the //impl method let probe_args_tuple = self . args_as_tuple_value ( ) ; //Keep the original probe method, but mark it deprecated with a helpful message so that if the //user calls the probe method directly they will at least be reminded that they should use the //macro instead. let probe_ident = & self . spec . method_name ; let deprecation_attribute = self . generate_probe_deprecation_attribute ( & provider . spec ) ; //Keep any attributes that were on the original method, and add `doc` attributes at the end //to provide some more information about the generated probe mechanics let attrs = & self . spec . original_method . attrs ; let probe_doc_comment = self . generate_probe_doc_comment ( & provider . spec ) ; // Note that we don't put an #[allow(dead_code)] attribute on the original method, because // the user declared that method.  If it's not being used, let the compiler warn them about // it just like it would any other unused method.  The methods we generate, however, won't // be directly visible to the user and thus should not cause a warning if left un-called let span = original_method . span ( ) ; Ok ( quote_spanned ! { span ( attrs ) probe_doc_comment deprecation_attribute [ allow ( dead_code ) ] vis original_method { if let Ok ( probes ) struct_type_path get ( ) { if probes probe_ident is_enabled ( ) { probes probe_ident fire ( probe_args_tuple ) } } } [ allow ( dead_code ) ] [ doc ( hidden ) ] vis enabled_method bool { if let Ok ( probes ) struct_type_path get ( ) { probes probe_ident is_enabled ( ) } else { false } } [ doc ( hidden ) ] vis probe_method Option ' static probe_method_ret_type { struct_type_path get ( ) ok ( ) map ( probes probes probe_ident ) } } ) }
For each probe the user defines on the trait, we will generate multiple implementation
methods:
For each probe the user defines on the trait we will generate multiple implementation methods :
&self
provider
&ProviderTraitGenerator
struct_type_path
&syn::Path
&self
provider
&ProviderTraitGenerator
struct_type_path
&syn::Path