| 1 | use bytesrust-analyzer cargo bytes 1.12.1 crate/::{Bufrust-analyzer cargo bytes 1.12.1 buf/buf_impl/Buf#, Bytesrust-analyzer cargo bytes 1.12.1 bytes/Bytes#}; |
| 2 | |
| 3 | use craterust-analyzer cargo sqlx-mysql 0.8.3 crate/::errorrust-analyzer cargo sqlx-mysql 0.8.3 error/::Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#; |
| 4 | use craterust-analyzer cargo sqlx-mysql 0.8.3 crate/::iorust-analyzer cargo sqlx-mysql 0.8.3 io/::ProtocolDecoderust-analyzer cargo sqlx-core 0.8.3 io/decode/ProtocolDecode#; |
| 5 | use craterust-analyzer cargo sqlx-mysql 0.8.3 crate/::protocolrust-analyzer cargo sqlx-mysql 0.8.3 protocol/::Capabilitiesrust-analyzer cargo sqlx-mysql 0.8.3 protocol/capabilities/Capabilities#; |
| 6 | |
| 7 | // https://dev.mysql.com/doc/internals/en/com-stmt-prepare-response.html#packet-COM_STMT_PREPARE_OK |
| 8 | |
| 9 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)] |
| 10 | pub(craterust-analyzer cargo sqlx-mysql 0.8.3 crate/) struct PrepareOkrust-analyzer cargo sqlx-mysql 0.8.3 protocol/statement/prepare_ok/PrepareOk# { |
| 11 | pub(craterust-analyzer cargo sqlx-mysql 0.8.3 crate/) statement_idrust-analyzer cargo sqlx-mysql 0.8.3 protocol/statement/prepare_ok/PrepareOk#statement_id.: u32, |
| 12 | pub(craterust-analyzer cargo sqlx-mysql 0.8.3 crate/) columnsrust-analyzer cargo sqlx-mysql 0.8.3 protocol/statement/prepare_ok/PrepareOk#columns.: u16, |
| 13 | pub(craterust-analyzer cargo sqlx-mysql 0.8.3 crate/) paramsrust-analyzer cargo sqlx-mysql 0.8.3 protocol/statement/prepare_ok/PrepareOk#params.: u16, |
| 14 | #[allow(unused)] |
| 15 | pub(craterust-analyzer cargo sqlx-mysql 0.8.3 crate/) warningsrust-analyzer cargo sqlx-mysql 0.8.3 protocol/statement/prepare_ok/PrepareOk#warnings.: u16, |
| 16 | } |
| 17 | |
| 18 | impl ProtocolDecoderust-analyzer cargo sqlx-core 0.8.3 io/decode/ProtocolDecode#<'_, Capabilitiesrust-analyzer cargo sqlx-mysql 0.8.3 protocol/capabilities/Capabilities#> for PrepareOkrust-analyzer cargo sqlx-mysql 0.8.3 protocol/statement/prepare_ok/PrepareOk# { |
| 19 | fn decode_withrust-analyzer cargo sqlx-mysql 0.8.3 protocol/statement/prepare_ok/impl#[PrepareOk][`ProtocolDecode<'_, Capabilities>`]decode_with().(buf: Bytesrust-analyzer cargo bytes 1.12.1 bytes/Bytes#, _: Capabilitiesrust-analyzer cargo sqlx-mysql 0.8.3 protocol/capabilities/Capabilities#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo sqlx-mysql 0.8.3 protocol/statement/prepare_ok/impl#[PrepareOk][`ProtocolDecode<'_, Capabilities>`], Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#> { |
| 20 | const SIZErust-analyzer cargo sqlx-mysql 0.8.3 protocol/statement/prepare_ok/SIZE.: usize = 12; |
| 21 | |
| 22 | let mut slice = buf.getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]get().(..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeTo#SIZErust-analyzer cargo sqlx-mysql 0.8.3 protocol/statement/prepare_ok/SIZE.).ok_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]ok_or_else().(|| { |
| 23 | err_protocolrust-analyzer cargo sqlx-core 0.8.3 error/err_protocol!!("PrepareOk expected 12 bytes but got {} bytes", buf.lenrust-analyzer cargo bytes 1.12.1 bytes/impl#[Bytes]len().()) |
| 24 | })?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 25 | |
| 26 | let status = slice.get_u8rust-analyzer cargo bytes 1.12.1 buf/buf_impl/Buf#get_u8().(); |
| 27 | if status rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().0x00 { |
| 28 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(err_protocolrust-analyzer cargo sqlx-core 0.8.3 error/err_protocol!!( |
| 29 | "expected 0x00 (COM_STMT_PREPARE_OK) but found 0x{:02x}", |
| 30 | status |
| 31 | )); |
| 32 | } |
| 33 | |
| 34 | let statement_id = slice.get_u32_lerust-analyzer cargo bytes 1.12.1 buf/buf_impl/Buf#get_u32_le().(); |
| 35 | let columns = slice.get_u16_lerust-analyzer cargo bytes 1.12.1 buf/buf_impl/Buf#get_u16_le().(); |
| 36 | let params = slice.get_u16_lerust-analyzer cargo bytes 1.12.1 buf/buf_impl/Buf#get_u16_le().(); |
| 37 | |
| 38 | slice.advancerust-analyzer cargo bytes 1.12.1 buf/buf_impl/impl#[`&[u8]`][Buf]advance().(1); // reserved: string<1> |
| 39 | |
| 40 | let warnings = slice.get_u16_lerust-analyzer cargo bytes 1.12.1 buf/buf_impl/Buf#get_u16_le().(); |
| 41 | |
| 42 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo sqlx-mysql 0.8.3 protocol/statement/prepare_ok/impl#[PrepareOk][`ProtocolDecode<'_, Capabilities>`] { |
| 43 | statement_idrust-analyzer cargo sqlx-mysql 0.8.3 protocol/statement/prepare_ok/PrepareOk#statement_id., |
| 44 | columnsrust-analyzer cargo sqlx-mysql 0.8.3 protocol/statement/prepare_ok/PrepareOk#columns., |
| 45 | paramsrust-analyzer cargo sqlx-mysql 0.8.3 protocol/statement/prepare_ok/PrepareOk#params., |
| 46 | warningsrust-analyzer cargo sqlx-mysql 0.8.3 protocol/statement/prepare_ok/PrepareOk#warnings., |
| 47 | }) |
| 48 | } |
| 49 | } |