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§
Sourcefn encode_null_bitmap(&self, out: &mut Vec<u8>)
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.
Sourcefn encode_types(&self, out: &mut Vec<u8>)
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)
Sourcefn encode_values(&self, out: &mut Vec<u8>) -> Result<()>
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).
Sourcefn encode_values_for_bulk(&self, out: &mut Vec<u8>) -> Result<()>
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