pub(crate) async fn execute_statement<P>(
        &mut self,
        statement: &Statement,
        params: P,
    ) -> Result<()>
    where
        P: Into<Params>,
    {
        let mut params = params.into();
        loop {
            match params {
                Params::Positional(params) => {
                    if statement.num_params() as usize != params.len() {
                        Err(DriverError::StmtParamsMismatch {
                            required: statement.num_params(),
                            supplied: params.len() as u16,
                        })?
                    }

                    let params = params.into_iter().collect::<Vec<_>>();

                    let (body, as_long_data) =
                        ComStmtExecuteRequestBuilder::new(statement.id()).build(&*params);

                    if as_long_data {
                        self.send_long_data(statement.id(), params.iter()).await?;
                    }

                    self.write_command_raw(body).await?;
                    self.read_result_set::<BinaryProtocol>().await?;
                    break;
                }
                Params::Named(_) => {
                    if statement.named_params.is_none() {
                        let error = DriverError::NamedParamsForPositionalQuery.into();
                        return Err(error);
                    }

                    params = match params.into_positional(statement.named_params.as_ref().unwrap())
                    {
                        Ok(positional_params) => positional_params,
                        Err(error) => return Err(error.into()),
                    };

                    continue;
                }
                Params::Empty => {
                    if statement.num_params() > 0 {
                        let error = DriverError::StmtParamsMismatch {
                            required: statement.num_params(),
                            supplied: 0,
                        }
                        .into();
                        return Err(error);
                    }

                    let (body, _) = ComStmtExecuteRequestBuilder::new(statement.id()).build(&[]);
                    self.write_command_raw(body).await?;
                    self.read_result_set::<BinaryProtocol>().await?;
                    break;
                }
            }
        }
        Ok(())
    }
/// Helper, that executes the given statement with the given params.
Helper, that executes the given statement with the given params.
Helper that executes the given statement with the given params .
pub(crate) async fn execute_statement<P>(
        &mut self,
        statement: &Statement,
        params: P,
    ) -> Result<()>
    where
        P: Into<Params>,
    {
        let mut params = params.into();
        loop {
            match params {
                Params::Positional(params) => {
                    if statement.num_params() as usize != params.len() {
                        Err(DriverError::StmtParamsMismatch {
                            required: statement.num_params(),
                            supplied: params.len() as u16,
                        })?
                    }
                    let params = params.into_iter().collect::<Vec<_>>();
                    let (body, as_long_data) =
                        ComStmtExecuteRequestBuilder::new(statement.id()).build(&*params);
                    if as_long_data {
                        self.send_long_data(statement.id(), params.iter()).await?;
                    }
                    self.write_command_raw(body).await?;
                    self.read_result_set::<BinaryProtocol>().await?;
                    break;
                }
                Params::Named(_) => {
                    if statement.named_params.is_none() {
                        let error = DriverError::NamedParamsForPositionalQuery.into();
                        return Err(error);
                    }
                    params = match params.into_positional(statement.named_params.as_ref().unwrap())
                    {
                        Ok(positional_params) => positional_params,
                        Err(error) => return Err(error.into()),
                    };
                    continue;
                }
                Params::Empty => {
                    if statement.num_params() > 0 {
                        let error = DriverError::StmtParamsMismatch {
                            required: statement.num_params(),
                            supplied: 0,
                        }
                        .into();
                        return Err(error);
                    }
                    let (body, _) = ComStmtExecuteRequestBuilder::new(statement.id()).build(&[]);
                    self.write_command_raw(body).await?;
                    self.read_result_set::<BinaryProtocol>().await?;
                    break;
                }
            }
        }
        Ok(())
    }
pub ( crate ) async fn execute_statement < P > ( & mut self , statement : & Statement , params : P , ) -> Result < ( ) > where P : Into < Params > , { let mut params = params . into ( ) ; loop { match params { Params :: Positional ( params ) => { if statement . num_params ( ) as usize != params . len ( ) { Err ( DriverError :: StmtParamsMismatch { required : statement . num_params ( ) , supplied : params . len ( ) as u16 , } ) ? } let params = params . into_iter ( ) . collect :: < Vec < _ > > ( ) ; let ( body , as_long_data ) = ComStmtExecuteRequestBuilder :: new ( statement . id ( ) ) . build ( & * params ) ; if as_long_data { self . send_long_data ( statement . id ( ) , params . iter ( ) ) . await ? ; } self . write_command_raw ( body ) . await ? ; self . read_result_set :: < BinaryProtocol > ( ) . await ? ; break ; } Params :: Named ( _ ) => { if statement . named_params . is_none ( ) { let error = DriverError :: NamedParamsForPositionalQuery . into ( ) ; return Err ( error ) ; } params = match params . into_positional ( statement . named_params . as_ref ( ) . unwrap ( ) ) { Ok ( positional_params ) => positional_params , Err ( error ) => return Err ( error . into ( ) ) , } ; continue ; } Params :: Empty => { if statement . num_params ( ) > 0 { let error = DriverError :: StmtParamsMismatch { required : statement . num_params ( ) , supplied : 0 , } . into ( ) ; return Err ( error ) ; } let ( body , _ ) = ComStmtExecuteRequestBuilder :: new ( statement . id ( ) ) . build ( & [ ] ) ; self . write_command_raw ( body ) . await ? ; self . read_result_set :: < BinaryProtocol > ( ) . await ? ; break ; } } } Ok ( ( ) ) }
Helper, that executes the given statement with the given params.
Helper that executes the given statement with the given params .
&mut self
statement
&Statement
params
P
&mut self
statement
&Statement
params
P