| 1 | //! Frontend message serialization. |
| 2 | #![allow(missing_docs)] |
| 3 | |
| 4 | use byteorderrust-analyzer cargo byteorder 1.5.0 crate/::{BigEndianrust-analyzer cargo byteorder 1.5.0 BigEndian#, ByteOrderrust-analyzer cargo byteorder 1.5.0 ByteOrder#}; |
| 5 | use bytesrust-analyzer cargo bytes 1.11.1 crate/::{Bufrust-analyzer cargo bytes 1.11.1 buf/buf_impl/Buf#, BufMutrust-analyzer cargo bytes 1.11.1 buf/buf_mut/BufMut#, BytesMutrust-analyzer cargo bytes 1.11.1 bytes_mut/BytesMut#}; |
| 6 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std error/::Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error#; |
| 7 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/; |
| 8 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::markerrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/; |
| 9 | |
| 10 | use craterust-analyzer cargo postgres-protocol 0.6.12 crate/::{FromUsizerust-analyzer cargo postgres-protocol 0.6.12 FromUsize#, IsNullrust-analyzer cargo postgres-protocol 0.6.12 IsNull#, Oidrust-analyzer cargo postgres-protocol 0.6.12 Oid#, write_nullablerust-analyzer cargo postgres-protocol 0.6.12 write_nullable().}; |
| 11 | |
| 12 | #[inline] |
| 13 | fn write_bodyrust-analyzer cargo postgres-protocol 0.6.12 message/frontend/write_body().<F, E>(buf: &mut BytesMutrust-analyzer cargo bytes 1.11.1 bytes_mut/BytesMut#, f: F) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), E> |
| 14 | where |
| 15 | F: FnOncerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/FnOnce#(&mut BytesMutrust-analyzer cargo bytes 1.11.1 bytes_mut/BytesMut#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), E>, |
| 16 | E: Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#>, |
| 17 | { |
| 18 | let base = buf.lenrust-analyzer cargo bytes 1.11.1 bytes_mut/impl#[BytesMut]len().(); |
| 19 | buf.extend_from_slicerust-analyzer cargo bytes 1.11.1 bytes_mut/impl#[BytesMut]extend_from_slice().(&[0; 4]); |
| 20 | |
| 21 | f(buf)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 22 | |
| 23 | let size = i32::from_usizerust-analyzer cargo postgres-protocol 0.6.12 impl#[i32][FromUsize]from_usize().(buf.lenrust-analyzer cargo bytes 1.11.1 bytes_mut/impl#[BytesMut]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().base)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 24 | BigEndianrust-analyzer cargo byteorder 1.5.0 BigEndian#::write_i32rust-analyzer cargo byteorder 1.5.0 ByteOrder#write_i32().(&mut buf[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().base..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut()., size); |
| 25 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 26 | } |
| 27 | |
| 28 | pub enum BindErrorrust-analyzer cargo postgres-protocol 0.6.12 message/frontend/BindError# { |
| 29 | Conversionrust-analyzer cargo postgres-protocol 0.6.12 message/frontend/BindError#Conversion#(Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + markerrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/::Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync# + Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send#>), |
| 30 | Serializationrust-analyzer cargo postgres-protocol 0.6.12 message/frontend/BindError#Serialization#(iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#), |
| 31 | } |
| 32 | |
| 33 | impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + markerrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/::Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync# + Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send#>> for BindErrorrust-analyzer cargo postgres-protocol 0.6.12 message/frontend/BindError# { |
| 34 | #[inline] |
| 35 | fn fromrust-analyzer cargo postgres-protocol 0.6.12 message/frontend/impl#[BindError][`From<Box<dyn Error + Send + Sync + 'static>>`]from().(e: Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + markerrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/::Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync# + Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send#>) -> BindErrorrust-analyzer cargo postgres-protocol 0.6.12 message/frontend/BindError# { |
| 36 | BindErrorrust-analyzer cargo postgres-protocol 0.6.12 message/frontend/BindError#::Conversionrust-analyzer cargo postgres-protocol 0.6.12 message/frontend/BindError#Conversion#(e) |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#> for BindErrorrust-analyzer cargo postgres-protocol 0.6.12 message/frontend/BindError# { |
| 41 | #[inline] |
| 42 | fn fromrust-analyzer cargo postgres-protocol 0.6.12 message/frontend/impl#[BindError][`From<io::Error>`]from().(e: iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#) -> BindErrorrust-analyzer cargo postgres-protocol 0.6.12 message/frontend/BindError# { |
| 43 | BindErrorrust-analyzer cargo postgres-protocol 0.6.12 message/frontend/BindError#::Serializationrust-analyzer cargo postgres-protocol 0.6.12 message/frontend/BindError#Serialization#(e) |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | #[inline] |
| 48 | pub fn bindrust-analyzer cargo postgres-protocol 0.6.12 message/frontend/bind().<I, J, F, T, K>( |
| 49 | portal: &str, |
| 50 | statement: &str, |
| 51 | formats: I, |
| 52 | values: J, |
| 53 | mut serializer: F, |
| 54 | result_formats: K, |
| 55 | buf: &mut BytesMutrust-analyzer cargo bytes 1.11.1 bytes_mut/BytesMut#, |
| 56 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), BindErrorrust-analyzer cargo postgres-protocol 0.6.12 message/frontend/BindError#> |
| 57 | where |
| 58 | I: IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#Item# = i16>, |
| 59 | J: IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#Item# = T>, |
| 60 | F: FnMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/FnMut#(T, &mut BytesMutrust-analyzer cargo bytes 1.11.1 bytes_mut/BytesMut#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<IsNullrust-analyzer cargo postgres-protocol 0.6.12 IsNull#, Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + markerrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/::Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync# + Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send#>>, |
| 61 | K: IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#Item# = i16>, |
| 62 | { |
| 63 | buf.put_u8rust-analyzer cargo bytes 1.11.1 buf/buf_mut/BufMut#put_u8().(b'B'); |
| 64 | |
| 65 | write_bodyrust-analyzer cargo postgres-protocol 0.6.12 message/frontend/write_body().(buf, |buf| { |
| 66 | write_cstrrust-analyzer cargo postgres-protocol 0.6.12 message/frontend/write_cstr().(portal.as_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_bytes().(), buf)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 67 | write_cstrrust-analyzer cargo postgres-protocol 0.6.12 message/frontend/write_cstr().(statement.as_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_bytes().(), buf)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 68 | write_countedrust-analyzer cargo postgres-protocol 0.6.12 message/frontend/write_counted().( |
| 69 | formats, |
| 70 | |f, buf| { |
| 71 | buf.put_i16rust-analyzer cargo bytes 1.11.1 buf/buf_mut/BufMut#put_i16().(f); |
| 72 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#::<_, iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#>(()) |
| 73 | }, |
| 74 | buf, |
| 75 | )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 76 | write_countedrust-analyzer cargo postgres-protocol 0.6.12 message/frontend/write_counted().( |
| 77 | values, |
| 78 | |v, buf| write_nullablerust-analyzer cargo postgres-protocol 0.6.12 write_nullable().(|buf| serializer(v, buf), buf), |
| 79 | buf, |
| 80 | )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 81 | write_countedrust-analyzer cargo postgres-protocol 0.6.12 message/frontend/write_counted().( |
| 82 | result_formats, |
| 83 | |f, buf| { |
| 84 | buf.put_i16rust-analyzer cargo bytes 1.11.1 buf/buf_mut/BufMut#put_i16().(f); |
| 85 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#::<_, iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#>(()) |
| 86 | }, |
| 87 | buf, |
| 88 | )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 89 | |
| 90 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 91 | }) |
| 92 | } |
| 93 | |
| 94 | #[inline] |
| 95 | fn write_countedrust-analyzer cargo postgres-protocol 0.6.12 message/frontend/write_counted().<I, T, F, E>(items: I, mut serializer: F, buf: &mut BytesMutrust-analyzer cargo bytes 1.11.1 bytes_mut/BytesMut#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), E> |
| 96 | where |
| 97 | I: IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#Item# = T>, |
| 98 | F: FnMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/FnMut#(T, &mut BytesMutrust-analyzer cargo bytes 1.11.1 bytes_mut/BytesMut#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), E>, |
| 99 | E: Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#>, |
| 100 | { |
| 101 | let base = buf.lenrust-analyzer cargo bytes 1.11.1 bytes_mut/impl#[BytesMut]len().(); |
| 102 | buf.extend_from_slicerust-analyzer cargo bytes 1.11.1 bytes_mut/impl#[BytesMut]extend_from_slice().(&[0; 2]); |
| 103 | let mut count = 0; |
| 104 | for item in items { |
| 105 | serializer(item, buf)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 106 | count rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().1; |
| 107 | } |
| 108 | let count = u16::from_usizerust-analyzer cargo postgres-protocol 0.6.12 impl#[u16][FromUsize]from_usize().(count)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 109 | BigEndianrust-analyzer cargo byteorder 1.5.0 BigEndian#::write_u16rust-analyzer cargo byteorder 1.5.0 impl#[BigEndian][ByteOrder]write_u16().(&mut buf[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().base..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut()., count); |
| 110 | |
| 111 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 112 | } |
| 113 | |
| 114 | #[inline] |
| 115 | pub fn cancel_requestrust-analyzer cargo postgres-protocol 0.6.12 message/frontend/cancel_request().(process_id: i32, secret_key: i32, buf: &mut BytesMutrust-analyzer cargo bytes 1.11.1 bytes_mut/BytesMut#) { |
| 116 | write_bodyrust-analyzer cargo postgres-protocol 0.6.12 message/frontend/write_body().(buf, |buf| { |
| 117 | buf.put_i32rust-analyzer cargo bytes 1.11.1 buf/buf_mut/BufMut#put_i32().(80_877_102); |
| 118 | buf.put_i32rust-analyzer cargo bytes 1.11.1 buf/buf_mut/BufMut#put_i32().(process_id); |
| 119 | buf.put_i32rust-analyzer cargo bytes 1.11.1 buf/buf_mut/BufMut#put_i32().(secret_key); |
| 120 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#::<_, iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#>(()) |
| 121 | }) |
| 122 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 123 | } |
| 124 | |
| 125 | #[inline] |
| 126 | pub fn closerust-analyzer cargo postgres-protocol 0.6.12 message/frontend/close().(variant: u8, name: &str, buf: &mut BytesMutrust-analyzer cargo bytes 1.11.1 bytes_mut/BytesMut#) -> iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<()> { |
| 127 | buf.put_u8rust-analyzer cargo bytes 1.11.1 buf/buf_mut/BufMut#put_u8().(b'C'); |
| 128 | write_bodyrust-analyzer cargo postgres-protocol 0.6.12 message/frontend/write_body().(buf, |buf| { |
| 129 | buf.put_u8rust-analyzer cargo bytes 1.11.1 buf/buf_mut/BufMut#put_u8().(variant); |
| 130 | write_cstrrust-analyzer cargo postgres-protocol 0.6.12 message/frontend/write_cstr().(name.as_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_bytes().(), buf) |
| 131 | }) |
| 132 | } |
| 133 | |
| 134 | pub struct CopyDatarust-analyzer cargo postgres-protocol 0.6.12 message/frontend/CopyData#<T> { |
| 135 | bufrust-analyzer cargo postgres-protocol 0.6.12 message/frontend/CopyData#buf.: T, |
| 136 | lenrust-analyzer cargo postgres-protocol 0.6.12 message/frontend/CopyData#len.: i32, |
| 137 | } |
| 138 | |
| 139 | impl<T> CopyDatarust-analyzer cargo postgres-protocol 0.6.12 message/frontend/CopyData#<T> |
| 140 | where |
| 141 | T: Bufrust-analyzer cargo bytes 1.11.1 buf/buf_impl/Buf#, |
| 142 | { |
| 143 | pub fn newrust-analyzer cargo postgres-protocol 0.6.12 message/frontend/impl#[`CopyData<T>`]new().(buf: T) -> iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<CopyDatarust-analyzer cargo postgres-protocol 0.6.12 message/frontend/CopyData#<T>> { |
| 144 | let len = buf |
| 145 | .remainingrust-analyzer cargo bytes 1.11.1 buf/buf_impl/Buf#remaining().() |
| 146 | .checked_addrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[usize]checked_add().(4) |
| 147 | .and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]and_then().(|l| i32::try_fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/ptr_try_from_impls/impl#[i32][`TryFrom<usize>`]try_from().(l).okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().()) |
| 148 | .ok_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]ok_or_else().(|| { |
| 149 | iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[Error]new().(iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::ErrorKindrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#::InvalidInputrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#InvalidInput#, "message length overflow") |
| 150 | })?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 151 | |
| 152 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(CopyDatarust-analyzer cargo postgres-protocol 0.6.12 message/frontend/CopyData# { bufrust-analyzer cargo postgres-protocol 0.6.12 message/frontend/CopyData#buf., lenrust-analyzer cargo postgres-protocol 0.6.12 message/frontend/CopyData#len. }) |
| 153 | } |
| 154 | |
| 155 | pub fn writerust-analyzer cargo postgres-protocol 0.6.12 message/frontend/impl#[`CopyData<T>`]write().(self, out: &mut BytesMutrust-analyzer cargo bytes 1.11.1 bytes_mut/BytesMut#) { |
| 156 | out.put_u8rust-analyzer cargo bytes 1.11.1 buf/buf_mut/BufMut#put_u8().(b'd'); |
| 157 | out.put_i32rust-analyzer cargo bytes 1.11.1 buf/buf_mut/BufMut#put_i32().(self.lenrust-analyzer cargo postgres-protocol 0.6.12 message/frontend/CopyData#len.); |
| 158 | out.putrust-analyzer cargo bytes 1.11.1 bytes_mut/impl#[BytesMut][BufMut]put().(self.bufrust-analyzer cargo postgres-protocol 0.6.12 message/frontend/CopyData#buf.); |
| 159 | } |
| 160 | } |
| 161 | |
| 162 | #[inline] |
| 163 | pub fn copy_donerust-analyzer cargo postgres-protocol 0.6.12 message/frontend/copy_done().(buf: &mut BytesMutrust-analyzer cargo bytes 1.11.1 bytes_mut/BytesMut#) { |
| 164 | buf.put_u8rust-analyzer cargo bytes 1.11.1 buf/buf_mut/BufMut#put_u8().(b'c'); |
| 165 | write_bodyrust-analyzer cargo postgres-protocol 0.6.12 message/frontend/write_body().(buf, |_| Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#::<(), iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#>(())).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 166 | } |
| 167 | |
| 168 | #[inline] |
| 169 | pub fn copy_failrust-analyzer cargo postgres-protocol 0.6.12 message/frontend/copy_fail().(message: &str, buf: &mut BytesMutrust-analyzer cargo bytes 1.11.1 bytes_mut/BytesMut#) -> iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<()> { |
| 170 | buf.put_u8rust-analyzer cargo bytes 1.11.1 buf/buf_mut/BufMut#put_u8().(b'f'); |
| 171 | write_bodyrust-analyzer cargo postgres-protocol 0.6.12 message/frontend/write_body().(buf, |buf| write_cstrrust-analyzer cargo postgres-protocol 0.6.12 message/frontend/write_cstr().(message.as_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_bytes().(), buf)) |
| 172 | } |
| 173 | |
| 174 | #[inline] |
| 175 | pub fn describerust-analyzer cargo postgres-protocol 0.6.12 message/frontend/describe().(variant: u8, name: &str, buf: &mut BytesMutrust-analyzer cargo bytes 1.11.1 bytes_mut/BytesMut#) -> iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<()> { |
| 176 | buf.put_u8rust-analyzer cargo bytes 1.11.1 buf/buf_mut/BufMut#put_u8().(b'D'); |
| 177 | write_bodyrust-analyzer cargo postgres-protocol 0.6.12 message/frontend/write_body().(buf, |buf| { |
| 178 | buf.put_u8rust-analyzer cargo bytes 1.11.1 buf/buf_mut/BufMut#put_u8().(variant); |
| 179 | write_cstrrust-analyzer cargo postgres-protocol 0.6.12 message/frontend/write_cstr().(name.as_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_bytes().(), buf) |
| 180 | }) |
| 181 | } |
| 182 | |
| 183 | #[inline] |
| 184 | pub fn executerust-analyzer cargo postgres-protocol 0.6.12 message/frontend/execute().(portal: &str, max_rows: i32, buf: &mut BytesMutrust-analyzer cargo bytes 1.11.1 bytes_mut/BytesMut#) -> iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<()> { |
| 185 | buf.put_u8rust-analyzer cargo bytes 1.11.1 buf/buf_mut/BufMut#put_u8().(b'E'); |
| 186 | write_bodyrust-analyzer cargo postgres-protocol 0.6.12 message/frontend/write_body().(buf, |buf| { |
| 187 | write_cstrrust-analyzer cargo postgres-protocol 0.6.12 message/frontend/write_cstr().(portal.as_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_bytes().(), buf)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 188 | buf.put_i32rust-analyzer cargo bytes 1.11.1 buf/buf_mut/BufMut#put_i32().(max_rows); |
| 189 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 190 | }) |
| 191 | } |
| 192 | |
| 193 | #[inline] |
| 194 | pub fn parserust-analyzer cargo postgres-protocol 0.6.12 message/frontend/parse().<I>(name: &str, query: &str, param_types: I, buf: &mut BytesMutrust-analyzer cargo bytes 1.11.1 bytes_mut/BytesMut#) -> iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<()> |
| 195 | where |
| 196 | I: IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#Item# = Oidrust-analyzer cargo postgres-protocol 0.6.12 Oid#>, |
| 197 | { |
| 198 | buf.put_u8rust-analyzer cargo bytes 1.11.1 buf/buf_mut/BufMut#put_u8().(b'P'); |
| 199 | write_bodyrust-analyzer cargo postgres-protocol 0.6.12 message/frontend/write_body().(buf, |buf| { |
| 200 | write_cstrrust-analyzer cargo postgres-protocol 0.6.12 message/frontend/write_cstr().(name.as_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_bytes().(), buf)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 201 | write_cstrrust-analyzer cargo postgres-protocol 0.6.12 message/frontend/write_cstr().(query.as_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_bytes().(), buf)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 202 | write_countedrust-analyzer cargo postgres-protocol 0.6.12 message/frontend/write_counted().( |
| 203 | param_types, |
| 204 | |t, buf| { |
| 205 | buf.put_u32rust-analyzer cargo bytes 1.11.1 buf/buf_mut/BufMut#put_u32().(t); |
| 206 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#::<_, iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#>(()) |
| 207 | }, |
| 208 | buf, |
| 209 | )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 210 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 211 | }) |
| 212 | } |
| 213 | |
| 214 | #[inline] |
| 215 | pub fn password_messagerust-analyzer cargo postgres-protocol 0.6.12 message/frontend/password_message().(password: &[u8], buf: &mut BytesMutrust-analyzer cargo bytes 1.11.1 bytes_mut/BytesMut#) -> iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<()> { |
| 216 | buf.put_u8rust-analyzer cargo bytes 1.11.1 buf/buf_mut/BufMut#put_u8().(b'p'); |
| 217 | write_bodyrust-analyzer cargo postgres-protocol 0.6.12 message/frontend/write_body().(buf, |buf| write_cstrrust-analyzer cargo postgres-protocol 0.6.12 message/frontend/write_cstr().(password, buf)) |
| 218 | } |
| 219 | |
| 220 | #[inline] |
| 221 | pub fn queryrust-analyzer cargo postgres-protocol 0.6.12 message/frontend/query().(query: &str, buf: &mut BytesMutrust-analyzer cargo bytes 1.11.1 bytes_mut/BytesMut#) -> iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<()> { |
| 222 | buf.put_u8rust-analyzer cargo bytes 1.11.1 buf/buf_mut/BufMut#put_u8().(b'Q'); |
| 223 | write_bodyrust-analyzer cargo postgres-protocol 0.6.12 message/frontend/write_body().(buf, |buf| write_cstrrust-analyzer cargo postgres-protocol 0.6.12 message/frontend/write_cstr().(query.as_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_bytes().(), buf)) |
| 224 | } |
| 225 | |
| 226 | #[inline] |
| 227 | pub fn sasl_initial_responserust-analyzer cargo postgres-protocol 0.6.12 message/frontend/sasl_initial_response().(mechanism: &str, data: &[u8], buf: &mut BytesMutrust-analyzer cargo bytes 1.11.1 bytes_mut/BytesMut#) -> iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<()> { |
| 228 | buf.put_u8rust-analyzer cargo bytes 1.11.1 buf/buf_mut/BufMut#put_u8().(b'p'); |
| 229 | write_bodyrust-analyzer cargo postgres-protocol 0.6.12 message/frontend/write_body().(buf, |buf| { |
| 230 | write_cstrrust-analyzer cargo postgres-protocol 0.6.12 message/frontend/write_cstr().(mechanism.as_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_bytes().(), buf)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 231 | let len = i32::from_usizerust-analyzer cargo postgres-protocol 0.6.12 impl#[i32][FromUsize]from_usize().(data.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().())?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 232 | buf.put_i32rust-analyzer cargo bytes 1.11.1 buf/buf_mut/BufMut#put_i32().(len); |
| 233 | buf.put_slicerust-analyzer cargo bytes 1.11.1 bytes_mut/impl#[BytesMut][BufMut]put_slice().(data); |
| 234 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 235 | }) |
| 236 | } |
| 237 | |
| 238 | #[inline] |
| 239 | pub fn sasl_responserust-analyzer cargo postgres-protocol 0.6.12 message/frontend/sasl_response().(data: &[u8], buf: &mut BytesMutrust-analyzer cargo bytes 1.11.1 bytes_mut/BytesMut#) -> iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<()> { |
| 240 | buf.put_u8rust-analyzer cargo bytes 1.11.1 buf/buf_mut/BufMut#put_u8().(b'p'); |
| 241 | write_bodyrust-analyzer cargo postgres-protocol 0.6.12 message/frontend/write_body().(buf, |buf| { |
| 242 | buf.put_slicerust-analyzer cargo bytes 1.11.1 bytes_mut/impl#[BytesMut][BufMut]put_slice().(data); |
| 243 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 244 | }) |
| 245 | } |
| 246 | |
| 247 | #[inline] |
| 248 | pub fn ssl_requestrust-analyzer cargo postgres-protocol 0.6.12 message/frontend/ssl_request().(buf: &mut BytesMutrust-analyzer cargo bytes 1.11.1 bytes_mut/BytesMut#) { |
| 249 | write_bodyrust-analyzer cargo postgres-protocol 0.6.12 message/frontend/write_body().(buf, |buf| { |
| 250 | buf.put_i32rust-analyzer cargo bytes 1.11.1 buf/buf_mut/BufMut#put_i32().(80_877_103); |
| 251 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#::<_, iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#>(()) |
| 252 | }) |
| 253 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 254 | } |
| 255 | |
| 256 | #[inline] |
| 257 | pub fn startup_messagerust-analyzer cargo postgres-protocol 0.6.12 message/frontend/startup_message().<'a, I>(parameters: I, buf: &mut BytesMutrust-analyzer cargo bytes 1.11.1 bytes_mut/BytesMut#) -> iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<()> |
| 258 | where |
| 259 | I: IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#Item# = (&'a str, &'a str)>, |
| 260 | { |
| 261 | write_bodyrust-analyzer cargo postgres-protocol 0.6.12 message/frontend/write_body().(buf, |buf| { |
| 262 | // postgres protocol version 3.0(196608) in big-endian |
| 263 | buf.put_i32rust-analyzer cargo bytes 1.11.1 buf/buf_mut/BufMut#put_i32().(0x00_03_00_00); |
| 264 | for (key, value) in parameters { |
| 265 | write_cstrrust-analyzer cargo postgres-protocol 0.6.12 message/frontend/write_cstr().(key.as_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_bytes().(), buf)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 266 | write_cstrrust-analyzer cargo postgres-protocol 0.6.12 message/frontend/write_cstr().(value.as_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_bytes().(), buf)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 267 | } |
| 268 | buf.put_u8rust-analyzer cargo bytes 1.11.1 buf/buf_mut/BufMut#put_u8().(0); |
| 269 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 270 | }) |
| 271 | } |
| 272 | |
| 273 | #[inline] |
| 274 | pub fn flushrust-analyzer cargo postgres-protocol 0.6.12 message/frontend/flush().(buf: &mut BytesMutrust-analyzer cargo bytes 1.11.1 bytes_mut/BytesMut#) { |
| 275 | buf.put_u8rust-analyzer cargo bytes 1.11.1 buf/buf_mut/BufMut#put_u8().(b'H'); |
| 276 | write_bodyrust-analyzer cargo postgres-protocol 0.6.12 message/frontend/write_body().(buf, |_| Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#::<(), iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#>(())).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 277 | } |
| 278 | |
| 279 | #[inline] |
| 280 | pub fn syncrust-analyzer cargo postgres-protocol 0.6.12 message/frontend/sync().(buf: &mut BytesMutrust-analyzer cargo bytes 1.11.1 bytes_mut/BytesMut#) { |
| 281 | buf.put_u8rust-analyzer cargo bytes 1.11.1 buf/buf_mut/BufMut#put_u8().(b'S'); |
| 282 | write_bodyrust-analyzer cargo postgres-protocol 0.6.12 message/frontend/write_body().(buf, |_| Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#::<(), iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#>(())).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 283 | } |
| 284 | |
| 285 | #[inline] |
| 286 | pub fn terminaterust-analyzer cargo postgres-protocol 0.6.12 message/frontend/terminate().(buf: &mut BytesMutrust-analyzer cargo bytes 1.11.1 bytes_mut/BytesMut#) { |
| 287 | buf.put_u8rust-analyzer cargo bytes 1.11.1 buf/buf_mut/BufMut#put_u8().(b'X'); |
| 288 | write_bodyrust-analyzer cargo postgres-protocol 0.6.12 message/frontend/write_body().(buf, |_| Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#::<(), iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#>(())).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 289 | } |
| 290 | |
| 291 | #[inline] |
| 292 | fn write_cstrrust-analyzer cargo postgres-protocol 0.6.12 message/frontend/write_cstr().(s: &[u8], buf: &mut BytesMutrust-analyzer cargo bytes 1.11.1 bytes_mut/BytesMut#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#> { |
| 293 | if s.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]contains().(&0) { |
| 294 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[Error]new().( |
| 295 | iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::ErrorKindrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#::InvalidInputrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#InvalidInput#, |
| 296 | "string contains embedded null", |
| 297 | )); |
| 298 | } |
| 299 | buf.put_slicerust-analyzer cargo bytes 1.11.1 bytes_mut/impl#[BytesMut][BufMut]put_slice().(s); |
| 300 | buf.put_u8rust-analyzer cargo bytes 1.11.1 buf/buf_mut/BufMut#put_u8().(0); |
| 301 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 302 | } |