Params

Trait Params 

Source
pub trait Params {
    // Required methods
    fn len(&self) -> usize;
    fn encode_null_bitmap(&self, out: &mut Vec<u8>);
    fn encode_types(&self, out: &mut Vec<u8>);
    fn encode_values(&self, out: &mut Vec<u8>) -> Result<()>;
    fn encode_values_for_bulk(&self, out: &mut Vec<u8>) -> Result<()>;

    // Provided method
    fn is_empty(&self) -> bool { ... }
}
Expand description

Trait for parameter binding in prepared statements

This trait is implemented by external libraries to provide a custom parameter serialization.

Required Methods§

Source

fn len(&self) -> usize

Number of parameters

Source

fn encode_null_bitmap(&self, out: &mut Vec<u8>)

Write NULL bitmap

The NULL bitmap is (num_params + 7) / 8 bytes long. Bit is set to 1 if the parameter is NULL.

Source

fn encode_types(&self, out: &mut Vec<u8>)

Write parameter types

Each parameter type is 2 bytes:

  • 1 byte: MySQL type (MYSQL_TYPE_*)
  • 1 byte: unsigned flag (0x80 if unsigned, 0x00 otherwise)
Source

fn encode_values(&self, out: &mut Vec<u8>) -> Result<()>

Write parameter values (binary encoded)

Values are encoded according to MySQL binary protocol. NULL parameters should be skipped (they’re already in the NULL bitmap).

Source

fn encode_values_for_bulk(&self, out: &mut Vec<u8>) -> Result<()>

Write parameter values for bulk execution (COM_STMT_BULK_EXECUTE)

Format:

  • First: parameter indicators (1 byte per parameter)
  • Then: values (only for parameters with indicator None)

See: https://mariadb.com/docs/server/reference/clientserver-protocol/3-binary-protocol-prepared-statements/com_stmt_bulk_execute

Provided Methods§

Source

fn is_empty(&self) -> bool

Implementations on Foreign Types§

Source§

impl<T: TypedParam> Params for &[T]

Source§

fn len(&self) -> usize

Source§

fn encode_null_bitmap(&self, out: &mut Vec<u8>)

Source§

fn encode_types(&self, out: &mut Vec<u8>)

Source§

fn encode_values(&self, out: &mut Vec<u8>) -> Result<()>

Source§

fn encode_values_for_bulk(&self, out: &mut Vec<u8>) -> Result<()>

Source§

impl<T: TypedParam> Params for &Vec<T>

Source§

fn len(&self) -> usize

Source§

fn encode_null_bitmap(&self, out: &mut Vec<u8>)

Source§

fn encode_types(&self, out: &mut Vec<u8>)

Source§

fn encode_values(&self, out: &mut Vec<u8>) -> Result<()>

Source§

fn encode_values_for_bulk(&self, out: &mut Vec<u8>) -> Result<()>

Source§

impl<T: TypedParam> Params for [T]

Source§

fn len(&self) -> usize

Source§

fn encode_null_bitmap(&self, out: &mut Vec<u8>)

Source§

fn encode_types(&self, out: &mut Vec<u8>)

Source§

fn encode_values(&self, out: &mut Vec<u8>) -> Result<()>

Source§

fn encode_values_for_bulk(&self, out: &mut Vec<u8>) -> Result<()>

Source§

impl<T: TypedParam> Params for Vec<T>

Source§

fn len(&self) -> usize

Source§

fn encode_null_bitmap(&self, out: &mut Vec<u8>)

Source§

fn encode_types(&self, out: &mut Vec<u8>)

Source§

fn encode_values(&self, out: &mut Vec<u8>) -> Result<()>

Source§

fn encode_values_for_bulk(&self, out: &mut Vec<u8>) -> Result<()>

Implementors§