| 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/::MySqlBufExtrust-analyzer cargo sqlx-mysql 0.8.3 io/buf/MySqlBufExt#; |
| 5 | 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#; |
| 6 | use craterust-analyzer cargo sqlx-mysql 0.8.3 crate/::protocolrust-analyzer cargo sqlx-mysql 0.8.3 protocol/::responserust-analyzer cargo sqlx-mysql 0.8.3 protocol/response/::Statusrust-analyzer cargo sqlx-mysql 0.8.3 protocol/response/status/Status#; |
| 7 | |
| 8 | /// Indicates successful completion of a previous command sent by the client. |
| 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 struct OkPacketrust-analyzer cargo sqlx-mysql 0.8.3 protocol/response/ok/OkPacket# { |
| 11 | pub affected_rowsrust-analyzer cargo sqlx-mysql 0.8.3 protocol/response/ok/OkPacket#affected_rows.: u64, |
| 12 | pub last_insert_idrust-analyzer cargo sqlx-mysql 0.8.3 protocol/response/ok/OkPacket#last_insert_id.: u64, |
| 13 | pub statusrust-analyzer cargo sqlx-mysql 0.8.3 protocol/response/ok/OkPacket#status.: Statusrust-analyzer cargo sqlx-mysql 0.8.3 protocol/response/status/Status#, |
| 14 | pub warningsrust-analyzer cargo sqlx-mysql 0.8.3 protocol/response/ok/OkPacket#warnings.: u16, |
| 15 | } |
| 16 | |
| 17 | impl ProtocolDecoderust-analyzer cargo sqlx-core 0.8.3 io/decode/ProtocolDecode#<'_> for OkPacketrust-analyzer cargo sqlx-mysql 0.8.3 protocol/response/ok/OkPacket# { |
| 18 | fn decode_withrust-analyzer cargo sqlx-mysql 0.8.3 protocol/response/ok/impl#[OkPacket][`ProtocolDecode<'_, ()>`]decode_with().(mut buf: Bytesrust-analyzer cargo bytes 1.12.1 bytes/Bytes#, _: ()) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo sqlx-mysql 0.8.3 protocol/response/ok/impl#[OkPacket][`ProtocolDecode<'_, ()>`], Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#> { |
| 19 | let header = buf.get_u8rust-analyzer cargo bytes 1.12.1 buf/buf_impl/Buf#get_u8().(); |
| 20 | if header 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().0 && header 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().0xfe { |
| 21 | 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!!( |
| 22 | "expected 0x00 or 0xfe (OK_Packet) but found 0x{:02x}", |
| 23 | header |
| 24 | )); |
| 25 | } |
| 26 | |
| 27 | let affected_rows = buf.get_uint_lenencrust-analyzer cargo sqlx-mysql 0.8.3 io/buf/impl#[Bytes][MySqlBufExt]get_uint_lenenc().(); |
| 28 | let last_insert_id = buf.get_uint_lenencrust-analyzer cargo sqlx-mysql 0.8.3 io/buf/impl#[Bytes][MySqlBufExt]get_uint_lenenc().(); |
| 29 | let status = Statusrust-analyzer cargo sqlx-mysql 0.8.3 protocol/response/status/Status#::from_bits_truncaterust-analyzer cargo sqlx-mysql 0.8.3 protocol/response/status/impl#[Status]from_bits_truncate().(buf.get_u16_lerust-analyzer cargo bytes 1.12.1 buf/buf_impl/Buf#get_u16_le().()); |
| 30 | let warnings = buf.get_u16_lerust-analyzer cargo bytes 1.12.1 buf/buf_impl/Buf#get_u16_le().(); |
| 31 | |
| 32 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo sqlx-mysql 0.8.3 protocol/response/ok/impl#[OkPacket][`ProtocolDecode<'_, ()>`] { |
| 33 | affected_rowsrust-analyzer cargo sqlx-mysql 0.8.3 protocol/response/ok/OkPacket#affected_rows., |
| 34 | last_insert_idrust-analyzer cargo sqlx-mysql 0.8.3 protocol/response/ok/OkPacket#last_insert_id., |
| 35 | statusrust-analyzer cargo sqlx-mysql 0.8.3 protocol/response/ok/OkPacket#status., |
| 36 | warningsrust-analyzer cargo sqlx-mysql 0.8.3 protocol/response/ok/OkPacket#warnings., |
| 37 | }) |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 42 | fn test_decode_ok_packetrust-analyzer cargo sqlx-mysql 0.8.3 protocol/response/ok/test_decode_ok_packet().() { |
| 43 | const DATArust-analyzer cargo sqlx-mysql 0.8.3 protocol/response/ok/DATA.: &[u8] = b"\x00\x00\x00\x02@\x00\x00"; |
| 44 | |
| 45 | let p = OkPacketrust-analyzer cargo sqlx-mysql 0.8.3 protocol/response/ok/OkPacket#::decoderust-analyzer cargo sqlx-core 0.8.3 io/decode/ProtocolDecode#decode().(DATArust-analyzer cargo sqlx-mysql 0.8.3 protocol/response/ok/DATA..intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 46 | |
| 47 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(p.affected_rowsrust-analyzer cargo sqlx-mysql 0.8.3 protocol/response/ok/OkPacket#affected_rows., 0); |
| 48 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(p.last_insert_idrust-analyzer cargo sqlx-mysql 0.8.3 protocol/response/ok/OkPacket#last_insert_id., 0); |
| 49 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(p.warningsrust-analyzer cargo sqlx-mysql 0.8.3 protocol/response/ok/OkPacket#warnings., 0); |
| 50 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(p.statusrust-analyzer cargo sqlx-mysql 0.8.3 protocol/response/ok/OkPacket#status..containsrust-analyzer cargo sqlx-mysql 0.8.3 protocol/response/status/impl#[Status]contains().(Statusrust-analyzer cargo sqlx-mysql 0.8.3 protocol/response/status/Status#::SERVER_STATUS_AUTOCOMMITrust-analyzer cargo sqlx-mysql 0.8.3 protocol/response/status/impl#[Status]SERVER_STATUS_AUTOCOMMIT.)); |
| 51 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(p.statusrust-analyzer cargo sqlx-mysql 0.8.3 protocol/response/ok/OkPacket#status..containsrust-analyzer cargo sqlx-mysql 0.8.3 protocol/response/status/impl#[Status]contains().(Statusrust-analyzer cargo sqlx-mysql 0.8.3 protocol/response/status/Status#::SERVER_SESSION_STATE_CHANGEDrust-analyzer cargo sqlx-mysql 0.8.3 protocol/response/status/impl#[Status]SERVER_SESSION_STATE_CHANGED.)); |
| 52 | } |