| 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 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::numrust-analyzer cargo std https://github.com/rust-lang/rust/library/std num/::Saturatingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/saturating/Saturating#; |
| 3 | |
| 4 | 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#; |
| 5 | use craterust-analyzer cargo sqlx-postgres 0.8.3 crate/::iorust-analyzer cargo sqlx-postgres 0.8.3 io/::PgBufMutExtrust-analyzer cargo sqlx-postgres 0.8.3 io/buf_mut/PgBufMutExt#; |
| 6 | |
| 7 | mod authenticationrust-analyzer cargo sqlx-postgres 0.8.3 message/authentication/; |
| 8 | mod backend_key_datarust-analyzer cargo sqlx-postgres 0.8.3 message/backend_key_data/; |
| 9 | mod bindrust-analyzer cargo sqlx-postgres 0.8.3 message/bind/; |
| 10 | mod closerust-analyzer cargo sqlx-postgres 0.8.3 message/close/; |
| 11 | mod command_completerust-analyzer cargo sqlx-postgres 0.8.3 message/command_complete/; |
| 12 | mod copyrust-analyzer cargo sqlx-postgres 0.8.3 message/copy/; |
| 13 | mod data_rowrust-analyzer cargo sqlx-postgres 0.8.3 message/data_row/; |
| 14 | mod describerust-analyzer cargo sqlx-postgres 0.8.3 message/describe/; |
| 15 | mod executerust-analyzer cargo sqlx-postgres 0.8.3 message/execute/; |
| 16 | mod flushrust-analyzer cargo sqlx-postgres 0.8.3 message/flush/; |
| 17 | mod notificationrust-analyzer cargo sqlx-postgres 0.8.3 message/notification/; |
| 18 | mod parameter_descriptionrust-analyzer cargo sqlx-postgres 0.8.3 message/parameter_description/; |
| 19 | mod parameter_statusrust-analyzer cargo sqlx-postgres 0.8.3 message/parameter_status/; |
| 20 | mod parserust-analyzer cargo sqlx-postgres 0.8.3 message/parse/; |
| 21 | mod parse_completerust-analyzer cargo sqlx-postgres 0.8.3 message/parse_complete/; |
| 22 | mod passwordrust-analyzer cargo sqlx-postgres 0.8.3 message/password/; |
| 23 | mod queryrust-analyzer cargo sqlx-postgres 0.8.3 message/query/; |
| 24 | mod ready_for_queryrust-analyzer cargo sqlx-postgres 0.8.3 message/ready_for_query/; |
| 25 | mod responserust-analyzer cargo sqlx-postgres 0.8.3 message/response/; |
| 26 | mod row_descriptionrust-analyzer cargo sqlx-postgres 0.8.3 message/row_description/; |
| 27 | mod saslrust-analyzer cargo sqlx-postgres 0.8.3 message/sasl/; |
| 28 | mod ssl_requestrust-analyzer cargo sqlx-postgres 0.8.3 message/ssl_request/; |
| 29 | mod startuprust-analyzer cargo sqlx-postgres 0.8.3 message/startup/; |
| 30 | mod syncrust-analyzer cargo sqlx-postgres 0.8.3 message/sync/; |
| 31 | mod terminaterust-analyzer cargo sqlx-postgres 0.8.3 message/terminate/; |
| 32 | |
| 33 | pub use authenticationrust-analyzer cargo sqlx-postgres 0.8.3 message/authentication/::{Authenticationrust-analyzer cargo sqlx-postgres 0.8.3 message/authentication/Authentication#, AuthenticationSaslrust-analyzer cargo sqlx-postgres 0.8.3 message/authentication/AuthenticationSasl#}; |
| 34 | pub use backend_key_datarust-analyzer cargo sqlx-postgres 0.8.3 message/backend_key_data/::BackendKeyDatarust-analyzer cargo sqlx-postgres 0.8.3 message/backend_key_data/BackendKeyData#; |
| 35 | pub use bindrust-analyzer cargo sqlx-postgres 0.8.3 message/bind/::Bindrust-analyzer cargo sqlx-postgres 0.8.3 message/bind/Bind#; |
| 36 | pub use closerust-analyzer cargo sqlx-postgres 0.8.3 message/close/::Closerust-analyzer cargo sqlx-postgres 0.8.3 message/close/Close#; |
| 37 | pub use command_completerust-analyzer cargo sqlx-postgres 0.8.3 message/command_complete/::CommandCompleterust-analyzer cargo sqlx-postgres 0.8.3 message/command_complete/CommandComplete#; |
| 38 | pub use copyrust-analyzer cargo sqlx-postgres 0.8.3 message/copy/::{CopyDatarust-analyzer cargo sqlx-postgres 0.8.3 message/copy/CopyData#, CopyDonerust-analyzer cargo sqlx-postgres 0.8.3 message/copy/CopyDone#, CopyFailrust-analyzer cargo sqlx-postgres 0.8.3 message/copy/CopyFail#, CopyInResponserust-analyzer cargo sqlx-postgres 0.8.3 message/copy/CopyInResponse#, CopyOutResponserust-analyzer cargo sqlx-postgres 0.8.3 message/copy/CopyOutResponse#, CopyResponseDatarust-analyzer cargo sqlx-postgres 0.8.3 message/copy/CopyResponseData#}; |
| 39 | pub use data_rowrust-analyzer cargo sqlx-postgres 0.8.3 message/data_row/::DataRowrust-analyzer cargo sqlx-postgres 0.8.3 message/data_row/DataRow#; |
| 40 | pub use describerust-analyzer cargo sqlx-postgres 0.8.3 message/describe/::Describerust-analyzer cargo sqlx-postgres 0.8.3 message/describe/Describe#; |
| 41 | pub use executerust-analyzer cargo sqlx-postgres 0.8.3 message/execute/::Executerust-analyzer cargo sqlx-postgres 0.8.3 message/execute/Execute#; |
| 42 | #[allow(unused_imports)] |
| 43 | pub use flushrust-analyzer cargo sqlx-postgres 0.8.3 message/flush/::Flushrust-analyzer cargo sqlx-postgres 0.8.3 message/flush/Flush#; |
| 44 | pub use notificationrust-analyzer cargo sqlx-postgres 0.8.3 message/notification/::Notificationrust-analyzer cargo sqlx-postgres 0.8.3 message/notification/Notification#; |
| 45 | pub use parameter_descriptionrust-analyzer cargo sqlx-postgres 0.8.3 message/parameter_description/::ParameterDescriptionrust-analyzer cargo sqlx-postgres 0.8.3 message/parameter_description/ParameterDescription#; |
| 46 | pub use parameter_statusrust-analyzer cargo sqlx-postgres 0.8.3 message/parameter_status/::ParameterStatusrust-analyzer cargo sqlx-postgres 0.8.3 message/parameter_status/ParameterStatus#; |
| 47 | pub use parserust-analyzer cargo sqlx-postgres 0.8.3 message/parse/::Parserust-analyzer cargo sqlx-postgres 0.8.3 message/parse/Parse#; |
| 48 | pub use parse_completerust-analyzer cargo sqlx-postgres 0.8.3 message/parse_complete/::ParseCompleterust-analyzer cargo sqlx-postgres 0.8.3 message/parse_complete/ParseComplete#; |
| 49 | pub use passwordrust-analyzer cargo sqlx-postgres 0.8.3 message/password/::Passwordrust-analyzer cargo sqlx-postgres 0.8.3 message/password/Password#; |
| 50 | pub use queryrust-analyzer cargo sqlx-postgres 0.8.3 message/query/::Queryrust-analyzer cargo sqlx-postgres 0.8.3 message/query/Query#; |
| 51 | pub use ready_for_queryrust-analyzer cargo sqlx-postgres 0.8.3 message/ready_for_query/::{ReadyForQueryrust-analyzer cargo sqlx-postgres 0.8.3 message/ready_for_query/ReadyForQuery#, TransactionStatusrust-analyzer cargo sqlx-postgres 0.8.3 message/ready_for_query/TransactionStatus#}; |
| 52 | pub use responserust-analyzer cargo sqlx-postgres 0.8.3 message/response/::{Noticerust-analyzer cargo sqlx-postgres 0.8.3 message/response/Notice#, PgSeverityrust-analyzer cargo sqlx-postgres 0.8.3 message/response/PgSeverity#}; |
| 53 | pub use row_descriptionrust-analyzer cargo sqlx-postgres 0.8.3 message/row_description/::RowDescriptionrust-analyzer cargo sqlx-postgres 0.8.3 message/row_description/RowDescription#; |
| 54 | pub use saslrust-analyzer cargo sqlx-postgres 0.8.3 message/sasl/::{SaslInitialResponserust-analyzer cargo sqlx-postgres 0.8.3 message/sasl/SaslInitialResponse#, SaslResponserust-analyzer cargo sqlx-postgres 0.8.3 message/sasl/SaslResponse#}; |
| 55 | use sqlx_corerust-analyzer cargo sqlx-core 0.8.3 crate/::iorust-analyzer cargo sqlx-core 0.8.3 io/::ProtocolEncoderust-analyzer cargo sqlx-core 0.8.3 io/encode/ProtocolEncode#; |
| 56 | pub use ssl_requestrust-analyzer cargo sqlx-postgres 0.8.3 message/ssl_request/::SslRequestrust-analyzer cargo sqlx-postgres 0.8.3 message/ssl_request/SslRequest#; |
| 57 | pub use startuprust-analyzer cargo sqlx-postgres 0.8.3 message/startup/::Startuprust-analyzer cargo sqlx-postgres 0.8.3 message/startup/Startup#; |
| 58 | pub use syncrust-analyzer cargo sqlx-postgres 0.8.3 message/sync/::Syncrust-analyzer cargo sqlx-postgres 0.8.3 message/sync/Sync#; |
| 59 | pub use terminaterust-analyzer cargo sqlx-postgres 0.8.3 message/terminate/::Terminaterust-analyzer cargo sqlx-postgres 0.8.3 message/terminate/Terminate#; |
| 60 | |
| 61 | // Note: we can't use the same enum for both frontend and backend message formats |
| 62 | // because there are duplicated format codes between them. |
| 63 | // |
| 64 | // For example, `Close` (frontend) and `CommandComplete` (backend) both use format code `C`. |
| 65 | // <https://www.postgresql.org/docs/current/protocol-message-formats.html> |
| 66 | #[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:, PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:)] |
| 67 | #[repr(u8)] |
| 68 | pub enum FrontendMessageFormatrust-analyzer cargo sqlx-postgres 0.8.3 message/FrontendMessageFormat# { |
| 69 | Bindrust-analyzer cargo sqlx-postgres 0.8.3 message/FrontendMessageFormat#Bind# = b'B', |
| 70 | Closerust-analyzer cargo sqlx-postgres 0.8.3 message/FrontendMessageFormat#Close# = b'C', |
| 71 | CopyDatarust-analyzer cargo sqlx-postgres 0.8.3 message/FrontendMessageFormat#CopyData# = b'd', |
| 72 | CopyDonerust-analyzer cargo sqlx-postgres 0.8.3 message/FrontendMessageFormat#CopyDone# = b'c', |
| 73 | CopyFailrust-analyzer cargo sqlx-postgres 0.8.3 message/FrontendMessageFormat#CopyFail# = b'f', |
| 74 | Describerust-analyzer cargo sqlx-postgres 0.8.3 message/FrontendMessageFormat#Describe# = b'D', |
| 75 | Executerust-analyzer cargo sqlx-postgres 0.8.3 message/FrontendMessageFormat#Execute# = b'E', |
| 76 | Flushrust-analyzer cargo sqlx-postgres 0.8.3 message/FrontendMessageFormat#Flush# = b'H', |
| 77 | Parserust-analyzer cargo sqlx-postgres 0.8.3 message/FrontendMessageFormat#Parse# = b'P', |
| 78 | /// This message format is polymorphic. It's used for: |
| 79 | /// |
| 80 | /// * Plain password responses |
| 81 | /// * MD5 password responses |
| 82 | /// * SASL responses |
| 83 | /// * GSSAPI/SSPI responses |
| 84 | PasswordPolymorphicrust-analyzer cargo sqlx-postgres 0.8.3 message/FrontendMessageFormat#PasswordPolymorphic# = b'p', |
| 85 | Queryrust-analyzer cargo sqlx-postgres 0.8.3 message/FrontendMessageFormat#Query# = b'Q', |
| 86 | Syncrust-analyzer cargo sqlx-postgres 0.8.3 message/FrontendMessageFormat#Sync# = b'S', |
| 87 | Terminaterust-analyzer cargo sqlx-postgres 0.8.3 message/FrontendMessageFormat#Terminate# = b'X', |
| 88 | } |
| 89 | |
| 90 | #[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:, PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:)] |
| 91 | #[repr(u8)] |
| 92 | pub enum BackendMessageFormatrust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat# { |
| 93 | Authenticationrust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat#Authentication#, |
| 94 | BackendKeyDatarust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat#BackendKeyData#, |
| 95 | BindCompleterust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat#BindComplete#, |
| 96 | CloseCompleterust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat#CloseComplete#, |
| 97 | CommandCompleterust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat#CommandComplete#, |
| 98 | CopyDatarust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat#CopyData#, |
| 99 | CopyDonerust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat#CopyDone#, |
| 100 | CopyInResponserust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat#CopyInResponse#, |
| 101 | CopyOutResponserust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat#CopyOutResponse#, |
| 102 | DataRowrust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat#DataRow#, |
| 103 | EmptyQueryResponserust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat#EmptyQueryResponse#, |
| 104 | ErrorResponserust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat#ErrorResponse#, |
| 105 | NoDatarust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat#NoData#, |
| 106 | NoticeResponserust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat#NoticeResponse#, |
| 107 | NotificationResponserust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat#NotificationResponse#, |
| 108 | ParameterDescriptionrust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat#ParameterDescription#, |
| 109 | ParameterStatusrust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat#ParameterStatus#, |
| 110 | ParseCompleterust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat#ParseComplete#, |
| 111 | PortalSuspendedrust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat#PortalSuspended#, |
| 112 | ReadyForQueryrust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat#ReadyForQuery#, |
| 113 | RowDescriptionrust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat#RowDescription#, |
| 114 | } |
| 115 | |
| 116 | #[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:)] |
| 117 | pub struct ReceivedMessagerust-analyzer cargo sqlx-postgres 0.8.3 message/ReceivedMessage# { |
| 118 | pub formatrust-analyzer cargo sqlx-postgres 0.8.3 message/ReceivedMessage#format.: BackendMessageFormatrust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat#, |
| 119 | pub contentsrust-analyzer cargo sqlx-postgres 0.8.3 message/ReceivedMessage#contents.: Bytesrust-analyzer cargo bytes 1.12.1 bytes/Bytes#, |
| 120 | } |
| 121 | |
| 122 | impl ReceivedMessagerust-analyzer cargo sqlx-postgres 0.8.3 message/ReceivedMessage# { |
| 123 | #[inline] |
| 124 | pub fn decoderust-analyzer cargo sqlx-postgres 0.8.3 message/impl#[ReceivedMessage]decode().<T>(self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<T, Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#> |
| 125 | where |
| 126 | T: BackendMessagerust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessage#, |
| 127 | { |
| 128 | if T::FORMATrust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessage#FORMAT. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne().self.formatrust-analyzer cargo sqlx-postgres 0.8.3 message/ReceivedMessage#format. { |
| 129 | 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!!( |
| 130 | "Postgres protocol error: expected {:?}, got {:?}", |
| 131 | T::FORMATrust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessage#FORMAT., |
| 132 | self.formatrust-analyzer cargo sqlx-postgres 0.8.3 message/ReceivedMessage#format. |
| 133 | )); |
| 134 | } |
| 135 | |
| 136 | T::decode_bodyrust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessage#decode_body().(self.contentsrust-analyzer cargo sqlx-postgres 0.8.3 message/ReceivedMessage#contents.).map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|e| match e { |
| 137 | Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#::Protocolrust-analyzer cargo sqlx-core 0.8.3 error/Error#Protocol#(s) => { |
| 138 | err_protocolrust-analyzer cargo sqlx-core 0.8.3 error/err_protocol!!("Postgres protocol error (reading {:?}): {s}", self.formatrust-analyzer cargo sqlx-postgres 0.8.3 message/ReceivedMessage#format.) |
| 139 | } |
| 140 | other => other, |
| 141 | }) |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | impl BackendMessageFormatrust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat# { |
| 146 | pub fn try_from_u8rust-analyzer cargo sqlx-postgres 0.8.3 message/impl#[BackendMessageFormat]try_from_u8().(v: u8) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo sqlx-postgres 0.8.3 message/impl#[BackendMessageFormat], Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#> { |
| 147 | // https://www.postgresql.org/docs/current/protocol-message-formats.html |
| 148 | |
| 149 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(match v { |
| 150 | b'1' => BackendMessageFormatrust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat#::ParseCompleterust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat#ParseComplete#, |
| 151 | b'2' => BackendMessageFormatrust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat#::BindCompleterust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat#BindComplete#, |
| 152 | b'3' => BackendMessageFormatrust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat#::CloseCompleterust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat#CloseComplete#, |
| 153 | b'C' => BackendMessageFormatrust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat#::CommandCompleterust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat#CommandComplete#, |
| 154 | b'd' => BackendMessageFormatrust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat#::CopyDatarust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat#CopyData#, |
| 155 | b'c' => BackendMessageFormatrust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat#::CopyDonerust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat#CopyDone#, |
| 156 | b'G' => BackendMessageFormatrust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat#::CopyInResponserust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat#CopyInResponse#, |
| 157 | b'H' => BackendMessageFormatrust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat#::CopyOutResponserust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat#CopyOutResponse#, |
| 158 | b'D' => BackendMessageFormatrust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat#::DataRowrust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat#DataRow#, |
| 159 | b'E' => BackendMessageFormatrust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat#::ErrorResponserust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat#ErrorResponse#, |
| 160 | b'I' => BackendMessageFormatrust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat#::EmptyQueryResponserust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat#EmptyQueryResponse#, |
| 161 | b'A' => BackendMessageFormatrust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat#::NotificationResponserust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat#NotificationResponse#, |
| 162 | b'K' => BackendMessageFormatrust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat#::BackendKeyDatarust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat#BackendKeyData#, |
| 163 | b'N' => BackendMessageFormatrust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat#::NoticeResponserust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat#NoticeResponse#, |
| 164 | b'R' => BackendMessageFormatrust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat#::Authenticationrust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat#Authentication#, |
| 165 | b'S' => BackendMessageFormatrust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat#::ParameterStatusrust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat#ParameterStatus#, |
| 166 | b'T' => BackendMessageFormatrust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat#::RowDescriptionrust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat#RowDescription#, |
| 167 | b'Z' => BackendMessageFormatrust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat#::ReadyForQueryrust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat#ReadyForQuery#, |
| 168 | b'n' => BackendMessageFormatrust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat#::NoDatarust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat#NoData#, |
| 169 | b's' => BackendMessageFormatrust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat#::PortalSuspendedrust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat#PortalSuspended#, |
| 170 | b't' => BackendMessageFormatrust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat#::ParameterDescriptionrust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat#ParameterDescription#, |
| 171 | |
| 172 | _ => 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!!("unknown message type: {:?}", v as char)), |
| 173 | }) |
| 174 | } |
| 175 | } |
| 176 | |
| 177 | pub(craterust-analyzer cargo sqlx-postgres 0.8.3 crate/) trait FrontendMessagerust-analyzer cargo sqlx-postgres 0.8.3 message/FrontendMessage#: Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized# { |
| 178 | /// The format prefix of this message. |
| 179 | const FORMATrust-analyzer cargo sqlx-postgres 0.8.3 message/FrontendMessage#FORMAT.: FrontendMessageFormatrust-analyzer cargo sqlx-postgres 0.8.3 message/FrontendMessageFormat#; |
| 180 | |
| 181 | /// Return the amount of space, in bytes, to reserve in the buffer passed to [`Self::encode_body()`]. |
| 182 | fn body_size_hintrust-analyzer cargo sqlx-postgres 0.8.3 message/FrontendMessage#body_size_hint().(&self) -> Saturatingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/saturating/Saturating#<usize>; |
| 183 | |
| 184 | /// Encode this type as a Frontend message in the Postgres protocol. |
| 185 | /// |
| 186 | /// The implementation should *not* include `Self::FORMAT` or the length prefix. |
| 187 | fn encode_bodyrust-analyzer cargo sqlx-postgres 0.8.3 message/FrontendMessage#encode_body().(&self, buf: &mut Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8>) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#>; |
| 188 | |
| 189 | #[inline(always)] |
| 190 | #[cfg_attr(not(test), allow(dead_code))] |
| 191 | fn encode_msgrust-analyzer cargo sqlx-postgres 0.8.3 message/FrontendMessage#encode_msg().(self, buf: &mut Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8>) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#> { |
| 192 | EncodeMessagerust-analyzer cargo sqlx-postgres 0.8.3 message/EncodeMessage#(self).encoderust-analyzer cargo sqlx-core 0.8.3 io/encode/ProtocolEncode#encode().(buf) |
| 193 | } |
| 194 | } |
| 195 | |
| 196 | pub(craterust-analyzer cargo sqlx-postgres 0.8.3 crate/) trait BackendMessagerust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessage#: Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized# { |
| 197 | /// The expected message format. |
| 198 | /// |
| 199 | /// <https://www.postgresql.org/docs/current/protocol-message-formats.html> |
| 200 | const FORMATrust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessage#FORMAT.: BackendMessageFormatrust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat#; |
| 201 | |
| 202 | /// Decode this type from a Backend message in the Postgres protocol. |
| 203 | /// |
| 204 | /// The format code and length prefix have already been read and are not at the start of `bytes`. |
| 205 | fn decode_bodyrust-analyzer cargo sqlx-postgres 0.8.3 message/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#<Self, Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#>; |
| 206 | } |
| 207 | |
| 208 | pub struct EncodeMessagerust-analyzer cargo sqlx-postgres 0.8.3 message/EncodeMessage#<F>(pub F); |
| 209 | |
| 210 | impl<F: FrontendMessagerust-analyzer cargo sqlx-postgres 0.8.3 message/FrontendMessage#> ProtocolEncoderust-analyzer cargo sqlx-core 0.8.3 io/encode/ProtocolEncode#<'_, ()> for EncodeMessagerust-analyzer cargo sqlx-postgres 0.8.3 message/EncodeMessage#<F> { |
| 211 | fn encode_withrust-analyzer cargo sqlx-postgres 0.8.3 message/impl#[`EncodeMessage<F>`][`ProtocolEncode<'_, ()>`]encode_with().(&self, buf: &mut Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8>, _context: ()) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#> { |
| 212 | let mut size_hint = self.0rust-analyzer cargo sqlx-postgres 0.8.3 message/EncodeMessage#0..body_size_hintrust-analyzer cargo sqlx-postgres 0.8.3 message/FrontendMessage#body_size_hint().(); |
| 213 | // plus format code and length prefix |
| 214 | size_hint rust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/saturating/impl#[`Saturating<usize>`][`AddAssign<usize>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/saturating/impl#[`Saturating<usize>`][`AddAssign<usize>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/saturating/impl#[`Saturating<usize>`][`AddAssign<usize>`]add_assign().5; |
| 215 | |
| 216 | // don't panic if `size_hint` is ridiculous |
| 217 | buf.try_reserverust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]try_reserve().(size_hint.0rust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/saturating/Saturating#0.).map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|e| { |
| 218 | err_protocolrust-analyzer cargo sqlx-core 0.8.3 error/err_protocol!!( |
| 219 | "Postgres protocol: error allocating {} bytes for encoding message {:?}: {e}", |
| 220 | size_hint.0rust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/saturating/Saturating#0., |
| 221 | F::FORMATrust-analyzer cargo sqlx-postgres 0.8.3 message/FrontendMessage#FORMAT., |
| 222 | ) |
| 223 | })?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 224 | |
| 225 | buf.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(F::FORMATrust-analyzer cargo sqlx-postgres 0.8.3 message/FrontendMessage#FORMAT. as u8); |
| 226 | |
| 227 | buf.put_length_prefixedrust-analyzer cargo sqlx-postgres 0.8.3 io/buf_mut/impl#[`Vec<u8>`][PgBufMutExt]put_length_prefixed().(|buf| self.0rust-analyzer cargo sqlx-postgres 0.8.3 message/EncodeMessage#0..encode_bodyrust-analyzer cargo sqlx-postgres 0.8.3 message/FrontendMessage#encode_body().(buf)) |
| 228 | } |
| 229 | } |