use byteorder::LittleEndian;
use crate::io::Buf;
use crate::mysql::io::BufExt;
use crate::mysql::protocol::Decode;
#[derive(Debug)]
pub struct ComStmtPrepareOk {
pub statement_id: u32,
pub columns: u16,
pub params: u16,
pub warnings: u16,
}
impl Decode for ComStmtPrepareOk {
fn decode(mut buf: &[u8]) -> crate::Result<Self> {
let header = buf.get_u8()?;
if header != 0x00 {
return Err(protocol_err!(
"expected COM_STMT_PREPARE_OK (0x00); received 0x{:X}",
header
))?;
}
let statement_id = buf.get_u32::<LittleEndian>()?;
let columns = buf.get_u16::<LittleEndian>()?;
let params = buf.get_u16::<LittleEndian>()?;
buf.advance(1);
let warnings = buf.get_u16::<LittleEndian>()?;
Ok(Self {
statement_id,
columns,
params,
warnings,
})
}
}