rbdc_mysql/protocol/statement/
prepare_ok.rs1use bytes::{Buf, Bytes};
2
3use crate::protocol::Capabilities;
4use rbdc::io::Decode;
5use rbdc::{err_protocol, Error};
6
7#[derive(Debug)]
10pub struct PrepareOk {
11 pub statement_id: u32,
12 pub columns: u16,
13 pub params: u16,
14 #[allow(unused)]
15 pub warnings: u16,
16}
17
18impl Decode<'_, Capabilities> for PrepareOk {
19 fn decode_with(mut buf: Bytes, _: Capabilities) -> Result<Self, Error> {
20 let status = buf.get_u8();
21 if status != 0x00 {
22 return Err(err_protocol!(
23 "expected 0x00 (COM_STMT_PREPARE_OK) but found 0x{:02x}",
24 status
25 ));
26 }
27
28 let statement_id = buf.get_u32_le();
29 let columns = buf.get_u16_le();
30 let params = buf.get_u16_le();
31
32 buf.advance(1); let warnings = buf.get_u16_le();
35
36 Ok(Self {
37 statement_id,
38 columns,
39 params,
40 warnings,
41 })
42 }
43}