pub fn from_call_expression(call: syn::Expr) -> TracersResult<ProbeCallDetails> {
        match call {
            syn::Expr::Call(call) => {
                // Within this call is encoded all the information we need about the probe firing,
                // we just have to extract it
                let func = call.func.as_ref().clone();

                if let syn::Expr::Path(func) = func {
                    if func.path.segments.len() < 2 {
                        return Err(
                            TracersError::invalid_call_expression(format!(
                            "The expression '{0}' is missing the name of the provider trait, eg 'MyProviderTrait::{0}'",
                            syn_helpers::convert_to_string(&call)),
                                    func));
                    }

                    let mut provider = func.path.clone();

                    //For paths of the form "foo::bar", when we call 'pop', we get back 'bar' and
                    //the remaining path is "foo::".  So pop the last path element off to get the
                    //probe name, then forcibly override that trailing :: separator
                    let (probe, _) = provider.segments.pop().unwrap().into_tuple(); //all call expressions have at least one segment
                    if provider.segments.trailing_punct() {
                        let pair = provider.segments.pop().unwrap(); //trailing_punct is true so there's at least one segmnet

                        match pair {
                            syn::punctuated::Pair::Punctuated(seg, _) => {
                                provider.segments.push_value(seg)
                            }
                            syn::punctuated::Pair::End(seg) => provider.segments.push_value(seg),
                        }
                    }

                    let args: Vec<_> = call.args.iter().cloned().collect();
                    Ok(ProbeCallDetails {
                        call,
                        probe_fq_path: func.path,
                        provider,
                        probe,
                        args,
                    })
                } else {
                    Err(TracersError::invalid_call_expression(format!("Unexpected expression for function call: {}", syn_helpers::convert_to_string(&func)), func))
                }
            },
            _ => {
                Err(TracersError::invalid_call_expression( "The probe! macro requires the name of a provider trait and its probe method, e.g. MyProvider::myprobe(...)", call))
            }
        }
    }
/// Parses a single expression which should be a call to the probe function.  This implies that
/// the probe call is `FireOnly`, since a block of code would take a different form.
Parses a single expression which should be a call to the probe function.  This implies that
the probe call is `FireOnly`, since a block of code would take a different form.
Parses a single expression which should be a call to the probe function . This implies that the probe call is ` FireOnly ` since a block of code would take a different form .
pub fn from_call_expression(call: syn::Expr) -> TracersResult<ProbeCallDetails> {
        match call {
            syn::Expr::Call(call) => {
                // Within this call is encoded all the information we need about the probe firing,
                // we just have to extract it
                let func = call.func.as_ref().clone();
                if let syn::Expr::Path(func) = func {
                    if func.path.segments.len() < 2 {
                        return Err(
                            TracersError::invalid_call_expression(format!(
                            "The expression '{0}' is missing the name of the provider trait, eg 'MyProviderTrait::{0}'",
                            syn_helpers::convert_to_string(&call)),
                                    func));
                    }
                    let mut provider = func.path.clone();
                    //For paths of the form "foo::bar", when we call 'pop', we get back 'bar' and
                    //the remaining path is "foo::".  So pop the last path element off to get the
                    //probe name, then forcibly override that trailing :: separator
                    let (probe, _) = provider.segments.pop().unwrap().into_tuple(); //all call expressions have at least one segment
                    if provider.segments.trailing_punct() {
                        let pair = provider.segments.pop().unwrap(); //trailing_punct is true so there's at least one segmnet
                        match pair {
                            syn::punctuated::Pair::Punctuated(seg, _) => {
                                provider.segments.push_value(seg)
                            }
                            syn::punctuated::Pair::End(seg) => provider.segments.push_value(seg),
                        }
                    }
                    let args: Vec<_> = call.args.iter().cloned().collect();
                    Ok(ProbeCallDetails {
                        call,
                        probe_fq_path: func.path,
                        provider,
                        probe,
                        args,
                    })
                } else {
                    Err(TracersError::invalid_call_expression(format!("Unexpected expression for function call: {}", syn_helpers::convert_to_string(&func)), func))
                }
            },
            _ => {
                Err(TracersError::invalid_call_expression( "The probe! macro requires the name of a provider trait and its probe method, e.g. MyProvider::myprobe(...)", call))
            }
        }
    }
pub fn from_call_expression ( call : syn :: Expr ) -> TracersResult < ProbeCallDetails > { match call { syn :: Expr :: Call ( call ) => { // Within this call is encoded all the information we need about the probe firing, // we just have to extract it let func = call . func . as_ref ( ) . clone ( ) ; if let syn :: Expr :: Path ( func ) = func { if func . path . segments . len ( ) < 2 { return Err ( TracersError :: invalid_call_expression ( format ! ( " " syn_helpers convert_to_string ( call ) ) , func ) ) ; } let mut provider = func . path . clone ( ) ; //For paths of the form "foo::bar", when we call 'pop', we get back 'bar' and //the remaining path is "foo::".  So pop the last path element off to get the //probe name, then forcibly override that trailing :: separator let ( probe , _ ) = provider . segments . pop ( ) . unwrap ( ) . into_tuple ( ) ; //all call expressions have at least one segment if provider . segments . trailing_punct ( ) { let pair = provider . segments . pop ( ) . unwrap ( ) ; //trailing_punct is true so there's at least one segmnet match pair { syn :: punctuated :: Pair :: Punctuated ( seg , _ ) => { provider . segments . push_value ( seg ) } syn :: punctuated :: Pair :: End ( seg ) => provider . segments . push_value ( seg ) , } } let args : Vec < _ > = call . args . iter ( ) . cloned ( ) . collect ( ) ; Ok ( ProbeCallDetails { call , probe_fq_path : func . path , provider , probe , args , } ) } else { Err ( TracersError :: invalid_call_expression ( format ! ( " " syn_helpers convert_to_string ( func ) ) , func ) ) } } , _ => { Err ( TracersError :: invalid_call_expression ( " " , call ) ) } } }
Parses a single expression which should be a call to the probe function.
Parses a single expression which should be a call to the probe function .
call
syn::Expr
call
syn::Expr