Debian Codegraph @

src/types/mod.rs

raw symbols SCIP
1 //! Conversions to and from Postgres's binary format for various types.
2 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#, ReadBytesExtrust-analyzer cargo byteorder 1.5.0 io/ReadBytesExt#};
3 use bytesrust-analyzer cargo bytes 1.11.1 crate/::{BufMutrust-analyzer cargo bytes 1.11.1 buf/buf_mut/BufMut#, BytesMutrust-analyzer cargo bytes 1.11.1 bytes_mut/BytesMut#};
4 use fallible_iteratorrust-analyzer cargo fallible-iterator 0.3.0 crate/::FallibleIteratorrust-analyzer cargo fallible-iterator 0.3.0 FallibleIterator#;
5 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::boxedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/::Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box# as StdBoxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#;
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/::Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#;
8 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::netrust-analyzer cargo std https://github.com/rust-lang/rust/library/std net/::{IpAddrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/ip_addr/IpAddr#, Ipv4Addrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/ip_addr/Ipv4Addr#, Ipv6Addrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/ip_addr/Ipv6Addr#};
9 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/;
10
11 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#, Lsnrust-analyzer cargo postgres-protocol 0.6.12 Lsn#, Oidrust-analyzer cargo postgres-protocol 0.6.12 Oid#, write_nullablerust-analyzer cargo postgres-protocol 0.6.12 write_nullable().};
12
13 #[cfg(test)]
14 mod testrust-analyzer cargo postgres-protocol 0.6.12 types/test/;
15
16 const RANGE_UPPER_UNBOUNDEDrust-analyzer cargo postgres-protocol 0.6.12 types/RANGE_UPPER_UNBOUNDED.: u8 = 0b0001_0000;
17 const RANGE_LOWER_UNBOUNDEDrust-analyzer cargo postgres-protocol 0.6.12 types/RANGE_LOWER_UNBOUNDED.: u8 = 0b0000_1000;
18 const RANGE_UPPER_INCLUSIVErust-analyzer cargo postgres-protocol 0.6.12 types/RANGE_UPPER_INCLUSIVE.: u8 = 0b0000_0100;
19 const RANGE_LOWER_INCLUSIVErust-analyzer cargo postgres-protocol 0.6.12 types/RANGE_LOWER_INCLUSIVE.: u8 = 0b0000_0010;
20 const RANGE_EMPTYrust-analyzer cargo postgres-protocol 0.6.12 types/RANGE_EMPTY.: u8 = 0b0000_0001;
21
22 const PGSQL_AF_INETrust-analyzer cargo postgres-protocol 0.6.12 types/PGSQL_AF_INET.: u8 = 2;
23 const PGSQL_AF_INET6rust-analyzer cargo postgres-protocol 0.6.12 types/PGSQL_AF_INET6.: u8 = 3;
24
25 /// Serializes a `BOOL` value.
26 #[inline]
27 pub fn bool_to_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/bool_to_sql().(v: bool, buf: &mut BytesMutrust-analyzer cargo bytes 1.11.1 bytes_mut/BytesMut#) {
28 buf.put_u8rust-analyzer cargo bytes 1.11.1 buf/buf_mut/BufMut#put_u8().(v as u8);
29 }
30
31 /// Deserializes a `BOOL` value.
32 #[inline]
33 pub fn bool_from_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/bool_from_sql().(buf: &[u8]) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<bool, StdBoxrust-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# + 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#>> {
34 if buf.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 cmp/impls/impl#[usize][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().1 {
35 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("invalid buffer size".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
36 }
37
38 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(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(). 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)
39 }
40
41 /// Serializes a `BYTEA` value.
42 #[inline]
43 pub fn bytea_to_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/bytea_to_sql().(v: &[u8], buf: &mut BytesMutrust-analyzer cargo bytes 1.11.1 bytes_mut/BytesMut#) {
44 buf.put_slicerust-analyzer cargo bytes 1.11.1 bytes_mut/impl#[BytesMut][BufMut]put_slice().(v);
45 }
46
47 /// Deserializes a `BYTEA value.
48 #[inline]
49 pub fn bytea_from_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/bytea_from_sql().(buf: &[u8]) -> &[u8] {
50 buf
51 }
52
53 /// Serializes a `TEXT`, `VARCHAR`, `CHAR(n)`, `NAME`, or `CITEXT` value.
54 #[inline]
55 pub fn text_to_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/text_to_sql().(v: &str, buf: &mut BytesMutrust-analyzer cargo bytes 1.11.1 bytes_mut/BytesMut#) {
56 buf.put_slicerust-analyzer cargo bytes 1.11.1 bytes_mut/impl#[BytesMut][BufMut]put_slice().(v.as_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_bytes().());
57 }
58
59 /// Deserializes a `TEXT`, `VARCHAR`, `CHAR(n)`, `NAME`, or `CITEXT` value.
60 #[inline]
61 pub fn text_from_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/text_from_sql().(buf: &[u8]) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<&str, StdBoxrust-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# + 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#>> {
62 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/::from_utf8rust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/converts/from_utf8().(buf)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().)
63 }
64
65 /// Serializes a `"char"` value.
66 #[inline]
67 pub fn char_to_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/char_to_sql().(v: i8, buf: &mut BytesMutrust-analyzer cargo bytes 1.11.1 bytes_mut/BytesMut#) {
68 buf.put_i8rust-analyzer cargo bytes 1.11.1 buf/buf_mut/BufMut#put_i8().(v);
69 }
70
71 /// Deserializes a `"char"` value.
72 #[inline]
73 pub fn char_from_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/char_from_sql().(mut buf: &[u8]) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<i8, StdBoxrust-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# + 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#>> {
74 let v = buf.read_i8rust-analyzer cargo byteorder 1.5.0 io/ReadBytesExt#read_i8().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
75 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().buf.is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]is_empty().() {
76 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("invalid buffer size".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
77 }
78 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(v)
79 }
80
81 /// Serializes an `INT2` value.
82 #[inline]
83 pub fn int2_to_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/int2_to_sql().(v: i16, buf: &mut BytesMutrust-analyzer cargo bytes 1.11.1 bytes_mut/BytesMut#) {
84 buf.put_i16rust-analyzer cargo bytes 1.11.1 buf/buf_mut/BufMut#put_i16().(v);
85 }
86
87 /// Deserializes an `INT2` value.
88 #[inline]
89 pub fn int2_from_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/int2_from_sql().(mut buf: &[u8]) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<i16, StdBoxrust-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# + 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#>> {
90 let v = buf.read_i16rust-analyzer cargo byteorder 1.5.0 io/ReadBytesExt#read_i16().::<BigEndianrust-analyzer cargo byteorder 1.5.0 BigEndian#>()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
91 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().buf.is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]is_empty().() {
92 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("invalid buffer size".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
93 }
94 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(v)
95 }
96
97 /// Serializes an `INT4` value.
98 #[inline]
99 pub fn int4_to_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/int4_to_sql().(v: i32, buf: &mut BytesMutrust-analyzer cargo bytes 1.11.1 bytes_mut/BytesMut#) {
100 buf.put_i32rust-analyzer cargo bytes 1.11.1 buf/buf_mut/BufMut#put_i32().(v);
101 }
102
103 /// Deserializes an `INT4` value.
104 #[inline]
105 pub fn int4_from_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/int4_from_sql().(mut buf: &[u8]) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<i32, StdBoxrust-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# + 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#>> {
106 let v = buf.read_i32rust-analyzer cargo byteorder 1.5.0 io/ReadBytesExt#read_i32().::<BigEndianrust-analyzer cargo byteorder 1.5.0 BigEndian#>()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
107 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().buf.is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]is_empty().() {
108 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("invalid buffer size".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
109 }
110 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(v)
111 }
112
113 /// Serializes an `OID` value.
114 #[inline]
115 pub fn oid_to_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/oid_to_sql().(v: Oidrust-analyzer cargo postgres-protocol 0.6.12 Oid#, buf: &mut BytesMutrust-analyzer cargo bytes 1.11.1 bytes_mut/BytesMut#) {
116 buf.put_u32rust-analyzer cargo bytes 1.11.1 buf/buf_mut/BufMut#put_u32().(v);
117 }
118
119 /// Deserializes an `OID` value.
120 #[inline]
121 pub fn oid_from_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/oid_from_sql().(mut buf: &[u8]) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Oidrust-analyzer cargo postgres-protocol 0.6.12 Oid#, StdBoxrust-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# + 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#>> {
122 let v = buf.read_u32rust-analyzer cargo byteorder 1.5.0 io/ReadBytesExt#read_u32().::<BigEndianrust-analyzer cargo byteorder 1.5.0 BigEndian#>()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
123 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().buf.is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]is_empty().() {
124 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("invalid buffer size".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
125 }
126 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(v)
127 }
128
129 /// Serializes an `INT8` value.
130 #[inline]
131 pub fn int8_to_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/int8_to_sql().(v: i64, buf: &mut BytesMutrust-analyzer cargo bytes 1.11.1 bytes_mut/BytesMut#) {
132 buf.put_i64rust-analyzer cargo bytes 1.11.1 buf/buf_mut/BufMut#put_i64().(v);
133 }
134
135 /// Deserializes an `INT8` value.
136 #[inline]
137 pub fn int8_from_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/int8_from_sql().(mut buf: &[u8]) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<i64, StdBoxrust-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# + 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#>> {
138 let v = buf.read_i64rust-analyzer cargo byteorder 1.5.0 io/ReadBytesExt#read_i64().::<BigEndianrust-analyzer cargo byteorder 1.5.0 BigEndian#>()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
139 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().buf.is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]is_empty().() {
140 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("invalid buffer size".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
141 }
142 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(v)
143 }
144
145 /// Serializes a `PG_LSN` value.
146 #[inline]
147 pub fn lsn_to_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/lsn_to_sql().(v: Lsnrust-analyzer cargo postgres-protocol 0.6.12 Lsn#, buf: &mut BytesMutrust-analyzer cargo bytes 1.11.1 bytes_mut/BytesMut#) {
148 buf.put_u64rust-analyzer cargo bytes 1.11.1 buf/buf_mut/BufMut#put_u64().(v);
149 }
150
151 /// Deserializes a `PG_LSN` value.
152 #[inline]
153 pub fn lsn_from_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/lsn_from_sql().(mut buf: &[u8]) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Lsnrust-analyzer cargo postgres-protocol 0.6.12 Lsn#, StdBoxrust-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# + 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#>> {
154 let v = buf.read_u64rust-analyzer cargo byteorder 1.5.0 io/ReadBytesExt#read_u64().::<BigEndianrust-analyzer cargo byteorder 1.5.0 BigEndian#>()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
155 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().buf.is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]is_empty().() {
156 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("invalid buffer size".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
157 }
158 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(v)
159 }
160
161 /// Serializes a `FLOAT4` value.
162 #[inline]
163 pub fn float4_to_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/float4_to_sql().(v: f32, buf: &mut BytesMutrust-analyzer cargo bytes 1.11.1 bytes_mut/BytesMut#) {
164 buf.put_f32rust-analyzer cargo bytes 1.11.1 buf/buf_mut/BufMut#put_f32().(v);
165 }
166
167 /// Deserializes a `FLOAT4` value.
168 #[inline]
169 pub fn float4_from_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/float4_from_sql().(mut buf: &[u8]) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<f32, StdBoxrust-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# + 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#>> {
170 let v = buf.read_f32rust-analyzer cargo byteorder 1.5.0 io/ReadBytesExt#read_f32().::<BigEndianrust-analyzer cargo byteorder 1.5.0 BigEndian#>()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
171 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().buf.is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]is_empty().() {
172 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("invalid buffer size".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
173 }
174 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(v)
175 }
176
177 /// Serializes a `FLOAT8` value.
178 #[inline]
179 pub fn float8_to_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/float8_to_sql().(v: f64, buf: &mut BytesMutrust-analyzer cargo bytes 1.11.1 bytes_mut/BytesMut#) {
180 buf.put_f64rust-analyzer cargo bytes 1.11.1 buf/buf_mut/BufMut#put_f64().(v);
181 }
182
183 /// Deserializes a `FLOAT8` value.
184 #[inline]
185 pub fn float8_from_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/float8_from_sql().(mut buf: &[u8]) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<f64, StdBoxrust-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# + 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#>> {
186 let v = buf.read_f64rust-analyzer cargo byteorder 1.5.0 io/ReadBytesExt#read_f64().::<BigEndianrust-analyzer cargo byteorder 1.5.0 BigEndian#>()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
187 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().buf.is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]is_empty().() {
188 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("invalid buffer size".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
189 }
190 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(v)
191 }
192
193 /// Serializes an `HSTORE` value.
194 #[inline]
195 pub fn hstore_to_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/hstore_to_sql().<'a, I>(
196 values: I,
197 buf: &mut BytesMutrust-analyzer cargo bytes 1.11.1 bytes_mut/BytesMut#,
198 ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), StdBoxrust-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# + 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#>>
199 where
200 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, Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&'a str>)>,
201 {
202 let base = buf.lenrust-analyzer cargo bytes 1.11.1 bytes_mut/impl#[BytesMut]len().();
203 buf.put_i32rust-analyzer cargo bytes 1.11.1 buf/buf_mut/BufMut#put_i32().(0);
204
205 let mut count = 0;
206 for (key, value) in values {
207 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;
208
209 write_pascal_stringrust-analyzer cargo postgres-protocol 0.6.12 types/write_pascal_string().(key, buf)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
210
211 match value {
212 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(value) => {
213 write_pascal_stringrust-analyzer cargo postgres-protocol 0.6.12 types/write_pascal_string().(value, buf)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
214 }
215 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => buf.put_i32rust-analyzer cargo bytes 1.11.1 buf/buf_mut/BufMut#put_i32().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][Neg]neg().1),
216 }
217 }
218
219 let count = i32::from_usizerust-analyzer cargo postgres-protocol 0.6.12 impl#[i32][FromUsize]from_usize().(count)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
220 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()., count);
221
222 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
223 }
224
225 fn write_pascal_stringrust-analyzer cargo postgres-protocol 0.6.12 types/write_pascal_string().(s: &str, 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#<(), StdBoxrust-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# + 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#>> {
226 let size = i32::from_usizerust-analyzer cargo postgres-protocol 0.6.12 impl#[i32][FromUsize]from_usize().(s.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().())?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
227 buf.put_i32rust-analyzer cargo bytes 1.11.1 buf/buf_mut/BufMut#put_i32().(size);
228 buf.put_slicerust-analyzer cargo bytes 1.11.1 bytes_mut/impl#[BytesMut][BufMut]put_slice().(s.as_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_bytes().());
229 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
230 }
231
232 /// Deserializes an `HSTORE` value.
233 #[inline]
234 pub fn hstore_from_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/hstore_from_sql().(
235 mut buf: &[u8],
236 ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<HstoreEntriesrust-analyzer cargo postgres-protocol 0.6.12 types/HstoreEntries#<'_>, StdBoxrust-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# + 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#>> {
237 let count = buf.read_i32rust-analyzer cargo byteorder 1.5.0 io/ReadBytesExt#read_i32().::<BigEndianrust-analyzer cargo byteorder 1.5.0 BigEndian#>()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
238 if count rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]lt().0 {
239 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("invalid entry count".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
240 }
241
242 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(HstoreEntriesrust-analyzer cargo postgres-protocol 0.6.12 types/HstoreEntries# {
243 remainingrust-analyzer cargo postgres-protocol 0.6.12 types/HstoreEntries#remaining.: count,
244 bufrust-analyzer cargo postgres-protocol 0.6.12 types/HstoreEntries#buf.,
245 })
246 }
247
248 /// A fallible iterator over `HSTORE` entries.
249 pub struct HstoreEntriesrust-analyzer cargo postgres-protocol 0.6.12 types/HstoreEntries#<'a> {
250 remainingrust-analyzer cargo postgres-protocol 0.6.12 types/HstoreEntries#remaining.: i32,
251 bufrust-analyzer cargo postgres-protocol 0.6.12 types/HstoreEntries#buf.: &'a [u8],
252 }
253
254 impl<'a> FallibleIteratorrust-analyzer cargo fallible-iterator 0.3.0 FallibleIterator# for HstoreEntriesrust-analyzer cargo postgres-protocol 0.6.12 types/HstoreEntries#<'a> {
255 type Itemrust-analyzer cargo postgres-protocol 0.6.12 types/impl#[`HstoreEntries<'a>`][FallibleIterator]Item# = (&'a str, Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&'a str>);
256 type Errorrust-analyzer cargo postgres-protocol 0.6.12 types/impl#[`HstoreEntries<'a>`][FallibleIterator]Error# = StdBoxrust-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# + 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#>;
257
258 #[inline]
259 #[allow(clippy::type_complexity)]
260 fn nextrust-analyzer cargo postgres-protocol 0.6.12 types/impl#[`HstoreEntries<'a>`][FallibleIterator]next().(
261 &mut self,
262 ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<(&'a str, Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&'a str>)>, StdBoxrust-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# + 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#>> {
263 if self.remainingrust-analyzer cargo postgres-protocol 0.6.12 types/HstoreEntries#remaining. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]eq().0 {
264 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().self.bufrust-analyzer cargo postgres-protocol 0.6.12 types/HstoreEntries#buf..is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]is_empty().() {
265 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("invalid buffer size".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
266 }
267 return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
268 }
269
270 self.remainingrust-analyzer cargo postgres-protocol 0.6.12 types/HstoreEntries#remaining. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`SubAssign<Self>`]sub_assign().-=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`SubAssign<Self>`]sub_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`SubAssign<Self>`]sub_assign().1;
271
272 let key_len = self.bufrust-analyzer cargo postgres-protocol 0.6.12 types/HstoreEntries#buf..read_i32rust-analyzer cargo byteorder 1.5.0 io/ReadBytesExt#read_i32().::<BigEndianrust-analyzer cargo byteorder 1.5.0 BigEndian#>()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
273 if key_len rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]lt().0 {
274 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("invalid key length".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
275 }
276 let (key, buf) = self
277 .bufrust-analyzer cargo postgres-protocol 0.6.12 types/HstoreEntries#buf.
278 .split_at_checkedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]split_at_checked().(key_len as usize)
279 .ok_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]ok_or().("invalid key length")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
280 let key = strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/::from_utf8rust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/converts/from_utf8().(key)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
281 self.bufrust-analyzer cargo postgres-protocol 0.6.12 types/HstoreEntries#buf. = buf;
282
283 let value_len = self.bufrust-analyzer cargo postgres-protocol 0.6.12 types/HstoreEntries#buf..read_i32rust-analyzer cargo byteorder 1.5.0 io/ReadBytesExt#read_i32().::<BigEndianrust-analyzer cargo byteorder 1.5.0 BigEndian#>()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
284 let value = if value_len rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]lt().0 {
285 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#
286 } else {
287 let (value, buf) = self
288 .bufrust-analyzer cargo postgres-protocol 0.6.12 types/HstoreEntries#buf.
289 .split_at_checkedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]split_at_checked().(value_len as usize)
290 .ok_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]ok_or().("invalid value length")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
291 let value = strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/::from_utf8rust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/converts/from_utf8().(value)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
292 self.bufrust-analyzer cargo postgres-protocol 0.6.12 types/HstoreEntries#buf. = buf;
293 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(value)
294 };
295
296 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((key, value)))
297 }
298
299 #[inline]
300 fn size_hintrust-analyzer cargo postgres-protocol 0.6.12 types/impl#[`HstoreEntries<'a>`][FallibleIterator]size_hint().(&self) -> (usize, Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<usize>) {
301 let len = self.remainingrust-analyzer cargo postgres-protocol 0.6.12 types/HstoreEntries#remaining. as usize;
302 (len, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(len))
303 }
304 }
305
306 /// Serializes a `VARBIT` or `BIT` value.
307 #[inline]
308 pub fn varbit_to_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/varbit_to_sql().<I>(
309 len: usize,
310 v: I,
311 buf: &mut BytesMutrust-analyzer cargo bytes 1.11.1 bytes_mut/BytesMut#,
312 ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), StdBoxrust-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# + 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#>>
313 where
314 I: Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item# = u8>,
315 {
316 let len = i32::from_usizerust-analyzer cargo postgres-protocol 0.6.12 impl#[i32][FromUsize]from_usize().(len)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
317 buf.put_i32rust-analyzer cargo bytes 1.11.1 buf/buf_mut/BufMut#put_i32().(len);
318
319 for byte in v {
320 buf.put_u8rust-analyzer cargo bytes 1.11.1 buf/buf_mut/BufMut#put_u8().(byte);
321 }
322
323 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
324 }
325
326 /// Deserializes a `VARBIT` or `BIT` value.
327 #[inline]
328 pub fn varbit_from_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/varbit_from_sql().(mut buf: &[u8]) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Varbitrust-analyzer cargo postgres-protocol 0.6.12 types/Varbit#<'_>, StdBoxrust-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# + 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#>> {
329 let len = buf.read_i32rust-analyzer cargo byteorder 1.5.0 io/ReadBytesExt#read_i32().::<BigEndianrust-analyzer cargo byteorder 1.5.0 BigEndian#>()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
330 if len rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]lt().0 {
331 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("invalid varbit length: varbit < 0".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
332 }
333 let bytes = (len as usize).div_ceilrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[usize]div_ceil().(8);
334 if buf.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 cmp/impls/impl#[usize][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().bytes {
335 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("invalid message length: varbit mismatch".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
336 }
337
338 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Varbitrust-analyzer cargo postgres-protocol 0.6.12 types/Varbit# {
339 lenrust-analyzer cargo postgres-protocol 0.6.12 types/Varbit#len.: len as usize,
340 bytesrust-analyzer cargo postgres-protocol 0.6.12 types/Varbit#bytes.: buf,
341 })
342 }
343
344 /// A `VARBIT` value.
345 pub struct Varbitrust-analyzer cargo postgres-protocol 0.6.12 types/Varbit#<'a> {
346 lenrust-analyzer cargo postgres-protocol 0.6.12 types/Varbit#len.: usize,
347 bytesrust-analyzer cargo postgres-protocol 0.6.12 types/Varbit#bytes.: &'a [u8],
348 }
349
350 impl<'a> Varbitrust-analyzer cargo postgres-protocol 0.6.12 types/Varbit#<'a> {
351 /// Returns the number of bits.
352 #[inline]
353 pub fn lenrust-analyzer cargo postgres-protocol 0.6.12 types/impl#[`Varbit<'a>`]len().(&self) -> usize {
354 self.lenrust-analyzer cargo postgres-protocol 0.6.12 types/Varbit#len.
355 }
356
357 /// Determines if the value has no bits.
358 #[inline]
359 pub fn is_emptyrust-analyzer cargo postgres-protocol 0.6.12 types/impl#[`Varbit<'a>`]is_empty().(&self) -> bool {
360 self.lenrust-analyzer cargo postgres-protocol 0.6.12 types/Varbit#len. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().0
361 }
362
363 /// Returns the bits as a slice of bytes.
364 #[inline]
365 pub fn bytesrust-analyzer cargo postgres-protocol 0.6.12 types/impl#[`Varbit<'a>`]bytes().(&self) -> &'a [u8] {
366 self.bytesrust-analyzer cargo postgres-protocol 0.6.12 types/Varbit#bytes.
367 }
368 }
369
370 /// Serializes a `TIMESTAMP` or `TIMESTAMPTZ` value.
371 ///
372 /// The value should represent the number of microseconds since midnight, January 1st, 2000.
373 #[inline]
374 pub fn timestamp_to_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/timestamp_to_sql().(v: i64, buf: &mut BytesMutrust-analyzer cargo bytes 1.11.1 bytes_mut/BytesMut#) {
375 buf.put_i64rust-analyzer cargo bytes 1.11.1 buf/buf_mut/BufMut#put_i64().(v);
376 }
377
378 /// Deserializes a `TIMESTAMP` or `TIMESTAMPTZ` value.
379 ///
380 /// The value represents the number of microseconds since midnight, January 1st, 2000.
381 #[inline]
382 pub fn timestamp_from_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/timestamp_from_sql().(mut buf: &[u8]) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<i64, StdBoxrust-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# + 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#>> {
383 let v = buf.read_i64rust-analyzer cargo byteorder 1.5.0 io/ReadBytesExt#read_i64().::<BigEndianrust-analyzer cargo byteorder 1.5.0 BigEndian#>()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
384 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().buf.is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]is_empty().() {
385 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("invalid message length: timestamp not drained".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
386 }
387 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(v)
388 }
389
390 /// Serializes a `DATE` value.
391 ///
392 /// The value should represent the number of days since January 1st, 2000.
393 #[inline]
394 pub fn date_to_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/date_to_sql().(v: i32, buf: &mut BytesMutrust-analyzer cargo bytes 1.11.1 bytes_mut/BytesMut#) {
395 buf.put_i32rust-analyzer cargo bytes 1.11.1 buf/buf_mut/BufMut#put_i32().(v);
396 }
397
398 /// Deserializes a `DATE` value.
399 ///
400 /// The value represents the number of days since January 1st, 2000.
401 #[inline]
402 pub fn date_from_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/date_from_sql().(mut buf: &[u8]) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<i32, StdBoxrust-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# + 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#>> {
403 let v = buf.read_i32rust-analyzer cargo byteorder 1.5.0 io/ReadBytesExt#read_i32().::<BigEndianrust-analyzer cargo byteorder 1.5.0 BigEndian#>()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
404 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().buf.is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]is_empty().() {
405 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("invalid message length: date not drained".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
406 }
407 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(v)
408 }
409
410 /// Serializes a `TIME` or `TIMETZ` value.
411 ///
412 /// The value should represent the number of microseconds since midnight.
413 #[inline]
414 pub fn time_to_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/time_to_sql().(v: i64, buf: &mut BytesMutrust-analyzer cargo bytes 1.11.1 bytes_mut/BytesMut#) {
415 buf.put_i64rust-analyzer cargo bytes 1.11.1 buf/buf_mut/BufMut#put_i64().(v);
416 }
417
418 /// Deserializes a `TIME` or `TIMETZ` value.
419 ///
420 /// The value represents the number of microseconds since midnight.
421 #[inline]
422 pub fn time_from_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/time_from_sql().(mut buf: &[u8]) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<i64, StdBoxrust-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# + 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#>> {
423 let v = buf.read_i64rust-analyzer cargo byteorder 1.5.0 io/ReadBytesExt#read_i64().::<BigEndianrust-analyzer cargo byteorder 1.5.0 BigEndian#>()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
424 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().buf.is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]is_empty().() {
425 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("invalid message length: time not drained".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
426 }
427 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(v)
428 }
429
430 /// Serializes a `MACADDR` value.
431 #[inline]
432 pub fn macaddr_to_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/macaddr_to_sql().(v: [u8; 6], buf: &mut BytesMutrust-analyzer cargo bytes 1.11.1 bytes_mut/BytesMut#) {
433 buf.put_slicerust-analyzer cargo bytes 1.11.1 bytes_mut/impl#[BytesMut][BufMut]put_slice().(&v);
434 }
435
436 /// Deserializes a `MACADDR` value.
437 #[inline]
438 pub fn macaddr_from_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/macaddr_from_sql().(buf: &[u8]) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<[u8; 6], StdBoxrust-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# + 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#>> {
439 if buf.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 cmp/impls/impl#[usize][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().6 {
440 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("invalid message length: macaddr length mismatch".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
441 }
442 let mut out = [0; 6];
443 out.copy_from_slicerust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]copy_from_slice().(buf);
444 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(out)
445 }
446
447 /// Serializes a `UUID` value.
448 #[inline]
449 pub fn uuid_to_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/uuid_to_sql().(v: [u8; 16], buf: &mut BytesMutrust-analyzer cargo bytes 1.11.1 bytes_mut/BytesMut#) {
450 buf.put_slicerust-analyzer cargo bytes 1.11.1 bytes_mut/impl#[BytesMut][BufMut]put_slice().(&v);
451 }
452
453 /// Deserializes a `UUID` value.
454 #[inline]
455 pub fn uuid_from_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/uuid_from_sql().(buf: &[u8]) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<[u8; 16], StdBoxrust-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# + 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#>> {
456 if buf.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 cmp/impls/impl#[usize][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().16 {
457 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("invalid message length: uuid size mismatch".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
458 }
459 let mut out = [0; 16];
460 out.copy_from_slicerust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]copy_from_slice().(buf);
461 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(out)
462 }
463
464 /// Serializes an array value.
465 #[inline]
466 pub fn array_to_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/array_to_sql().<T, I, J, F>(
467 dimensions: I,
468 element_type: Oidrust-analyzer cargo postgres-protocol 0.6.12 Oid#,
469 elements: J,
470 mut serializer: F,
471 buf: &mut BytesMutrust-analyzer cargo bytes 1.11.1 bytes_mut/BytesMut#,
472 ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), StdBoxrust-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# + 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#>>
473 where
474 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# = ArrayDimensionrust-analyzer cargo postgres-protocol 0.6.12 types/ArrayDimension#>,
475 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>,
476 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#, StdBoxrust-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# + 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#>>,
477 {
478 let dimensions_idx = buf.lenrust-analyzer cargo bytes 1.11.1 bytes_mut/impl#[BytesMut]len().();
479 buf.put_i32rust-analyzer cargo bytes 1.11.1 buf/buf_mut/BufMut#put_i32().(0);
480 let flags_idx = buf.lenrust-analyzer cargo bytes 1.11.1 bytes_mut/impl#[BytesMut]len().();
481 buf.put_i32rust-analyzer cargo bytes 1.11.1 buf/buf_mut/BufMut#put_i32().(0);
482 buf.put_u32rust-analyzer cargo bytes 1.11.1 buf/buf_mut/BufMut#put_u32().(element_type);
483
484 let mut num_dimensions = 0;
485 for dimension in dimensions {
486 num_dimensions 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;
487 buf.put_i32rust-analyzer cargo bytes 1.11.1 buf/buf_mut/BufMut#put_i32().(dimension.lenrust-analyzer cargo postgres-protocol 0.6.12 types/ArrayDimension#len.);
488 buf.put_i32rust-analyzer cargo bytes 1.11.1 buf/buf_mut/BufMut#put_i32().(dimension.lower_boundrust-analyzer cargo postgres-protocol 0.6.12 types/ArrayDimension#lower_bound.);
489 }
490
491 let num_dimensions = i32::from_usizerust-analyzer cargo postgres-protocol 0.6.12 impl#[i32][FromUsize]from_usize().(num_dimensions)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
492 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().dimensions_idx..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()., num_dimensions);
493
494 let mut has_nulls = false;
495 for element in elements {
496 write_nullablerust-analyzer cargo postgres-protocol 0.6.12 write_nullable().(
497 |buf| {
498 let r = serializer(element, buf);
499 if let Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(IsNullrust-analyzer cargo postgres-protocol 0.6.12 IsNull#::Yesrust-analyzer cargo postgres-protocol 0.6.12 IsNull#Yes#) = r {
500 has_nulls = true;
501 }
502 r
503 },
504 buf,
505 )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
506 }
507
508 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().flags_idx..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()., has_nulls as i32);
509
510 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
511 }
512
513 /// Deserializes an array value.
514 #[inline]
515 pub fn array_from_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/array_from_sql().(mut buf: &[u8]) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Arrayrust-analyzer cargo postgres-protocol 0.6.12 types/Array#<'_>, StdBoxrust-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# + 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#>> {
516 let dimensions = buf.read_i32rust-analyzer cargo byteorder 1.5.0 io/ReadBytesExt#read_i32().::<BigEndianrust-analyzer cargo byteorder 1.5.0 BigEndian#>()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
517 if dimensions rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]lt().0 {
518 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("invalid dimension count".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
519 }
520 let has_nulls = buf.read_i32rust-analyzer cargo byteorder 1.5.0 io/ReadBytesExt#read_i32().::<BigEndianrust-analyzer cargo byteorder 1.5.0 BigEndian#>()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]ne().0;
521 let element_type = buf.read_u32rust-analyzer cargo byteorder 1.5.0 io/ReadBytesExt#read_u32().::<BigEndianrust-analyzer cargo byteorder 1.5.0 BigEndian#>()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
522
523 let mut r = buf;
524 let mut elements = 1i32;
525 for _ in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#dimensions {
526 let len = r.read_i32rust-analyzer cargo byteorder 1.5.0 io/ReadBytesExt#read_i32().::<BigEndianrust-analyzer cargo byteorder 1.5.0 BigEndian#>()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
527 if len rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]lt().0 {
528 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("invalid dimension size".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
529 }
530 let _lower_bound = r.read_i32rust-analyzer cargo byteorder 1.5.0 io/ReadBytesExt#read_i32().::<BigEndianrust-analyzer cargo byteorder 1.5.0 BigEndian#>()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
531 elements = match elements.checked_mulrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[i32]checked_mul().(len) {
532 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(elements) => elements,
533 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("too many array elements".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()),
534 };
535 }
536
537 if dimensions rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]eq().0 {
538 elements = 0;
539 }
540
541 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Arrayrust-analyzer cargo postgres-protocol 0.6.12 types/Array# {
542 dimensionsrust-analyzer cargo postgres-protocol 0.6.12 types/Array#dimensions.,
543 has_nullsrust-analyzer cargo postgres-protocol 0.6.12 types/Array#has_nulls.,
544 element_typerust-analyzer cargo postgres-protocol 0.6.12 types/Array#element_type.,
545 elementsrust-analyzer cargo postgres-protocol 0.6.12 types/Array#elements.,
546 bufrust-analyzer cargo postgres-protocol 0.6.12 types/Array#buf.,
547 })
548 }
549
550 /// A Postgres array.
551 pub struct Arrayrust-analyzer cargo postgres-protocol 0.6.12 types/Array#<'a> {
552 dimensionsrust-analyzer cargo postgres-protocol 0.6.12 types/Array#dimensions.: i32,
553 has_nullsrust-analyzer cargo postgres-protocol 0.6.12 types/Array#has_nulls.: bool,
554 element_typerust-analyzer cargo postgres-protocol 0.6.12 types/Array#element_type.: Oidrust-analyzer cargo postgres-protocol 0.6.12 Oid#,
555 elementsrust-analyzer cargo postgres-protocol 0.6.12 types/Array#elements.: i32,
556 bufrust-analyzer cargo postgres-protocol 0.6.12 types/Array#buf.: &'a [u8],
557 }
558
559 impl<'a> Arrayrust-analyzer cargo postgres-protocol 0.6.12 types/Array#<'a> {
560 /// Returns true if there are `NULL` elements.
561 #[inline]
562 pub fn has_nullsrust-analyzer cargo postgres-protocol 0.6.12 types/impl#[`Array<'a>`]has_nulls().(&self) -> bool {
563 self.has_nullsrust-analyzer cargo postgres-protocol 0.6.12 types/Array#has_nulls.
564 }
565
566 /// Returns the OID of the elements of the array.
567 #[inline]
568 pub fn element_typerust-analyzer cargo postgres-protocol 0.6.12 types/impl#[`Array<'a>`]element_type().(&self) -> Oidrust-analyzer cargo postgres-protocol 0.6.12 Oid# {
569 self.element_typerust-analyzer cargo postgres-protocol 0.6.12 types/Array#element_type.
570 }
571
572 /// Returns an iterator over the dimensions of the array.
573 #[inline]
574 pub fn dimensionsrust-analyzer cargo postgres-protocol 0.6.12 types/impl#[`Array<'a>`]dimensions().(&self) -> ArrayDimensionsrust-analyzer cargo postgres-protocol 0.6.12 types/ArrayDimensions#<'a> {
575 ArrayDimensionsrust-analyzer cargo postgres-protocol 0.6.12 types/ArrayDimensions#(&self.bufrust-analyzer cargo postgres-protocol 0.6.12 types/Array#buf.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeTo#self.dimensionsrust-analyzer cargo postgres-protocol 0.6.12 types/Array#dimensions. as usize rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().8]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().)
576 }
577
578 /// Returns an iterator over the values of the array.
579 #[inline]
580 pub fn valuesrust-analyzer cargo postgres-protocol 0.6.12 types/impl#[`Array<'a>`]values().(&self) -> ArrayValuesrust-analyzer cargo postgres-protocol 0.6.12 types/ArrayValues#<'a> {
581 ArrayValuesrust-analyzer cargo postgres-protocol 0.6.12 types/ArrayValues# {
582 remainingrust-analyzer cargo postgres-protocol 0.6.12 types/ArrayValues#remaining.: self.elementsrust-analyzer cargo postgres-protocol 0.6.12 types/Array#elements.,
583 bufrust-analyzer cargo postgres-protocol 0.6.12 types/ArrayValues#buf.: &self.bufrust-analyzer cargo postgres-protocol 0.6.12 types/Array#buf.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().self.dimensionsrust-analyzer cargo postgres-protocol 0.6.12 types/Array#dimensions. as usize rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().8..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/Index#index().,
584 }
585 }
586 }
587
588 /// An iterator over the dimensions of an array.
589 pub struct ArrayDimensionsrust-analyzer cargo postgres-protocol 0.6.12 types/ArrayDimensions#<'a>(&'a [u8]);
590
591 impl FallibleIteratorrust-analyzer cargo fallible-iterator 0.3.0 FallibleIterator# for ArrayDimensionsrust-analyzer cargo postgres-protocol 0.6.12 types/ArrayDimensions#<'_> {
592 type Itemrust-analyzer cargo postgres-protocol 0.6.12 types/impl#[`ArrayDimensions<'_>`][FallibleIterator]Item# = ArrayDimensionrust-analyzer cargo postgres-protocol 0.6.12 types/ArrayDimension#;
593 type Errorrust-analyzer cargo postgres-protocol 0.6.12 types/impl#[`ArrayDimensions<'_>`][FallibleIterator]Error# = StdBoxrust-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# + 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#>;
594
595 #[inline]
596 fn nextrust-analyzer cargo postgres-protocol 0.6.12 types/impl#[`ArrayDimensions<'_>`][FallibleIterator]next().(&mut self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<ArrayDimensionrust-analyzer cargo postgres-protocol 0.6.12 types/ArrayDimension#>, StdBoxrust-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# + 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#>> {
597 if self.0rust-analyzer cargo postgres-protocol 0.6.12 types/ArrayDimensions#0..is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]is_empty().() {
598 return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
599 }
600
601 let len = self.0rust-analyzer cargo postgres-protocol 0.6.12 types/ArrayDimensions#0..read_i32rust-analyzer cargo byteorder 1.5.0 io/ReadBytesExt#read_i32().::<BigEndianrust-analyzer cargo byteorder 1.5.0 BigEndian#>()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
602 let lower_bound = self.0rust-analyzer cargo postgres-protocol 0.6.12 types/ArrayDimensions#0..read_i32rust-analyzer cargo byteorder 1.5.0 io/ReadBytesExt#read_i32().::<BigEndianrust-analyzer cargo byteorder 1.5.0 BigEndian#>()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
603
604 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ArrayDimensionrust-analyzer cargo postgres-protocol 0.6.12 types/ArrayDimension# { lenrust-analyzer cargo postgres-protocol 0.6.12 types/ArrayDimension#len., lower_boundrust-analyzer cargo postgres-protocol 0.6.12 types/ArrayDimension#lower_bound. }))
605 }
606
607 #[inline]
608 fn size_hintrust-analyzer cargo postgres-protocol 0.6.12 types/impl#[`ArrayDimensions<'_>`][FallibleIterator]size_hint().(&self) -> (usize, Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<usize>) {
609 let len = self.0rust-analyzer cargo postgres-protocol 0.6.12 types/ArrayDimensions#0..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 ops/arith/impl#[usize][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div().8;
610 (len, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(len))
611 }
612 }
613
614 /// Information about a dimension of an array.
615 #[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:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:)]
616 pub struct ArrayDimensionrust-analyzer cargo postgres-protocol 0.6.12 types/ArrayDimension# {
617 /// The length of this dimension.
618 pub lenrust-analyzer cargo postgres-protocol 0.6.12 types/ArrayDimension#len.: i32,
619
620 /// The base value used to index into this dimension.
621 pub lower_boundrust-analyzer cargo postgres-protocol 0.6.12 types/ArrayDimension#lower_bound.: i32,
622 }
623
624 /// An iterator over the values of an array, in row-major order.
625 pub struct ArrayValuesrust-analyzer cargo postgres-protocol 0.6.12 types/ArrayValues#<'a> {
626 remainingrust-analyzer cargo postgres-protocol 0.6.12 types/ArrayValues#remaining.: i32,
627 bufrust-analyzer cargo postgres-protocol 0.6.12 types/ArrayValues#buf.: &'a [u8],
628 }
629
630 impl<'a> FallibleIteratorrust-analyzer cargo fallible-iterator 0.3.0 FallibleIterator# for ArrayValuesrust-analyzer cargo postgres-protocol 0.6.12 types/ArrayValues#<'a> {
631 type Itemrust-analyzer cargo postgres-protocol 0.6.12 types/impl#[`ArrayValues<'a>`][FallibleIterator]Item# = Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&'a [u8]>;
632 type Errorrust-analyzer cargo postgres-protocol 0.6.12 types/impl#[`ArrayValues<'a>`][FallibleIterator]Error# = StdBoxrust-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# + 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#>;
633
634 #[inline]
635 fn nextrust-analyzer cargo postgres-protocol 0.6.12 types/impl#[`ArrayValues<'a>`][FallibleIterator]next().(&mut self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&'a [u8]>>, StdBoxrust-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# + 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#>> {
636 if self.remainingrust-analyzer cargo postgres-protocol 0.6.12 types/ArrayValues#remaining. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]eq().0 {
637 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().self.bufrust-analyzer cargo postgres-protocol 0.6.12 types/ArrayValues#buf..is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]is_empty().() {
638 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("invalid message length: arrayvalue not drained".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
639 }
640 return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
641 }
642 self.remainingrust-analyzer cargo postgres-protocol 0.6.12 types/ArrayValues#remaining. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`SubAssign<Self>`]sub_assign().-=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`SubAssign<Self>`]sub_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`SubAssign<Self>`]sub_assign().1;
643
644 let len = self.bufrust-analyzer cargo postgres-protocol 0.6.12 types/ArrayValues#buf..read_i32rust-analyzer cargo byteorder 1.5.0 io/ReadBytesExt#read_i32().::<BigEndianrust-analyzer cargo byteorder 1.5.0 BigEndian#>()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
645 let val = if len rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]lt().0 {
646 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#
647 } else {
648 let (val, buf) = self
649 .bufrust-analyzer cargo postgres-protocol 0.6.12 types/ArrayValues#buf.
650 .split_at_checkedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]split_at_checked().(len as usize)
651 .ok_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]ok_or().("invalid value length")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
652 self.bufrust-analyzer cargo postgres-protocol 0.6.12 types/ArrayValues#buf. = buf;
653 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(val)
654 };
655
656 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(val))
657 }
658
659 fn size_hintrust-analyzer cargo postgres-protocol 0.6.12 types/impl#[`ArrayValues<'a>`][FallibleIterator]size_hint().(&self) -> (usize, Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<usize>) {
660 let len = self.remainingrust-analyzer cargo postgres-protocol 0.6.12 types/ArrayValues#remaining. as usize;
661 (len, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(len))
662 }
663 }
664
665 /// Serializes an empty range.
666 #[inline]
667 pub fn empty_range_to_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/empty_range_to_sql().(buf: &mut BytesMutrust-analyzer cargo bytes 1.11.1 bytes_mut/BytesMut#) {
668 buf.put_u8rust-analyzer cargo bytes 1.11.1 buf/buf_mut/BufMut#put_u8().(RANGE_EMPTYrust-analyzer cargo postgres-protocol 0.6.12 types/RANGE_EMPTY.);
669 }
670
671 /// Serializes a range value.
672 pub fn range_to_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/range_to_sql().<F, G>(
673 lower: F,
674 upper: G,
675 buf: &mut BytesMutrust-analyzer cargo bytes 1.11.1 bytes_mut/BytesMut#,
676 ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), StdBoxrust-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# + 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#>>
677 where
678 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#<RangeBoundrust-analyzer cargo postgres-protocol 0.6.12 types/RangeBound#<IsNullrust-analyzer cargo postgres-protocol 0.6.12 IsNull#>, StdBoxrust-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# + 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#>>,
679 G: 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#<RangeBoundrust-analyzer cargo postgres-protocol 0.6.12 types/RangeBound#<IsNullrust-analyzer cargo postgres-protocol 0.6.12 IsNull#>, StdBoxrust-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# + 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#>>,
680 {
681 let tag_idx = buf.lenrust-analyzer cargo bytes 1.11.1 bytes_mut/impl#[BytesMut]len().();
682 buf.put_u8rust-analyzer cargo bytes 1.11.1 buf/buf_mut/BufMut#put_u8().(0);
683 let mut tag = 0;
684
685 match write_boundrust-analyzer cargo postgres-protocol 0.6.12 types/write_bound().(lower, buf)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). {
686 RangeBoundrust-analyzer cargo postgres-protocol 0.6.12 types/RangeBound#::Inclusiverust-analyzer cargo postgres-protocol 0.6.12 types/RangeBound#Inclusive#(()) => tag rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitOrAssign<Self>`]bitor_assign().|=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitOrAssign<Self>`]bitor_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitOrAssign<Self>`]bitor_assign().RANGE_LOWER_INCLUSIVErust-analyzer cargo postgres-protocol 0.6.12 types/RANGE_LOWER_INCLUSIVE.,
687 RangeBoundrust-analyzer cargo postgres-protocol 0.6.12 types/RangeBound#::Exclusiverust-analyzer cargo postgres-protocol 0.6.12 types/RangeBound#Exclusive#(()) => {}
688 RangeBoundrust-analyzer cargo postgres-protocol 0.6.12 types/RangeBound#::Unboundedrust-analyzer cargo postgres-protocol 0.6.12 types/RangeBound#Unbounded# => tag rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitOrAssign<Self>`]bitor_assign().|=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitOrAssign<Self>`]bitor_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitOrAssign<Self>`]bitor_assign().RANGE_LOWER_UNBOUNDEDrust-analyzer cargo postgres-protocol 0.6.12 types/RANGE_LOWER_UNBOUNDED.,
689 }
690
691 match write_boundrust-analyzer cargo postgres-protocol 0.6.12 types/write_bound().(upper, buf)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). {
692 RangeBoundrust-analyzer cargo postgres-protocol 0.6.12 types/RangeBound#::Inclusiverust-analyzer cargo postgres-protocol 0.6.12 types/RangeBound#Inclusive#(()) => tag rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitOrAssign<Self>`]bitor_assign().|=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitOrAssign<Self>`]bitor_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitOrAssign<Self>`]bitor_assign().RANGE_UPPER_INCLUSIVErust-analyzer cargo postgres-protocol 0.6.12 types/RANGE_UPPER_INCLUSIVE.,
693 RangeBoundrust-analyzer cargo postgres-protocol 0.6.12 types/RangeBound#::Exclusiverust-analyzer cargo postgres-protocol 0.6.12 types/RangeBound#Exclusive#(()) => {}
694 RangeBoundrust-analyzer cargo postgres-protocol 0.6.12 types/RangeBound#::Unboundedrust-analyzer cargo postgres-protocol 0.6.12 types/RangeBound#Unbounded# => tag rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitOrAssign<Self>`]bitor_assign().|=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitOrAssign<Self>`]bitor_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitOrAssign<Self>`]bitor_assign().RANGE_UPPER_UNBOUNDEDrust-analyzer cargo postgres-protocol 0.6.12 types/RANGE_UPPER_UNBOUNDED.,
695 }
696
697 buf[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().tag_idx]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut(). = tag;
698
699 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
700 }
701
702 fn write_boundrust-analyzer cargo postgres-protocol 0.6.12 types/write_bound().<F>(
703 bound: F,
704 buf: &mut BytesMutrust-analyzer cargo bytes 1.11.1 bytes_mut/BytesMut#,
705 ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<RangeBoundrust-analyzer cargo postgres-protocol 0.6.12 types/RangeBound#<()>, StdBoxrust-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# + 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#>>
706 where
707 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#<RangeBoundrust-analyzer cargo postgres-protocol 0.6.12 types/RangeBound#<IsNullrust-analyzer cargo postgres-protocol 0.6.12 IsNull#>, StdBoxrust-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# + 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#>>,
708 {
709 let base = buf.lenrust-analyzer cargo bytes 1.11.1 bytes_mut/impl#[BytesMut]len().();
710 buf.put_i32rust-analyzer cargo bytes 1.11.1 buf/buf_mut/BufMut#put_i32().(0);
711
712 let (null, ret) = match bound(buf)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). {
713 RangeBoundrust-analyzer cargo postgres-protocol 0.6.12 types/RangeBound#::Inclusiverust-analyzer cargo postgres-protocol 0.6.12 types/RangeBound#Inclusive#(null) => (Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(null), RangeBoundrust-analyzer cargo postgres-protocol 0.6.12 types/RangeBound#::Inclusiverust-analyzer cargo postgres-protocol 0.6.12 types/RangeBound#Inclusive#(())),
714 RangeBoundrust-analyzer cargo postgres-protocol 0.6.12 types/RangeBound#::Exclusiverust-analyzer cargo postgres-protocol 0.6.12 types/RangeBound#Exclusive#(null) => (Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(null), RangeBoundrust-analyzer cargo postgres-protocol 0.6.12 types/RangeBound#::Exclusiverust-analyzer cargo postgres-protocol 0.6.12 types/RangeBound#Exclusive#(())),
715 RangeBoundrust-analyzer cargo postgres-protocol 0.6.12 types/RangeBound#::Unboundedrust-analyzer cargo postgres-protocol 0.6.12 types/RangeBound#Unbounded# => (Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, RangeBoundrust-analyzer cargo postgres-protocol 0.6.12 types/RangeBound#::Unboundedrust-analyzer cargo postgres-protocol 0.6.12 types/RangeBound#Unbounded#),
716 };
717
718 match null {
719 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(null) => {
720 let len = match null {
721 IsNullrust-analyzer cargo postgres-protocol 0.6.12 IsNull#::Norust-analyzer cargo postgres-protocol 0.6.12 IsNull#No# => 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 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().4)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().,
722 IsNullrust-analyzer cargo postgres-protocol 0.6.12 IsNull#::Yesrust-analyzer cargo postgres-protocol 0.6.12 IsNull#Yes# => -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][Neg]neg().1,
723 };
724 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()., len);
725 }
726 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => buf.truncaterust-analyzer cargo bytes 1.11.1 bytes_mut/impl#[BytesMut]truncate().(base),
727 }
728
729 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(ret)
730 }
731
732 /// One side of a range.
733 pub enum RangeBoundrust-analyzer cargo postgres-protocol 0.6.12 types/RangeBound#<T> {
734 /// An inclusive bound.
735 Inclusiverust-analyzer cargo postgres-protocol 0.6.12 types/RangeBound#Inclusive#(T),
736 /// An exclusive bound.
737 Exclusiverust-analyzer cargo postgres-protocol 0.6.12 types/RangeBound#Exclusive#(T),
738 /// No bound.
739 Unboundedrust-analyzer cargo postgres-protocol 0.6.12 types/RangeBound#Unbounded#,
740 }
741
742 /// Deserializes a range value.
743 #[inline]
744 pub fn range_from_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/range_from_sql().(mut buf: &[u8]) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Rangerust-analyzer cargo postgres-protocol 0.6.12 types/Range#<'_>, StdBoxrust-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# + 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#>> {
745 let tag = buf.read_u8rust-analyzer cargo byteorder 1.5.0 io/ReadBytesExt#read_u8().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
746
747 if tag rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().RANGE_EMPTYrust-analyzer cargo postgres-protocol 0.6.12 types/RANGE_EMPTY. {
748 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().buf.is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]is_empty().() {
749 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("invalid message size".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
750 }
751 return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Rangerust-analyzer cargo postgres-protocol 0.6.12 types/Range#::Emptyrust-analyzer cargo postgres-protocol 0.6.12 types/Range#Empty#);
752 }
753
754 let lower = read_boundrust-analyzer cargo postgres-protocol 0.6.12 types/read_bound().(&mut buf, tag, RANGE_LOWER_UNBOUNDEDrust-analyzer cargo postgres-protocol 0.6.12 types/RANGE_LOWER_UNBOUNDED., RANGE_LOWER_INCLUSIVErust-analyzer cargo postgres-protocol 0.6.12 types/RANGE_LOWER_INCLUSIVE.)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
755 let upper = read_boundrust-analyzer cargo postgres-protocol 0.6.12 types/read_bound().(&mut buf, tag, RANGE_UPPER_UNBOUNDEDrust-analyzer cargo postgres-protocol 0.6.12 types/RANGE_UPPER_UNBOUNDED., RANGE_UPPER_INCLUSIVErust-analyzer cargo postgres-protocol 0.6.12 types/RANGE_UPPER_INCLUSIVE.)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
756
757 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().buf.is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]is_empty().() {
758 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("invalid message size".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
759 }
760
761 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Rangerust-analyzer cargo postgres-protocol 0.6.12 types/Range#::Nonemptyrust-analyzer cargo postgres-protocol 0.6.12 types/Range#Nonempty#(lower, upper))
762 }
763
764 #[inline]
765 fn read_boundrust-analyzer cargo postgres-protocol 0.6.12 types/read_bound().<'a>(
766 buf: &mut &'a [u8],
767 tag: u8,
768 unbounded: u8,
769 inclusive: u8,
770 ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<RangeBoundrust-analyzer cargo postgres-protocol 0.6.12 types/RangeBound#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&'a [u8]>>, StdBoxrust-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# + 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#>> {
771 if tag rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitAnd<Self>`]bitand().&rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitAnd<Self>`]bitand(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitAnd<Self>`]bitand().unbounded 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 {
772 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(RangeBoundrust-analyzer cargo postgres-protocol 0.6.12 types/RangeBound#::Unboundedrust-analyzer cargo postgres-protocol 0.6.12 types/RangeBound#Unbounded#)
773 } else {
774 let len = buf.read_i32rust-analyzer cargo byteorder 1.5.0 io/ReadBytesExt#read_i32().::<BigEndianrust-analyzer cargo byteorder 1.5.0 BigEndian#>()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
775 let value = if len rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]lt().0 {
776 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#
777 } else {
778 let len = len as usize;
779 let (value, tail) = buf.split_at_checkedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]split_at_checked().(len).ok_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]ok_or().("invalid message size")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
780 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().buf = tail;
781 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(value)
782 };
783
784 if tag rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitAnd<Self>`]bitand().&rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitAnd<Self>`]bitand(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitAnd<Self>`]bitand().inclusive 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 {
785 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(RangeBoundrust-analyzer cargo postgres-protocol 0.6.12 types/RangeBound#::Inclusiverust-analyzer cargo postgres-protocol 0.6.12 types/RangeBound#Inclusive#(value))
786 } else {
787 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(RangeBoundrust-analyzer cargo postgres-protocol 0.6.12 types/RangeBound#::Exclusiverust-analyzer cargo postgres-protocol 0.6.12 types/RangeBound#Exclusive#(value))
788 }
789 }
790 }
791
792 /// A Postgres range.
793 pub enum Rangerust-analyzer cargo postgres-protocol 0.6.12 types/Range#<'a> {
794 /// An empty range.
795 Emptyrust-analyzer cargo postgres-protocol 0.6.12 types/Range#Empty#,
796 /// A nonempty range.
797 Nonemptyrust-analyzer cargo postgres-protocol 0.6.12 types/Range#Nonempty#(RangeBoundrust-analyzer cargo postgres-protocol 0.6.12 types/RangeBound#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&'a [u8]>>, RangeBoundrust-analyzer cargo postgres-protocol 0.6.12 types/RangeBound#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&'a [u8]>>),
798 }
799
800 /// Serializes a point value.
801 #[inline]
802 pub fn point_to_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/point_to_sql().(x: f64, y: f64, buf: &mut BytesMutrust-analyzer cargo bytes 1.11.1 bytes_mut/BytesMut#) {
803 buf.put_f64rust-analyzer cargo bytes 1.11.1 buf/buf_mut/BufMut#put_f64().(x);
804 buf.put_f64rust-analyzer cargo bytes 1.11.1 buf/buf_mut/BufMut#put_f64().(y);
805 }
806
807 /// Deserializes a point value.
808 #[inline]
809 pub fn point_from_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/point_from_sql().(mut buf: &[u8]) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Pointrust-analyzer cargo postgres-protocol 0.6.12 types/Point#, StdBoxrust-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# + 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#>> {
810 let x = buf.read_f64rust-analyzer cargo byteorder 1.5.0 io/ReadBytesExt#read_f64().::<BigEndianrust-analyzer cargo byteorder 1.5.0 BigEndian#>()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
811 let y = buf.read_f64rust-analyzer cargo byteorder 1.5.0 io/ReadBytesExt#read_f64().::<BigEndianrust-analyzer cargo byteorder 1.5.0 BigEndian#>()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
812 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().buf.is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]is_empty().() {
813 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("invalid buffer size".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
814 }
815 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Pointrust-analyzer cargo postgres-protocol 0.6.12 types/Point# { xrust-analyzer cargo postgres-protocol 0.6.12 types/Point#x., yrust-analyzer cargo postgres-protocol 0.6.12 types/Point#y. })
816 }
817
818 /// A Postgres point.
819 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)]
820 pub struct Pointrust-analyzer cargo postgres-protocol 0.6.12 types/Point# {
821 xrust-analyzer cargo postgres-protocol 0.6.12 types/Point#x.: f64,
822 yrust-analyzer cargo postgres-protocol 0.6.12 types/Point#y.: f64,
823 }
824
825 impl Pointrust-analyzer cargo postgres-protocol 0.6.12 types/Point# {
826 /// Returns the x coordinate of the point.
827 #[inline]
828 pub fn xrust-analyzer cargo postgres-protocol 0.6.12 types/impl#[Point]x().(&self) -> f64 {
829 self.xrust-analyzer cargo postgres-protocol 0.6.12 types/Point#x.
830 }
831
832 /// Returns the y coordinate of the point.
833 #[inline]
834 pub fn yrust-analyzer cargo postgres-protocol 0.6.12 types/impl#[Point]y().(&self) -> f64 {
835 self.yrust-analyzer cargo postgres-protocol 0.6.12 types/Point#y.
836 }
837 }
838
839 /// Serializes a box value.
840 #[inline]
841 pub fn box_to_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/box_to_sql().(x1: f64, y1: f64, x2: f64, y2: f64, buf: &mut BytesMutrust-analyzer cargo bytes 1.11.1 bytes_mut/BytesMut#) {
842 buf.put_f64rust-analyzer cargo bytes 1.11.1 buf/buf_mut/BufMut#put_f64().(x1);
843 buf.put_f64rust-analyzer cargo bytes 1.11.1 buf/buf_mut/BufMut#put_f64().(y1);
844 buf.put_f64rust-analyzer cargo bytes 1.11.1 buf/buf_mut/BufMut#put_f64().(x2);
845 buf.put_f64rust-analyzer cargo bytes 1.11.1 buf/buf_mut/BufMut#put_f64().(y2);
846 }
847
848 /// Deserializes a box value.
849 #[inline]
850 pub fn box_from_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/box_from_sql().(mut buf: &[u8]) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Boxrust-analyzer cargo postgres-protocol 0.6.12 types/Box#, StdBoxrust-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# + 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#>> {
851 let x1 = buf.read_f64rust-analyzer cargo byteorder 1.5.0 io/ReadBytesExt#read_f64().::<BigEndianrust-analyzer cargo byteorder 1.5.0 BigEndian#>()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
852 let y1 = buf.read_f64rust-analyzer cargo byteorder 1.5.0 io/ReadBytesExt#read_f64().::<BigEndianrust-analyzer cargo byteorder 1.5.0 BigEndian#>()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
853 let x2 = buf.read_f64rust-analyzer cargo byteorder 1.5.0 io/ReadBytesExt#read_f64().::<BigEndianrust-analyzer cargo byteorder 1.5.0 BigEndian#>()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
854 let y2 = buf.read_f64rust-analyzer cargo byteorder 1.5.0 io/ReadBytesExt#read_f64().::<BigEndianrust-analyzer cargo byteorder 1.5.0 BigEndian#>()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
855 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().buf.is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]is_empty().() {
856 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("invalid buffer size".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
857 }
858 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Boxrust-analyzer cargo postgres-protocol 0.6.12 types/Box# {
859 upper_rightrust-analyzer cargo postgres-protocol 0.6.12 types/Box#upper_right.: Pointrust-analyzer cargo postgres-protocol 0.6.12 types/Point# { xrust-analyzer cargo postgres-protocol 0.6.12 types/Point#x.: x1, yrust-analyzer cargo postgres-protocol 0.6.12 types/Point#y.: y1 },
860 lower_leftrust-analyzer cargo postgres-protocol 0.6.12 types/Box#lower_left.: Pointrust-analyzer cargo postgres-protocol 0.6.12 types/Point# { xrust-analyzer cargo postgres-protocol 0.6.12 types/Point#x.: x2, yrust-analyzer cargo postgres-protocol 0.6.12 types/Point#y.: y2 },
861 })
862 }
863
864 /// A Postgres box.
865 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)]
866 pub struct Boxrust-analyzer cargo postgres-protocol 0.6.12 types/Box# {
867 upper_rightrust-analyzer cargo postgres-protocol 0.6.12 types/Box#upper_right.: Pointrust-analyzer cargo postgres-protocol 0.6.12 types/Point#,
868 lower_leftrust-analyzer cargo postgres-protocol 0.6.12 types/Box#lower_left.: Pointrust-analyzer cargo postgres-protocol 0.6.12 types/Point#,
869 }
870
871 impl Boxrust-analyzer cargo postgres-protocol 0.6.12 types/Box# {
872 /// Returns the upper right corner of the box.
873 #[inline]
874 pub fn upper_rightrust-analyzer cargo postgres-protocol 0.6.12 types/impl#[Box]upper_right().(&self) -> Pointrust-analyzer cargo postgres-protocol 0.6.12 types/Point# {
875 self.upper_rightrust-analyzer cargo postgres-protocol 0.6.12 types/Box#upper_right.
876 }
877
878 /// Returns the lower left corner of the box.
879 #[inline]
880 pub fn lower_leftrust-analyzer cargo postgres-protocol 0.6.12 types/impl#[Box]lower_left().(&self) -> Pointrust-analyzer cargo postgres-protocol 0.6.12 types/Point# {
881 self.lower_leftrust-analyzer cargo postgres-protocol 0.6.12 types/Box#lower_left.
882 }
883 }
884
885 /// Serializes a Postgres path.
886 #[inline]
887 pub fn path_to_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/path_to_sql().<I>(
888 closed: bool,
889 points: I,
890 buf: &mut BytesMutrust-analyzer cargo bytes 1.11.1 bytes_mut/BytesMut#,
891 ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), StdBoxrust-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# + 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#>>
892 where
893 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# = (f64, f64)>,
894 {
895 buf.put_u8rust-analyzer cargo bytes 1.11.1 buf/buf_mut/BufMut#put_u8().(closed as u8);
896 let points_idx = buf.lenrust-analyzer cargo bytes 1.11.1 bytes_mut/impl#[BytesMut]len().();
897 buf.put_i32rust-analyzer cargo bytes 1.11.1 buf/buf_mut/BufMut#put_i32().(0);
898
899 let mut num_points = 0;
900 for (x, y) in points {
901 num_points 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;
902 buf.put_f64rust-analyzer cargo bytes 1.11.1 buf/buf_mut/BufMut#put_f64().(x);
903 buf.put_f64rust-analyzer cargo bytes 1.11.1 buf/buf_mut/BufMut#put_f64().(y);
904 }
905
906 let num_points = i32::from_usizerust-analyzer cargo postgres-protocol 0.6.12 impl#[i32][FromUsize]from_usize().(num_points)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
907 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().points_idx..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()., num_points);
908
909 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
910 }
911
912 /// Deserializes a Postgres path.
913 #[inline]
914 pub fn path_from_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/path_from_sql().(mut buf: &[u8]) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Pathrust-analyzer cargo postgres-protocol 0.6.12 types/Path#<'_>, StdBoxrust-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# + 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#>> {
915 let closed = buf.read_u8rust-analyzer cargo byteorder 1.5.0 io/ReadBytesExt#read_u8().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). 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;
916 let points = buf.read_i32rust-analyzer cargo byteorder 1.5.0 io/ReadBytesExt#read_i32().::<BigEndianrust-analyzer cargo byteorder 1.5.0 BigEndian#>()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
917
918 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Pathrust-analyzer cargo postgres-protocol 0.6.12 types/Path# {
919 closedrust-analyzer cargo postgres-protocol 0.6.12 types/Path#closed.,
920 pointsrust-analyzer cargo postgres-protocol 0.6.12 types/Path#points.,
921 bufrust-analyzer cargo postgres-protocol 0.6.12 types/Path#buf.,
922 })
923 }
924
925 /// A Postgres point.
926 pub struct Pathrust-analyzer cargo postgres-protocol 0.6.12 types/Path#<'a> {
927 closedrust-analyzer cargo postgres-protocol 0.6.12 types/Path#closed.: bool,
928 pointsrust-analyzer cargo postgres-protocol 0.6.12 types/Path#points.: i32,
929 bufrust-analyzer cargo postgres-protocol 0.6.12 types/Path#buf.: &'a [u8],
930 }
931
932 impl<'a> Pathrust-analyzer cargo postgres-protocol 0.6.12 types/Path#<'a> {
933 /// Determines if the path is closed or open.
934 #[inline]
935 pub fn closedrust-analyzer cargo postgres-protocol 0.6.12 types/impl#[`Path<'a>`]closed().(&self) -> bool {
936 self.closedrust-analyzer cargo postgres-protocol 0.6.12 types/Path#closed.
937 }
938
939 /// Returns an iterator over the points in the path.
940 #[inline]
941 pub fn pointsrust-analyzer cargo postgres-protocol 0.6.12 types/impl#[`Path<'a>`]points().(&self) -> PathPointsrust-analyzer cargo postgres-protocol 0.6.12 types/PathPoints#<'a> {
942 PathPointsrust-analyzer cargo postgres-protocol 0.6.12 types/PathPoints# {
943 remainingrust-analyzer cargo postgres-protocol 0.6.12 types/PathPoints#remaining.: self.pointsrust-analyzer cargo postgres-protocol 0.6.12 types/Path#points.,
944 bufrust-analyzer cargo postgres-protocol 0.6.12 types/PathPoints#buf.: self.bufrust-analyzer cargo postgres-protocol 0.6.12 types/Path#buf.,
945 }
946 }
947 }
948
949 /// An iterator over the points of a Postgres path.
950 pub struct PathPointsrust-analyzer cargo postgres-protocol 0.6.12 types/PathPoints#<'a> {
951 remainingrust-analyzer cargo postgres-protocol 0.6.12 types/PathPoints#remaining.: i32,
952 bufrust-analyzer cargo postgres-protocol 0.6.12 types/PathPoints#buf.: &'a [u8],
953 }
954
955 impl FallibleIteratorrust-analyzer cargo fallible-iterator 0.3.0 FallibleIterator# for PathPointsrust-analyzer cargo postgres-protocol 0.6.12 types/PathPoints#<'_> {
956 type Itemrust-analyzer cargo postgres-protocol 0.6.12 types/impl#[`PathPoints<'_>`][FallibleIterator]Item# = Pointrust-analyzer cargo postgres-protocol 0.6.12 types/Point#;
957 type Errorrust-analyzer cargo postgres-protocol 0.6.12 types/impl#[`PathPoints<'_>`][FallibleIterator]Error# = StdBoxrust-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# + 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#>;
958
959 #[inline]
960 fn nextrust-analyzer cargo postgres-protocol 0.6.12 types/impl#[`PathPoints<'_>`][FallibleIterator]next().(&mut self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Pointrust-analyzer cargo postgres-protocol 0.6.12 types/Point#>, StdBoxrust-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# + 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#>> {
961 if self.remainingrust-analyzer cargo postgres-protocol 0.6.12 types/PathPoints#remaining. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]eq().0 {
962 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().self.bufrust-analyzer cargo postgres-protocol 0.6.12 types/PathPoints#buf..is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]is_empty().() {
963 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("invalid message length: path points not drained".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
964 }
965 return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
966 }
967 self.remainingrust-analyzer cargo postgres-protocol 0.6.12 types/PathPoints#remaining. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`SubAssign<Self>`]sub_assign().-=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`SubAssign<Self>`]sub_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`SubAssign<Self>`]sub_assign().1;
968
969 let x = self.bufrust-analyzer cargo postgres-protocol 0.6.12 types/PathPoints#buf..read_f64rust-analyzer cargo byteorder 1.5.0 io/ReadBytesExt#read_f64().::<BigEndianrust-analyzer cargo byteorder 1.5.0 BigEndian#>()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
970 let y = self.bufrust-analyzer cargo postgres-protocol 0.6.12 types/PathPoints#buf..read_f64rust-analyzer cargo byteorder 1.5.0 io/ReadBytesExt#read_f64().::<BigEndianrust-analyzer cargo byteorder 1.5.0 BigEndian#>()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
971
972 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Pointrust-analyzer cargo postgres-protocol 0.6.12 types/Point# { xrust-analyzer cargo postgres-protocol 0.6.12 types/Point#x., yrust-analyzer cargo postgres-protocol 0.6.12 types/Point#y. }))
973 }
974
975 #[inline]
976 fn size_hintrust-analyzer cargo postgres-protocol 0.6.12 types/impl#[`PathPoints<'_>`][FallibleIterator]size_hint().(&self) -> (usize, Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<usize>) {
977 let len = self.remainingrust-analyzer cargo postgres-protocol 0.6.12 types/PathPoints#remaining. as usize;
978 (len, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(len))
979 }
980 }
981
982 /// Serializes a Postgres inet.
983 #[inline]
984 pub fn inet_to_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/inet_to_sql().(addr: IpAddrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/ip_addr/IpAddr#, netmask: u8, buf: &mut BytesMutrust-analyzer cargo bytes 1.11.1 bytes_mut/BytesMut#) {
985 let family = match addr {
986 IpAddrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/ip_addr/IpAddr#::V4rust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/ip_addr/IpAddr#V4#(_) => PGSQL_AF_INETrust-analyzer cargo postgres-protocol 0.6.12 types/PGSQL_AF_INET.,
987 IpAddrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/ip_addr/IpAddr#::V6rust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/ip_addr/IpAddr#V6#(_) => PGSQL_AF_INET6rust-analyzer cargo postgres-protocol 0.6.12 types/PGSQL_AF_INET6.,
988 };
989 buf.put_u8rust-analyzer cargo bytes 1.11.1 buf/buf_mut/BufMut#put_u8().(family);
990 buf.put_u8rust-analyzer cargo bytes 1.11.1 buf/buf_mut/BufMut#put_u8().(netmask);
991 buf.put_u8rust-analyzer cargo bytes 1.11.1 buf/buf_mut/BufMut#put_u8().(0); // is_cidr
992 match addr {
993 IpAddrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/ip_addr/IpAddr#::V4rust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/ip_addr/IpAddr#V4#(addr) => {
994 buf.put_u8rust-analyzer cargo bytes 1.11.1 buf/buf_mut/BufMut#put_u8().(4);
995 buf.put_slicerust-analyzer cargo bytes 1.11.1 bytes_mut/impl#[BytesMut][BufMut]put_slice().(&addr.octetsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/ip_addr/impl#[Ipv4Addr]octets().());
996 }
997 IpAddrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/ip_addr/IpAddr#::V6rust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/ip_addr/IpAddr#V6#(addr) => {
998 buf.put_u8rust-analyzer cargo bytes 1.11.1 buf/buf_mut/BufMut#put_u8().(16);
999 buf.put_slicerust-analyzer cargo bytes 1.11.1 bytes_mut/impl#[BytesMut][BufMut]put_slice().(&addr.octetsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/ip_addr/impl#[Ipv6Addr]octets().());
1000 }
1001 }
1002 }
1003
1004 /// Deserializes a Postgres inet.
1005 #[inline]
1006 pub fn inet_from_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/inet_from_sql().(mut buf: &[u8]) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Inetrust-analyzer cargo postgres-protocol 0.6.12 types/Inet#, StdBoxrust-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# + 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#>> {
1007 let family = buf.read_u8rust-analyzer cargo byteorder 1.5.0 io/ReadBytesExt#read_u8().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
1008 let netmask = buf.read_u8rust-analyzer cargo byteorder 1.5.0 io/ReadBytesExt#read_u8().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
1009 buf.read_u8rust-analyzer cargo byteorder 1.5.0 io/ReadBytesExt#read_u8().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; // is_cidr
1010 let len = buf.read_u8rust-analyzer cargo byteorder 1.5.0 io/ReadBytesExt#read_u8().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
1011
1012 let addr = match family {
1013 PGSQL_AF_INETrust-analyzer cargo postgres-protocol 0.6.12 types/PGSQL_AF_INET. => {
1014 if netmask rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]gt().32 {
1015 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("invalid IPv4 netmask".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
1016 }
1017 if len 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().4 {
1018 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("invalid IPv4 address length".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
1019 }
1020 let mut addr = [0; 4];
1021 buf.read_exactrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/impls/impl#[`&[u8]`][Read]read_exact().(&mut addr)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
1022 IpAddrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/ip_addr/IpAddr#::V4rust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/ip_addr/IpAddr#V4#(Ipv4Addrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/ip_addr/Ipv4Addr#::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/ip_addr/impl#[Ipv4Addr][`From<[u8; 4]>`]from().(addr))
1023 }
1024 PGSQL_AF_INET6rust-analyzer cargo postgres-protocol 0.6.12 types/PGSQL_AF_INET6. => {
1025 if netmask rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]gt().128 {
1026 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("invalid IPv6 netmask".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
1027 }
1028 if len 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().16 {
1029 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("invalid IPv6 address length".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
1030 }
1031 let mut addr = [0; 16];
1032 buf.read_exactrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/impls/impl#[`&[u8]`][Read]read_exact().(&mut addr)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
1033 IpAddrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/ip_addr/IpAddr#::V6rust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/ip_addr/IpAddr#V6#(Ipv6Addrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/ip_addr/Ipv6Addr#::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/ip_addr/impl#[Ipv6Addr][`From<[u8; 16]>`]from().(addr))
1034 }
1035 _ => return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("invalid IP family".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()),
1036 };
1037
1038 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().buf.is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]is_empty().() {
1039 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("invalid buffer size".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
1040 }
1041
1042 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Inetrust-analyzer cargo postgres-protocol 0.6.12 types/Inet# { addrrust-analyzer cargo postgres-protocol 0.6.12 types/Inet#addr., netmaskrust-analyzer cargo postgres-protocol 0.6.12 types/Inet#netmask. })
1043 }
1044
1045 /// A Postgres network address.
1046 pub struct Inetrust-analyzer cargo postgres-protocol 0.6.12 types/Inet# {
1047 addrrust-analyzer cargo postgres-protocol 0.6.12 types/Inet#addr.: IpAddrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/ip_addr/IpAddr#,
1048 netmaskrust-analyzer cargo postgres-protocol 0.6.12 types/Inet#netmask.: u8,
1049 }
1050
1051 impl Inetrust-analyzer cargo postgres-protocol 0.6.12 types/Inet# {
1052 /// Returns the IP address.
1053 #[inline]
1054 pub fn addrrust-analyzer cargo postgres-protocol 0.6.12 types/impl#[Inet]addr().(&self) -> IpAddrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/ip_addr/IpAddr# {
1055 self.addrrust-analyzer cargo postgres-protocol 0.6.12 types/Inet#addr.
1056 }
1057
1058 /// Returns the netmask.
1059 #[inline]
1060 pub fn netmaskrust-analyzer cargo postgres-protocol 0.6.12 types/impl#[Inet]netmask().(&self) -> u8 {
1061 self.netmaskrust-analyzer cargo postgres-protocol 0.6.12 types/Inet#netmask.
1062 }
1063 }
1064
1065 /// Serializes a Postgres ltree string
1066 #[inline]
1067 pub fn ltree_to_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/ltree_to_sql().(v: &str, buf: &mut BytesMutrust-analyzer cargo bytes 1.11.1 bytes_mut/BytesMut#) {
1068 // A version number is prepended to an ltree string per spec
1069 buf.put_u8rust-analyzer cargo bytes 1.11.1 buf/buf_mut/BufMut#put_u8().(1);
1070 // Append the rest of the query
1071 buf.put_slicerust-analyzer cargo bytes 1.11.1 bytes_mut/impl#[BytesMut][BufMut]put_slice().(v.as_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_bytes().());
1072 }
1073
1074 /// Deserialize a Postgres ltree string
1075 #[inline]
1076 pub fn ltree_from_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/ltree_from_sql().(buf: &[u8]) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<&str, StdBoxrust-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# + 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#>> {
1077 match buf {
1078 // Remove the version number from the front of the ltree per spec
1079 [1u8, rest @ ..] => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/::from_utf8rust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/converts/from_utf8().(rest)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().),
1080 _ => Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("ltree version 1 only supported".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()),
1081 }
1082 }
1083
1084 /// Serializes a Postgres lquery string
1085 #[inline]
1086 pub fn lquery_to_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/lquery_to_sql().(v: &str, buf: &mut BytesMutrust-analyzer cargo bytes 1.11.1 bytes_mut/BytesMut#) {
1087 // A version number is prepended to an lquery string per spec
1088 buf.put_u8rust-analyzer cargo bytes 1.11.1 buf/buf_mut/BufMut#put_u8().(1);
1089 // Append the rest of the query
1090 buf.put_slicerust-analyzer cargo bytes 1.11.1 bytes_mut/impl#[BytesMut][BufMut]put_slice().(v.as_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_bytes().());
1091 }
1092
1093 /// Deserialize a Postgres lquery string
1094 #[inline]
1095 pub fn lquery_from_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/lquery_from_sql().(buf: &[u8]) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<&str, StdBoxrust-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# + 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#>> {
1096 match buf {
1097 // Remove the version number from the front of the lquery per spec
1098 [1u8, rest @ ..] => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/::from_utf8rust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/converts/from_utf8().(rest)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().),
1099 _ => Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("lquery version 1 only supported".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()),
1100 }
1101 }
1102
1103 /// Serializes a Postgres ltxtquery string
1104 #[inline]
1105 pub fn ltxtquery_to_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/ltxtquery_to_sql().(v: &str, buf: &mut BytesMutrust-analyzer cargo bytes 1.11.1 bytes_mut/BytesMut#) {
1106 // A version number is prepended to an ltxtquery string per spec
1107 buf.put_u8rust-analyzer cargo bytes 1.11.1 buf/buf_mut/BufMut#put_u8().(1);
1108 // Append the rest of the query
1109 buf.put_slicerust-analyzer cargo bytes 1.11.1 bytes_mut/impl#[BytesMut][BufMut]put_slice().(v.as_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_bytes().());
1110 }
1111
1112 /// Deserialize a Postgres ltxtquery string
1113 #[inline]
1114 pub fn ltxtquery_from_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/ltxtquery_from_sql().(buf: &[u8]) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<&str, StdBoxrust-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# + 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#>> {
1115 match buf {
1116 // Remove the version number from the front of the ltxtquery per spec
1117 [1u8, rest @ ..] => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/::from_utf8rust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/converts/from_utf8().(rest)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().),
1118 _ => Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("ltxtquery version 1 only supported".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()),
1119 }
1120 }