| 1 | use sqlx_corerust-analyzer cargo sqlx-core 0.8.3 crate/::bytesrust-analyzer cargo bytes 1.12.1 crate/::Bytesrust-analyzer cargo bytes 1.12.1 bytes/Bytes#; |
| 2 | |
| 3 | use craterust-analyzer cargo sqlx-postgres 0.8.3 crate/::errorrust-analyzer cargo sqlx-postgres 0.8.3 error/::Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#; |
| 4 | use craterust-analyzer cargo sqlx-postgres 0.8.3 crate/::messagerust-analyzer cargo sqlx-postgres 0.8.3 message/::{BackendMessagerust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessage#, BackendMessageFormatrust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat#}; |
| 5 | |
| 6 | #[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:)] |
| 7 | #[repr(u8)] |
| 8 | pub enum TransactionStatusrust-analyzer cargo sqlx-postgres 0.8.3 message/ready_for_query/TransactionStatus# { |
| 9 | /// Not in a transaction block. |
| 10 | Idlerust-analyzer cargo sqlx-postgres 0.8.3 message/ready_for_query/TransactionStatus#Idle# = b'I', |
| 11 | |
| 12 | /// In a transaction block. |
| 13 | Transactionrust-analyzer cargo sqlx-postgres 0.8.3 message/ready_for_query/TransactionStatus#Transaction# = b'T', |
| 14 | |
| 15 | /// In a _failed_ transaction block. Queries will be rejected until block is ended. |
| 16 | Errorrust-analyzer cargo sqlx-postgres 0.8.3 message/ready_for_query/TransactionStatus#Error# = b'E', |
| 17 | } |
| 18 | |
| 19 | #[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:)] |
| 20 | pub struct ReadyForQueryrust-analyzer cargo sqlx-postgres 0.8.3 message/ready_for_query/ReadyForQuery# { |
| 21 | pub transaction_statusrust-analyzer cargo sqlx-postgres 0.8.3 message/ready_for_query/ReadyForQuery#transaction_status.: TransactionStatusrust-analyzer cargo sqlx-postgres 0.8.3 message/ready_for_query/TransactionStatus#, |
| 22 | } |
| 23 | |
| 24 | impl BackendMessagerust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessage# for ReadyForQueryrust-analyzer cargo sqlx-postgres 0.8.3 message/ready_for_query/ReadyForQuery# { |
| 25 | const FORMATrust-analyzer cargo sqlx-postgres 0.8.3 message/ready_for_query/impl#[ReadyForQuery][BackendMessage]FORMAT.: BackendMessageFormatrust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat# = BackendMessageFormatrust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat#::ReadyForQueryrust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat#ReadyForQuery#; |
| 26 | |
| 27 | fn decode_bodyrust-analyzer cargo sqlx-postgres 0.8.3 message/ready_for_query/impl#[ReadyForQuery][BackendMessage]decode_body().(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-postgres 0.8.3 message/ready_for_query/impl#[ReadyForQuery][BackendMessage], Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#> { |
| 28 | let status = match buf[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). { |
| 29 | b'I' => TransactionStatusrust-analyzer cargo sqlx-postgres 0.8.3 message/ready_for_query/TransactionStatus#::Idlerust-analyzer cargo sqlx-postgres 0.8.3 message/ready_for_query/TransactionStatus#Idle#, |
| 30 | b'T' => TransactionStatusrust-analyzer cargo sqlx-postgres 0.8.3 message/ready_for_query/TransactionStatus#::Transactionrust-analyzer cargo sqlx-postgres 0.8.3 message/ready_for_query/TransactionStatus#Transaction#, |
| 31 | b'E' => TransactionStatusrust-analyzer cargo sqlx-postgres 0.8.3 message/ready_for_query/TransactionStatus#::Errorrust-analyzer cargo sqlx-postgres 0.8.3 message/ready_for_query/TransactionStatus#Error#, |
| 32 | |
| 33 | status => { |
| 34 | 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!!( |
| 35 | "unknown transaction status: {:?}", |
| 36 | status as char |
| 37 | )); |
| 38 | } |
| 39 | }; |
| 40 | |
| 41 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo sqlx-postgres 0.8.3 message/ready_for_query/impl#[ReadyForQuery][BackendMessage] { |
| 42 | transaction_statusrust-analyzer cargo sqlx-postgres 0.8.3 message/ready_for_query/ReadyForQuery#transaction_status.: status, |
| 43 | }) |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 48 | fn test_decode_ready_for_queryrust-analyzer cargo sqlx-postgres 0.8.3 message/ready_for_query/test_decode_ready_for_query().() -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#> { |
| 49 | const DATArust-analyzer cargo sqlx-postgres 0.8.3 message/ready_for_query/DATA.: &[u8] = b"E"; |
| 50 | |
| 51 | let m = ReadyForQueryrust-analyzer cargo sqlx-postgres 0.8.3 message/ready_for_query/ReadyForQuery#::decode_bodyrust-analyzer cargo sqlx-postgres 0.8.3 message/ready_for_query/impl#[ReadyForQuery][BackendMessage]decode_body().(Bytesrust-analyzer cargo bytes 1.12.1 bytes/Bytes#::from_staticrust-analyzer cargo bytes 1.12.1 bytes/impl#[Bytes]from_static().(DATArust-analyzer cargo sqlx-postgres 0.8.3 message/ready_for_query/DATA.))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 52 | |
| 53 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!(m.transaction_statusrust-analyzer cargo sqlx-postgres 0.8.3 message/ready_for_query/ReadyForQuery#transaction_status., TransactionStatusrust-analyzer cargo sqlx-postgres 0.8.3 message/ready_for_query/TransactionStatus#::Errorrust-analyzer cargo sqlx-postgres 0.8.3 message/ready_for_query/TransactionStatus#Error#)); |
| 54 | |
| 55 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 56 | } |