| 1 | use craterust-analyzer cargo sqlx-postgres 0.8.3 crate/::iorust-analyzer cargo sqlx-postgres 0.8.3 io/::ProtocolEncoderust-analyzer cargo sqlx-core 0.8.3 io/encode/ProtocolEncode#; |
| 2 | |
| 3 | pub struct SslRequestrust-analyzer cargo sqlx-postgres 0.8.3 message/ssl_request/SslRequest#; |
| 4 | |
| 5 | impl SslRequestrust-analyzer cargo sqlx-postgres 0.8.3 message/ssl_request/SslRequest# { |
| 6 | // https://www.postgresql.org/docs/current/protocol-message-formats.html#PROTOCOL-MESSAGE-FORMATS-SSLREQUEST |
| 7 | pub const BYTESrust-analyzer cargo sqlx-postgres 0.8.3 message/ssl_request/impl#[SslRequest]BYTES.: &'static [u8] = b"\x00\x00\x00\x08\x04\xd2\x16\x2f"; |
| 8 | } |
| 9 | |
| 10 | // Cannot impl FrontendMessage because it does not have a format code |
| 11 | impl ProtocolEncoderust-analyzer cargo sqlx-core 0.8.3 io/encode/ProtocolEncode#<'_> for SslRequestrust-analyzer cargo sqlx-postgres 0.8.3 message/ssl_request/SslRequest# { |
| 12 | #[inline(always)] |
| 13 | fn encode_withrust-analyzer cargo sqlx-postgres 0.8.3 message/ssl_request/impl#[SslRequest][`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#<(), craterust-analyzer cargo sqlx-postgres 0.8.3 crate/::Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#> { |
| 14 | buf.extend_from_slicerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]extend_from_slice().(Selfrust-analyzer cargo sqlx-postgres 0.8.3 message/ssl_request/impl#[SslRequest][`ProtocolEncode<'_, ()>`]::BYTESrust-analyzer cargo sqlx-postgres 0.8.3 message/ssl_request/impl#[SslRequest]BYTES.); |
| 15 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 16 | } |
| 17 | } |
| 18 | |
| 19 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 20 | fn test_encode_ssl_requestrust-analyzer cargo sqlx-postgres 0.8.3 message/ssl_request/test_encode_ssl_request().() { |
| 21 | let mut buf = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().(); |
| 22 | |
| 23 | // Int32(8) |
| 24 | // Length of message contents in bytes, including self. |
| 25 | buf.extend_from_slicerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]extend_from_slice().(&8_u32.to_be_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]to_be_bytes().()); |
| 26 | |
| 27 | // Int32(80877103) |
| 28 | // The SSL request code. The value is chosen to contain 1234 in the most significant 16 bits, |
| 29 | // and 5679 in the least significant 16 bits. |
| 30 | // (To avoid confusion, this code must not be the same as any protocol version number.) |
| 31 | buf.extend_from_slicerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]extend_from_slice().(&(((1234 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`Shl<Self>`]shl().<<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`Shl<Self>`]shl(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`Shl<Self>`]shl().16) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`BitOr<Self>`]bitor().|rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`BitOr<Self>`]bitor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`BitOr<Self>`]bitor().5679) as u32).to_be_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]to_be_bytes().()); |
| 32 | |
| 33 | let mut encoded = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().(); |
| 34 | SslRequestrust-analyzer cargo sqlx-postgres 0.8.3 message/ssl_request/SslRequest#.encoderust-analyzer cargo sqlx-core 0.8.3 io/encode/ProtocolEncode#encode().(&mut encoded).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 35 | |
| 36 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(buf, SslRequestrust-analyzer cargo sqlx-postgres 0.8.3 message/ssl_request/SslRequest#::BYTESrust-analyzer cargo sqlx-postgres 0.8.3 message/ssl_request/impl#[SslRequest]BYTES.); |
| 37 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(buf, encoded); |
| 38 | } |