| 1 | //! Conversions to and from Postgres types. |
| 2 | //! |
| 3 | //! This crate is used by the `tokio-postgres` and `postgres` crates. You normally don't need to depend directly on it |
| 4 | //! unless you want to define your own `ToSql` or `FromSql` definitions. |
| 5 | //! |
| 6 | //! # Derive |
| 7 | //! |
| 8 | //! If the `derive` cargo feature is enabled, you can derive `ToSql` and `FromSql` implementations for custom Postgres |
| 9 | //! types. Explicitly, modify your `Cargo.toml` file to include the following: |
| 10 | //! |
| 11 | //! ```toml |
| 12 | //! [dependencies] |
| 13 | //! postgres-types = { version = "0.X.X", features = ["derive"] } |
| 14 | //! ``` |
| 15 | //! |
| 16 | //! ## Enums |
| 17 | //! |
| 18 | //! Postgres enums correspond to C-like enums in Rust: |
| 19 | //! |
| 20 | //! ```sql |
| 21 | //! CREATE TYPE "Mood" AS ENUM ( |
| 22 | //! 'Sad', |
| 23 | //! 'Ok', |
| 24 | //! 'Happy' |
| 25 | //! ); |
| 26 | //! ``` |
| 27 | //! |
| 28 | //! ```rust |
| 29 | //! # #[cfg(feature = "derive")] |
| 30 | //! use postgres_types::{ToSql, FromSql}; |
| 31 | //! |
| 32 | //! # #[cfg(feature = "derive")] |
| 33 | //! #[derive(Debug, ToSql, FromSql)] |
| 34 | //! enum Mood { |
| 35 | //! Sad, |
| 36 | //! Ok, |
| 37 | //! Happy, |
| 38 | //! } |
| 39 | //! ``` |
| 40 | //! |
| 41 | //! ## Domains |
| 42 | //! |
| 43 | //! Postgres domains correspond to tuple structs with one member in Rust: |
| 44 | //! |
| 45 | //! ```sql |
| 46 | //! CREATE DOMAIN "SessionId" AS BYTEA CHECK(octet_length(VALUE) = 16); |
| 47 | //! ``` |
| 48 | //! |
| 49 | //! ```rust |
| 50 | //! # #[cfg(feature = "derive")] |
| 51 | //! use postgres_types::{ToSql, FromSql}; |
| 52 | //! |
| 53 | //! # #[cfg(feature = "derive")] |
| 54 | //! #[derive(Debug, ToSql, FromSql)] |
| 55 | //! struct SessionId(Vec<u8>); |
| 56 | //! ``` |
| 57 | //! |
| 58 | //! ## Newtypes |
| 59 | //! |
| 60 | //! The `#[postgres(transparent)]` attribute can be used on a single-field tuple struct to create a |
| 61 | //! Rust-only wrapper type that will use the [`ToSql`] & [`FromSql`] implementation of the inner |
| 62 | //! value : |
| 63 | //! ```rust |
| 64 | //! # #[cfg(feature = "derive")] |
| 65 | //! use postgres_types::{ToSql, FromSql}; |
| 66 | //! |
| 67 | //! # #[cfg(feature = "derive")] |
| 68 | //! #[derive(Debug, ToSql, FromSql)] |
| 69 | //! #[postgres(transparent)] |
| 70 | //! struct UserId(i32); |
| 71 | //! ``` |
| 72 | //! |
| 73 | //! ## Composites |
| 74 | //! |
| 75 | //! Postgres composite types correspond to structs in Rust: |
| 76 | //! |
| 77 | //! ```sql |
| 78 | //! CREATE TYPE "InventoryItem" AS ( |
| 79 | //! name TEXT, |
| 80 | //! supplier_id INT, |
| 81 | //! price DOUBLE PRECISION |
| 82 | //! ); |
| 83 | //! ``` |
| 84 | //! |
| 85 | //! ```rust |
| 86 | //! # #[cfg(feature = "derive")] |
| 87 | //! use postgres_types::{ToSql, FromSql}; |
| 88 | //! |
| 89 | //! # #[cfg(feature = "derive")] |
| 90 | //! #[derive(Debug, ToSql, FromSql)] |
| 91 | //! struct InventoryItem { |
| 92 | //! name: String, |
| 93 | //! supplier_id: i32, |
| 94 | //! price: Option<f64>, |
| 95 | //! } |
| 96 | //! ``` |
| 97 | //! |
| 98 | //! ## Naming |
| 99 | //! |
| 100 | //! The derived implementations will enforce exact matches of type, field, and variant names between the Rust and |
| 101 | //! Postgres types. The `#[postgres(name = "...")]` attribute can be used to adjust the name on a type, variant, or |
| 102 | //! field: |
| 103 | //! |
| 104 | //! ```sql |
| 105 | //! CREATE TYPE mood AS ENUM ( |
| 106 | //! 'sad', |
| 107 | //! 'ok', |
| 108 | //! 'happy' |
| 109 | //! ); |
| 110 | //! ``` |
| 111 | //! |
| 112 | //! ```rust |
| 113 | //! # #[cfg(feature = "derive")] |
| 114 | //! use postgres_types::{ToSql, FromSql}; |
| 115 | //! |
| 116 | //! # #[cfg(feature = "derive")] |
| 117 | //! #[derive(Debug, ToSql, FromSql)] |
| 118 | //! #[postgres(name = "mood")] |
| 119 | //! enum Mood { |
| 120 | //! #[postgres(name = "sad")] |
| 121 | //! Sad, |
| 122 | //! #[postgres(name = "ok")] |
| 123 | //! Ok, |
| 124 | //! #[postgres(name = "happy")] |
| 125 | //! Happy, |
| 126 | //! } |
| 127 | //! ``` |
| 128 | //! |
| 129 | //! Alternatively, the `#[postgres(rename_all = "...")]` attribute can be used to rename all fields or variants |
| 130 | //! with the chosen casing convention. This will not affect the struct or enum's type name. Note that |
| 131 | //! `#[postgres(name = "...")]` takes precendence when used in conjunction with `#[postgres(rename_all = "...")]`: |
| 132 | //! |
| 133 | //! ```rust |
| 134 | //! # #[cfg(feature = "derive")] |
| 135 | //! use postgres_types::{ToSql, FromSql}; |
| 136 | //! |
| 137 | //! # #[cfg(feature = "derive")] |
| 138 | //! #[derive(Debug, ToSql, FromSql)] |
| 139 | //! #[postgres(name = "mood", rename_all = "snake_case")] |
| 140 | //! enum Mood { |
| 141 | //! #[postgres(name = "ok")] |
| 142 | //! Ok, // ok |
| 143 | //! VeryHappy, // very_happy |
| 144 | //! } |
| 145 | //! ``` |
| 146 | //! |
| 147 | //! The following case conventions are supported: |
| 148 | //! - `"lowercase"` |
| 149 | //! - `"UPPERCASE"` |
| 150 | //! - `"PascalCase"` |
| 151 | //! - `"camelCase"` |
| 152 | //! - `"snake_case"` |
| 153 | //! - `"SCREAMING_SNAKE_CASE"` |
| 154 | //! - `"kebab-case"` |
| 155 | //! - `"SCREAMING-KEBAB-CASE"` |
| 156 | //! - `"Train-Case"` |
| 157 | //! |
| 158 | //! ## Allowing Enum Mismatches |
| 159 | //! |
| 160 | //! By default the generated implementation of [`ToSql`] & [`FromSql`] for enums will require an exact match of the enum |
| 161 | //! variants between the Rust and Postgres types. |
| 162 | //! To allow mismatches, the `#[postgres(allow_mismatch)]` attribute can be used on the enum definition: |
| 163 | //! |
| 164 | //! ```sql |
| 165 | //! CREATE TYPE mood AS ENUM ( |
| 166 | //! 'Sad', |
| 167 | //! 'Ok', |
| 168 | //! 'Happy' |
| 169 | //! ); |
| 170 | //! ``` |
| 171 | //! |
| 172 | //! ```rust |
| 173 | //! # #[cfg(feature = "derive")] |
| 174 | //! use postgres_types::{ToSql, FromSql}; |
| 175 | //! |
| 176 | //! # #[cfg(feature = "derive")] |
| 177 | //! #[derive(Debug, ToSql, FromSql)] |
| 178 | //! #[postgres(allow_mismatch)] |
| 179 | //! enum Mood { |
| 180 | //! Happy, |
| 181 | //! Meh, |
| 182 | //! } |
| 183 | //! ``` |
| 184 | #![warn(clippy::all, rust_2018_idioms, missing_docs)] |
| 185 | use fallible_iteratorrust-analyzer cargo fallible-iterator 0.3.0 crate/::FallibleIteratorrust-analyzer cargo fallible-iterator 0.3.0 FallibleIterator#; |
| 186 | use postgres_protocolrust-analyzer cargo postgres-protocol 0.6.12 crate/::typesrust-analyzer cargo postgres-protocol 0.6.12 types/::{selfrust-analyzer cargo postgres-protocol 0.6.12 types/, ArrayDimensionrust-analyzer cargo postgres-protocol 0.6.12 types/ArrayDimension#}; |
| 187 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::anyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/::type_namerust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/type_name().; |
| 188 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::borrowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/::Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#; |
| 189 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::collectionsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/::HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#; |
| 190 | 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#; |
| 191 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/; |
| 192 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::hashrust-analyzer cargo std https://github.com/rust-lang/rust/library/std hash/::BuildHasherrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/BuildHasher#; |
| 193 | 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#; |
| 194 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::syncrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/::Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#; |
| 195 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::timerust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/::{Durationrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/Duration#, SystemTimerust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/SystemTime#, UNIX_EPOCHrust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/UNIX_EPOCH.}; |
| 196 | |
| 197 | #[cfg(feature = "derive")] |
| 198 | pub use postgres_deriverust-analyzer cargo postgres-derive 0.4.9 crate/::{FromSqlrust-analyzer cargo postgres-derive 0.4.9 FromSql:, ToSqlrust-analyzer cargo postgres-derive 0.4.9 ToSql:}; |
| 199 | |
| 200 | #[cfg(feature = "with-serde_json-1")] |
| 201 | pub use craterust-analyzer cargo postgres-types 0.2.14 crate/::serde_json_1rust-analyzer cargo postgres-types 0.2.14 serde_json_1/::Jsonrust-analyzer cargo postgres-types 0.2.14 serde_json_1/Json#; |
| 202 | use craterust-analyzer cargo postgres-types 0.2.14 crate/::type_genrust-analyzer cargo postgres-types 0.2.14 type_gen/::{Innerrust-analyzer cargo postgres-types 0.2.14 type_gen/Inner#, Otherrust-analyzer cargo postgres-types 0.2.14 type_gen/Other#}; |
| 203 | |
| 204 | #[doc(inline)] |
| 205 | pub use postgres_protocolrust-analyzer cargo postgres-protocol 0.6.12 crate/::Oidrust-analyzer cargo postgres-protocol 0.6.12 Oid#; |
| 206 | |
| 207 | #[doc(inline)] |
| 208 | pub use pg_lsnrust-analyzer cargo postgres-types 0.2.14 pg_lsn/::PgLsnrust-analyzer cargo postgres-types 0.2.14 pg_lsn/PgLsn#; |
| 209 | |
| 210 | pub use craterust-analyzer cargo postgres-types 0.2.14 crate/::specialrust-analyzer cargo postgres-types 0.2.14 special/::{Daterust-analyzer cargo postgres-types 0.2.14 special/Date#, Timestamprust-analyzer cargo postgres-types 0.2.14 special/Timestamp#}; |
| 211 | use bytesrust-analyzer cargo bytes 1.11.1 crate/::BytesMutrust-analyzer cargo bytes 1.11.1 bytes_mut/BytesMut#; |
| 212 | |
| 213 | // Number of seconds from 1970-01-01 to 2000-01-01 |
| 214 | const TIME_SEC_CONVERSIONrust-analyzer cargo postgres-types 0.2.14 TIME_SEC_CONVERSION.: u64 = 946_684_800; |
| 215 | const USEC_PER_SECrust-analyzer cargo postgres-types 0.2.14 USEC_PER_SEC.: u64 = 1_000_000; |
| 216 | const NSEC_PER_USECrust-analyzer cargo postgres-types 0.2.14 NSEC_PER_USEC.: u64 = 1_000; |
| 217 | |
| 218 | /// Generates a simple implementation of `ToSql::accepts` which accepts the |
| 219 | /// types passed to it. |
| 220 | #[macro_export] |
| 221 | macro_rules! acceptsrust-analyzer cargo postgres-types 0.2.14 accepts! { |
| 222 | ($($expected:ident),+) => ( |
| 223 | fn accepts(ty: &$crate::Type) -> bool { |
| 224 | matches!(*ty, $($crate::Type::$expected)|+) |
| 225 | } |
| 226 | ) |
| 227 | } |
| 228 | |
| 229 | /// Generates an implementation of `ToSql::to_sql_checked`. |
| 230 | /// |
| 231 | /// All `ToSql` implementations should use this macro. |
| 232 | #[macro_export] |
| 233 | macro_rules! to_sql_checkedrust-analyzer cargo postgres-types 0.2.14 to_sql_checked! { |
| 234 | () => { |
| 235 | fn to_sql_checked( |
| 236 | &self, |
| 237 | ty: &$crate::Type, |
| 238 | out: &mut $crate::private::BytesMut, |
| 239 | ) -> ::std::result::Result< |
| 240 | $crate::IsNull, |
| 241 | Box<dyn ::std::error::Error + ::std::marker::Sync + ::std::marker::Send>, |
| 242 | > { |
| 243 | $crate::__to_sql_checked(self, ty, out) |
| 244 | } |
| 245 | }; |
| 246 | } |
| 247 | |
| 248 | // WARNING: this function is not considered part of this crate's public API. |
| 249 | // It is subject to change at any time. |
| 250 | #[doc(hidden)] |
| 251 | pub fn __to_sql_checkedrust-analyzer cargo postgres-types 0.2.14 __to_sql_checked().<T>( |
| 252 | v: &T, |
| 253 | ty: &Typerust-analyzer cargo postgres-types 0.2.14 Type#, |
| 254 | out: &mut BytesMutrust-analyzer cargo bytes 1.11.1 bytes_mut/BytesMut#, |
| 255 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<IsNullrust-analyzer cargo postgres-types 0.2.14 IsNull#, Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + 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#>> |
| 256 | where |
| 257 | T: ToSqlrust-analyzer cargo postgres-types 0.2.14 ToSql#, |
| 258 | { |
| 259 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().T::acceptsrust-analyzer cargo postgres-types 0.2.14 ToSql#accepts().(ty) { |
| 260 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]new().(WrongTyperust-analyzer cargo postgres-types 0.2.14 WrongType#::newrust-analyzer cargo postgres-types 0.2.14 impl#[WrongType]new().::<T>(ty.clonerust-analyzer cargo postgres-types 0.2.14 impl#[Type][Clone]clone().()))); |
| 261 | } |
| 262 | v.to_sqlrust-analyzer cargo postgres-types 0.2.14 ToSql#to_sql().(ty, out) |
| 263 | } |
| 264 | |
| 265 | #[cfg(feature = "with-bit-vec-0_6")] |
| 266 | mod bit_vec_06; |
| 267 | #[cfg(feature = "with-bit-vec-0_7")] |
| 268 | mod bit_vec_07; |
| 269 | #[cfg(feature = "with-bit-vec-0_8")] |
| 270 | mod bit_vec_08rust-analyzer cargo postgres-types 0.2.14 bit_vec_08/; |
| 271 | #[cfg(feature = "with-bit-vec-0_9")] |
| 272 | mod bit_vec_09; |
| 273 | #[cfg(feature = "with-chrono-0_4")] |
| 274 | mod chrono_04rust-analyzer cargo postgres-types 0.2.14 chrono_04/; |
| 275 | #[cfg(feature = "with-cidr-0_2")] |
| 276 | mod cidr_02; |
| 277 | #[cfg(feature = "with-cidr-0_3")] |
| 278 | mod cidr_03rust-analyzer cargo postgres-types 0.2.14 cidr_03/; |
| 279 | #[cfg(feature = "with-eui48-0_4")] |
| 280 | mod eui48_04; |
| 281 | #[cfg(feature = "with-eui48-1")] |
| 282 | mod eui48_1rust-analyzer cargo postgres-types 0.2.14 eui48_1/; |
| 283 | #[cfg(feature = "with-geo-types-0_6")] |
| 284 | mod geo_types_06; |
| 285 | #[cfg(feature = "with-geo-types-0_7")] |
| 286 | mod geo_types_07rust-analyzer cargo postgres-types 0.2.14 geo_types_07/; |
| 287 | #[cfg(feature = "with-jiff-0_1")] |
| 288 | mod jiff_01; |
| 289 | #[cfg(feature = "with-jiff-0_2")] |
| 290 | mod jiff_02rust-analyzer cargo postgres-types 0.2.14 jiff_02/; |
| 291 | #[cfg(feature = "with-serde_json-1")] |
| 292 | mod serde_json_1rust-analyzer cargo postgres-types 0.2.14 serde_json_1/; |
| 293 | #[cfg(feature = "with-smol_str-01")] |
| 294 | mod smol_str_01; |
| 295 | #[cfg(feature = "with-time-0_2")] |
| 296 | mod time_02; |
| 297 | #[cfg(feature = "with-time-0_3")] |
| 298 | mod time_03rust-analyzer cargo postgres-types 0.2.14 time_03/; |
| 299 | #[cfg(feature = "with-uuid-0_8")] |
| 300 | mod uuid_08; |
| 301 | #[cfg(feature = "with-uuid-1")] |
| 302 | mod uuid_1rust-analyzer cargo postgres-types 0.2.14 uuid_1/; |
| 303 | |
| 304 | // The time::{date, time} macros produce compile errors if the crate package is renamed. |
| 305 | #[cfg(feature = "with-time-0_2")] |
| 306 | extern crate time_02 as time; |
| 307 | |
| 308 | mod pg_lsnrust-analyzer cargo postgres-types 0.2.14 pg_lsn/; |
| 309 | #[doc(hidden)] |
| 310 | pub mod privaterust-analyzer cargo postgres-types 0.2.14 private/; |
| 311 | mod specialrust-analyzer cargo postgres-types 0.2.14 special/; |
| 312 | mod type_genrust-analyzer cargo postgres-types 0.2.14 type_gen/; |
| 313 | |
| 314 | /// A Postgres type. |
| 315 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(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:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/macros/Hash:)] |
| 316 | pub struct Typerust-analyzer cargo postgres-types 0.2.14 Type#(Innerrust-analyzer cargo postgres-types 0.2.14 type_gen/Inner#); |
| 317 | |
| 318 | impl fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug# for Typerust-analyzer cargo postgres-types 0.2.14 Type# { |
| 319 | fn fmtrust-analyzer cargo postgres-types 0.2.14 impl#[Type][Debug]fmt().(&self, fmt: &mut fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#<'_>) -> fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# { |
| 320 | fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug#::fmtrust-analyzer cargo postgres-types 0.2.14 type_gen/impl#[Inner][Debug]fmt().(&self.0rust-analyzer cargo postgres-types 0.2.14 Type#0., fmt) |
| 321 | } |
| 322 | } |
| 323 | |
| 324 | impl fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# for Typerust-analyzer cargo postgres-types 0.2.14 Type# { |
| 325 | fn fmtrust-analyzer cargo postgres-types 0.2.14 impl#[Type][Display]fmt().(&self, fmt: &mut fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#<'_>) -> fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# { |
| 326 | match self.schemarust-analyzer cargo postgres-types 0.2.14 impl#[Type]schema().() { |
| 327 | "public" | "pg_catalog" => {} |
| 328 | schema => writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(fmt, "{schema}.")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., |
| 329 | } |
| 330 | fmt.write_strrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]write_str().(self.namerust-analyzer cargo postgres-types 0.2.14 impl#[Type]name().()) |
| 331 | } |
| 332 | } |
| 333 | |
| 334 | impl Typerust-analyzer cargo postgres-types 0.2.14 Type# { |
| 335 | /// Creates a new `Type`. |
| 336 | pub fn newrust-analyzer cargo postgres-types 0.2.14 impl#[Type]new().(name: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, oid: Oidrust-analyzer cargo postgres-protocol 0.6.12 Oid#, kind: Kindrust-analyzer cargo postgres-types 0.2.14 Kind#, schema: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#) -> Typerust-analyzer cargo postgres-types 0.2.14 Type# { |
| 337 | Typerust-analyzer cargo postgres-types 0.2.14 Type#(Innerrust-analyzer cargo postgres-types 0.2.14 type_gen/Inner#::Otherrust-analyzer cargo postgres-types 0.2.14 type_gen/Inner#Other#(Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T>`]new().(Otherrust-analyzer cargo postgres-types 0.2.14 type_gen/Other# { |
| 338 | namerust-analyzer cargo postgres-types 0.2.14 type_gen/Other#name., |
| 339 | oidrust-analyzer cargo postgres-types 0.2.14 type_gen/Other#oid., |
| 340 | kindrust-analyzer cargo postgres-types 0.2.14 type_gen/Other#kind., |
| 341 | schemarust-analyzer cargo postgres-types 0.2.14 type_gen/Other#schema., |
| 342 | }))) |
| 343 | } |
| 344 | |
| 345 | /// Returns the `Type` corresponding to the provided `Oid` if it |
| 346 | /// corresponds to a built-in type. |
| 347 | pub fn from_oidrust-analyzer cargo postgres-types 0.2.14 impl#[Type]from_oid().(oid: Oidrust-analyzer cargo postgres-protocol 0.6.12 Oid#) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Typerust-analyzer cargo postgres-types 0.2.14 Type#> { |
| 348 | Innerrust-analyzer cargo postgres-types 0.2.14 type_gen/Inner#::from_oidrust-analyzer cargo postgres-types 0.2.14 type_gen/impl#[Inner]from_oid().(oid).maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(Typerust-analyzer cargo postgres-types 0.2.14 Type#) |
| 349 | } |
| 350 | |
| 351 | /// Returns the OID of the `Type`. |
| 352 | pub fn oidrust-analyzer cargo postgres-types 0.2.14 impl#[Type]oid().(&self) -> Oidrust-analyzer cargo postgres-protocol 0.6.12 Oid# { |
| 353 | self.0rust-analyzer cargo postgres-types 0.2.14 Type#0..oidrust-analyzer cargo postgres-types 0.2.14 type_gen/impl#[Inner]oid().() |
| 354 | } |
| 355 | |
| 356 | /// Returns the kind of this type. |
| 357 | pub fn kindrust-analyzer cargo postgres-types 0.2.14 impl#[Type]kind().(&self) -> &Kindrust-analyzer cargo postgres-types 0.2.14 Kind# { |
| 358 | self.0rust-analyzer cargo postgres-types 0.2.14 Type#0..kindrust-analyzer cargo postgres-types 0.2.14 type_gen/impl#[Inner]kind().() |
| 359 | } |
| 360 | |
| 361 | /// Returns the schema of this type. |
| 362 | pub fn schemarust-analyzer cargo postgres-types 0.2.14 impl#[Type]schema().(&self) -> &str { |
| 363 | match self.0rust-analyzer cargo postgres-types 0.2.14 Type#0. { |
| 364 | Innerrust-analyzer cargo postgres-types 0.2.14 type_gen/Inner#::Otherrust-analyzer cargo postgres-types 0.2.14 type_gen/Inner#Other#(ref u) => &u.schemarust-analyzer cargo postgres-types 0.2.14 type_gen/Other#schema., |
| 365 | _ => "pg_catalog", |
| 366 | } |
| 367 | } |
| 368 | |
| 369 | /// Returns the name of this type. |
| 370 | pub fn namerust-analyzer cargo postgres-types 0.2.14 impl#[Type]name().(&self) -> &str { |
| 371 | self.0rust-analyzer cargo postgres-types 0.2.14 Type#0..namerust-analyzer cargo postgres-types 0.2.14 type_gen/impl#[Inner]name().() |
| 372 | } |
| 373 | } |
| 374 | |
| 375 | /// Represents the kind of a Postgres type. |
| 376 | #[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:, 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:, Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/macros/Hash:)] |
| 377 | #[non_exhaustive] |
| 378 | pub enum Kindrust-analyzer cargo postgres-types 0.2.14 Kind# { |
| 379 | /// A simple type like `VARCHAR` or `INTEGER`. |
| 380 | Simplerust-analyzer cargo postgres-types 0.2.14 Kind#Simple#, |
| 381 | /// An enumerated type along with its variants. |
| 382 | Enumrust-analyzer cargo postgres-types 0.2.14 Kind#Enum#(Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>), |
| 383 | /// A pseudo-type. |
| 384 | Pseudorust-analyzer cargo postgres-types 0.2.14 Kind#Pseudo#, |
| 385 | /// An array type along with the type of its elements. |
| 386 | Arrayrust-analyzer cargo postgres-types 0.2.14 Kind#Array#(Typerust-analyzer cargo postgres-types 0.2.14 Type#), |
| 387 | /// A range type along with the type of its elements. |
| 388 | Rangerust-analyzer cargo postgres-types 0.2.14 Kind#Range#(Typerust-analyzer cargo postgres-types 0.2.14 Type#), |
| 389 | /// A multirange type along with the type of its elements. |
| 390 | Multirangerust-analyzer cargo postgres-types 0.2.14 Kind#Multirange#(Typerust-analyzer cargo postgres-types 0.2.14 Type#), |
| 391 | /// A domain type along with its underlying type. |
| 392 | Domainrust-analyzer cargo postgres-types 0.2.14 Kind#Domain#(Typerust-analyzer cargo postgres-types 0.2.14 Type#), |
| 393 | /// A composite type along with information about its fields. |
| 394 | Compositerust-analyzer cargo postgres-types 0.2.14 Kind#Composite#(Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Fieldrust-analyzer cargo postgres-types 0.2.14 Field#>), |
| 395 | } |
| 396 | |
| 397 | /// Information about a field of a composite type. |
| 398 | #[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:, 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:, Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/macros/Hash:)] |
| 399 | pub struct Fieldrust-analyzer cargo postgres-types 0.2.14 Field# { |
| 400 | namerust-analyzer cargo postgres-types 0.2.14 Field#name.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, |
| 401 | type_rust-analyzer cargo postgres-types 0.2.14 Field#type_.: Typerust-analyzer cargo postgres-types 0.2.14 Type#, |
| 402 | } |
| 403 | |
| 404 | impl Fieldrust-analyzer cargo postgres-types 0.2.14 Field# { |
| 405 | /// Creates a new `Field`. |
| 406 | pub fn newrust-analyzer cargo postgres-types 0.2.14 impl#[Field]new().(name: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, type_: Typerust-analyzer cargo postgres-types 0.2.14 Type#) -> Fieldrust-analyzer cargo postgres-types 0.2.14 Field# { |
| 407 | Fieldrust-analyzer cargo postgres-types 0.2.14 Field# { namerust-analyzer cargo postgres-types 0.2.14 Field#name., type_rust-analyzer cargo postgres-types 0.2.14 Field#type_. } |
| 408 | } |
| 409 | |
| 410 | /// Returns the name of the field. |
| 411 | pub fn namerust-analyzer cargo postgres-types 0.2.14 impl#[Field]name().(&self) -> &str { |
| 412 | &self.namerust-analyzer cargo postgres-types 0.2.14 Field#name. |
| 413 | } |
| 414 | |
| 415 | /// Returns the type of the field. |
| 416 | pub fn type_rust-analyzer cargo postgres-types 0.2.14 impl#[Field]type_().(&self) -> &Typerust-analyzer cargo postgres-types 0.2.14 Type# { |
| 417 | &self.type_rust-analyzer cargo postgres-types 0.2.14 Field#type_. |
| 418 | } |
| 419 | } |
| 420 | |
| 421 | /// An error indicating that a `NULL` Postgres value was passed to a `FromSql` |
| 422 | /// implementation that does not support `NULL` values. |
| 423 | #[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:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:)] |
| 424 | pub struct WasNullrust-analyzer cargo postgres-types 0.2.14 WasNull#; |
| 425 | |
| 426 | impl fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# for WasNullrust-analyzer cargo postgres-types 0.2.14 WasNull# { |
| 427 | fn fmtrust-analyzer cargo postgres-types 0.2.14 impl#[WasNull][Display]fmt().(&self, fmt: &mut fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#<'_>) -> fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# { |
| 428 | fmt.write_strrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]write_str().("a Postgres value was `NULL`") |
| 429 | } |
| 430 | } |
| 431 | |
| 432 | impl Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# for WasNullrust-analyzer cargo postgres-types 0.2.14 WasNull# {} |
| 433 | |
| 434 | /// An error indicating that a conversion was attempted between incompatible |
| 435 | /// Rust and Postgres types. |
| 436 | #[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:)] |
| 437 | pub struct WrongTyperust-analyzer cargo postgres-types 0.2.14 WrongType# { |
| 438 | postgresrust-analyzer cargo postgres-types 0.2.14 WrongType#postgres.: Typerust-analyzer cargo postgres-types 0.2.14 Type#, |
| 439 | rustrust-analyzer cargo postgres-types 0.2.14 WrongType#rust.: &'static str, |
| 440 | } |
| 441 | |
| 442 | impl fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# for WrongTyperust-analyzer cargo postgres-types 0.2.14 WrongType# { |
| 443 | fn fmtrust-analyzer cargo postgres-types 0.2.14 impl#[WrongType][Display]fmt().(&self, fmt: &mut fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#<'_>) -> fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# { |
| 444 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!( |
| 445 | fmt, |
| 446 | "cannot convert between the Rust type `{}` and the Postgres type `{}`", |
| 447 | self.rustrust-analyzer cargo postgres-types 0.2.14 WrongType#rust., self.postgresrust-analyzer cargo postgres-types 0.2.14 WrongType#postgres., |
| 448 | ) |
| 449 | } |
| 450 | } |
| 451 | |
| 452 | impl Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# for WrongTyperust-analyzer cargo postgres-types 0.2.14 WrongType# {} |
| 453 | |
| 454 | impl WrongTyperust-analyzer cargo postgres-types 0.2.14 WrongType# { |
| 455 | /// Creates a new `WrongType` error. |
| 456 | pub fn newrust-analyzer cargo postgres-types 0.2.14 impl#[WrongType]new().<T>(ty: Typerust-analyzer cargo postgres-types 0.2.14 Type#) -> WrongTyperust-analyzer cargo postgres-types 0.2.14 WrongType# { |
| 457 | WrongTyperust-analyzer cargo postgres-types 0.2.14 WrongType# { |
| 458 | postgresrust-analyzer cargo postgres-types 0.2.14 WrongType#postgres.: ty, |
| 459 | rustrust-analyzer cargo postgres-types 0.2.14 WrongType#rust.: type_namerust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/type_name().::<T>(), |
| 460 | } |
| 461 | } |
| 462 | } |
| 463 | |
| 464 | /// A trait for types that can be created from a Postgres value. |
| 465 | /// |
| 466 | /// # Types |
| 467 | /// |
| 468 | /// The following implementations are provided by this crate, along with the |
| 469 | /// corresponding Postgres types: |
| 470 | /// |
| 471 | /// | Rust type | Postgres type(s) | |
| 472 | /// |-----------------------------------|-----------------------------------------------| |
| 473 | /// | `bool` | BOOL | |
| 474 | /// | `i8` | "char" | |
| 475 | /// | `i16` | SMALLINT, SMALLSERIAL | |
| 476 | /// | `i32` | INT, SERIAL | |
| 477 | /// | `u32` | OID | |
| 478 | /// | `i64` | BIGINT, BIGSERIAL | |
| 479 | /// | `f32` | REAL | |
| 480 | /// | `f64` | DOUBLE PRECISION | |
| 481 | /// | `&str`/`String` | VARCHAR, CHAR(n), TEXT, CITEXT, NAME, UNKNOWN | |
| 482 | /// | | LTREE, LQUERY, LTXTQUERY | |
| 483 | /// | `&[u8]`/`Vec<u8>` | BYTEA | |
| 484 | /// | `HashMap<String, Option<String>>` | HSTORE | |
| 485 | /// | `SystemTime` | TIMESTAMP, TIMESTAMP WITH TIME ZONE | |
| 486 | /// | `IpAddr` | INET | |
| 487 | /// |
| 488 | /// In addition, some implementations are provided for types in third party |
| 489 | /// crates. These are disabled by default; to opt into one of these |
| 490 | /// implementations, activate the Cargo feature corresponding to the crate's |
| 491 | /// name prefixed by `with-`. For example, the `with-serde_json-1` feature enables |
| 492 | /// the implementation for the `serde_json::Value` type. |
| 493 | /// |
| 494 | /// | Rust type | Postgres type(s) | |
| 495 | /// |---------------------------------|-------------------------------------| |
| 496 | /// | `chrono::NaiveDateTime` | TIMESTAMP | |
| 497 | /// | `chrono::DateTime<Utc>` | TIMESTAMP WITH TIME ZONE | |
| 498 | /// | `chrono::DateTime<Local>` | TIMESTAMP WITH TIME ZONE | |
| 499 | /// | `chrono::DateTime<FixedOffset>` | TIMESTAMP WITH TIME ZONE | |
| 500 | /// | `chrono::NaiveDate` | DATE | |
| 501 | /// | `chrono::NaiveTime` | TIME | |
| 502 | /// | `cidr::IpCidr` | CIDR | |
| 503 | /// | `cidr::IpInet` | INET | |
| 504 | /// | `time::PrimitiveDateTime` | TIMESTAMP | |
| 505 | /// | `time::OffsetDateTime` | TIMESTAMP WITH TIME ZONE | |
| 506 | /// | `time::Date` | DATE | |
| 507 | /// | `time::Time` | TIME | |
| 508 | /// | `jiff::civil::Date` | DATE | |
| 509 | /// | `jiff::civil::DateTime` | TIMESTAMP | |
| 510 | /// | `jiff::civil::Time` | TIME | |
| 511 | /// | `jiff::Timestamp` | TIMESTAMP WITH TIME ZONE | |
| 512 | /// | `eui48::MacAddress` | MACADDR | |
| 513 | /// | `geo_types::Point<f64>` | POINT | |
| 514 | /// | `geo_types::Rect<f64>` | BOX | |
| 515 | /// | `geo_types::LineString<f64>` | PATH | |
| 516 | /// | `serde_json::Value` | JSON, JSONB | |
| 517 | /// | `uuid::Uuid` | UUID | |
| 518 | /// | `bit_vec::BitVec` | BIT, VARBIT | |
| 519 | /// | `eui48::MacAddress` | MACADDR | |
| 520 | /// | `cidr::InetCidr` | CIDR | |
| 521 | /// | `cidr::InetAddr` | INET | |
| 522 | /// | `smol_str::SmolStr` | VARCHAR, CHAR(n), TEXT, CITEXT, | |
| 523 | /// | | NAME, UNKNOWN, LTREE, LQUERY, | |
| 524 | /// | | LTXTQUERY | |
| 525 | /// |
| 526 | /// # Nullability |
| 527 | /// |
| 528 | /// In addition to the types listed above, `FromSql` is implemented for |
| 529 | /// `Option<T>` where `T` implements `FromSql`. An `Option<T>` represents a |
| 530 | /// nullable Postgres value. |
| 531 | /// |
| 532 | /// # Arrays |
| 533 | /// |
| 534 | /// `FromSql` is implemented for `Vec<T>`, `Box<[T]>` and `[T; N]` where `T` |
| 535 | /// implements `FromSql`, and corresponds to one-dimensional Postgres arrays. |
| 536 | /// |
| 537 | /// **Note:** the impl for arrays only exist when the Cargo feature `array-impls` |
| 538 | /// is enabled. |
| 539 | pub trait FromSqlrust-analyzer cargo postgres-types 0.2.14 FromSql#<'a>: Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized# { |
| 540 | /// Creates a new value of this type from a buffer of data of the specified |
| 541 | /// Postgres `Type` in its binary format. |
| 542 | /// |
| 543 | /// The caller of this method is responsible for ensuring that this type |
| 544 | /// is compatible with the Postgres `Type`. |
| 545 | fn from_sqlrust-analyzer cargo postgres-types 0.2.14 FromSql#from_sql().(ty: &Typerust-analyzer cargo postgres-types 0.2.14 Type#, raw: &'a [u8]) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Self, Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + 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#>>; |
| 546 | |
| 547 | /// Creates a new value of this type from a `NULL` SQL value. |
| 548 | /// |
| 549 | /// The caller of this method is responsible for ensuring that this type |
| 550 | /// is compatible with the Postgres `Type`. |
| 551 | /// |
| 552 | /// The default implementation returns `Err(Box::new(WasNull))`. |
| 553 | #[allow(unused_variables)] |
| 554 | fn from_sql_nullrust-analyzer cargo postgres-types 0.2.14 FromSql#from_sql_null().(ty: &Typerust-analyzer cargo postgres-types 0.2.14 Type#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Self, Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + 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#>> { |
| 555 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]new().(WasNullrust-analyzer cargo postgres-types 0.2.14 WasNull#)) |
| 556 | } |
| 557 | |
| 558 | /// A convenience function that delegates to `from_sql` and `from_sql_null` depending on the |
| 559 | /// value of `raw`. |
| 560 | fn from_sql_nullablerust-analyzer cargo postgres-types 0.2.14 FromSql#from_sql_nullable().( |
| 561 | ty: &Typerust-analyzer cargo postgres-types 0.2.14 Type#, |
| 562 | raw: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&'a [u8]>, |
| 563 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Self, Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + 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#>> { |
| 564 | match raw { |
| 565 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(raw) => Self::from_sqlrust-analyzer cargo postgres-types 0.2.14 FromSql#from_sql().(ty, raw), |
| 566 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => Self::from_sql_nullrust-analyzer cargo postgres-types 0.2.14 FromSql#from_sql_null().(ty), |
| 567 | } |
| 568 | } |
| 569 | |
| 570 | /// Determines if a value of this type can be created from the specified |
| 571 | /// Postgres `Type`. |
| 572 | fn acceptsrust-analyzer cargo postgres-types 0.2.14 FromSql#accepts().(ty: &Typerust-analyzer cargo postgres-types 0.2.14 Type#) -> bool; |
| 573 | } |
| 574 | |
| 575 | /// A trait for types which can be created from a Postgres value without borrowing any data. |
| 576 | /// |
| 577 | /// This is primarily useful for trait bounds on functions. |
| 578 | pub trait FromSqlOwnedrust-analyzer cargo postgres-types 0.2.14 FromSqlOwned#: for<'a> FromSqlrust-analyzer cargo postgres-types 0.2.14 FromSql#<'a> {} |
| 579 | |
| 580 | impl<T> FromSqlOwnedrust-analyzer cargo postgres-types 0.2.14 FromSqlOwned# for T where T: for<'a> FromSqlrust-analyzer cargo postgres-types 0.2.14 FromSql#<'a> {} |
| 581 | |
| 582 | impl<'a, T: FromSqlrust-analyzer cargo postgres-types 0.2.14 FromSql#<'a>> FromSqlrust-analyzer cargo postgres-types 0.2.14 FromSql#<'a> for Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<T> { |
| 583 | fn from_sqlrust-analyzer cargo postgres-types 0.2.14 impl#[`Option<T>`][`FromSql<'a>`]from_sql().(ty: &Typerust-analyzer cargo postgres-types 0.2.14 Type#, raw: &'a [u8]) -> 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#<T>, Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + 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#>> { |
| 584 | <T as FromSqlrust-analyzer cargo postgres-types 0.2.14 FromSql#>::from_sqlrust-analyzer cargo postgres-types 0.2.14 FromSql#from_sql().(ty, raw).maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map().(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#) |
| 585 | } |
| 586 | |
| 587 | fn from_sql_nullrust-analyzer cargo postgres-types 0.2.14 impl#[`Option<T>`][`FromSql<'a>`]from_sql_null().(_: &Typerust-analyzer cargo postgres-types 0.2.14 Type#) -> 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#<T>, Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + 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#>> { |
| 588 | 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#) |
| 589 | } |
| 590 | |
| 591 | fn acceptsrust-analyzer cargo postgres-types 0.2.14 impl#[`Option<T>`][`FromSql<'a>`]accepts().(ty: &Typerust-analyzer cargo postgres-types 0.2.14 Type#) -> bool { |
| 592 | <T as FromSqlrust-analyzer cargo postgres-types 0.2.14 FromSql#>::acceptsrust-analyzer cargo postgres-types 0.2.14 FromSql#accepts().(ty) |
| 593 | } |
| 594 | } |
| 595 | |
| 596 | impl<'a, T: FromSqlrust-analyzer cargo postgres-types 0.2.14 FromSql#<'a>> FromSqlrust-analyzer cargo postgres-types 0.2.14 FromSql#<'a> for Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<T> { |
| 597 | fn from_sqlrust-analyzer cargo postgres-types 0.2.14 impl#[`Vec<T>`][`FromSql<'a>`]from_sql().(ty: &Typerust-analyzer cargo postgres-types 0.2.14 Type#, raw: &'a [u8]) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<T>, Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + 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#>> { |
| 598 | let member_type = match *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().ty.kindrust-analyzer cargo postgres-types 0.2.14 impl#[Type]kind().() { |
| 599 | Kindrust-analyzer cargo postgres-types 0.2.14 Kind#::Arrayrust-analyzer cargo postgres-types 0.2.14 Kind#Array#(ref member) => member, |
| 600 | _ => panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("expected array type"), |
| 601 | }; |
| 602 | |
| 603 | let array = typesrust-analyzer cargo postgres-protocol 0.6.12 types/::array_from_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/array_from_sql().(raw)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 604 | if array.dimensionsrust-analyzer cargo postgres-protocol 0.6.12 types/impl#[`Array<'a>`]dimensions().().count()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/try_trait/Try#branch(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#gt().1 { |
| 605 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("array contains too many dimensions".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()); |
| 606 | } |
| 607 | |
| 608 | array |
| 609 | .valuesrust-analyzer cargo postgres-protocol 0.6.12 types/impl#[`Array<'a>`]values().() |
| 610 | .map(|v| T::from_sql_nullablerust-analyzer cargo postgres-types 0.2.14 FromSql#from_sql_nullable().(member_type, v)) |
| 611 | .collect() |
| 612 | } |
| 613 | |
| 614 | fn acceptsrust-analyzer cargo postgres-types 0.2.14 impl#[`Vec<T>`][`FromSql<'a>`]accepts().(ty: &Typerust-analyzer cargo postgres-types 0.2.14 Type#) -> bool { |
| 615 | match *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().ty.kindrust-analyzer cargo postgres-types 0.2.14 impl#[Type]kind().() { |
| 616 | Kindrust-analyzer cargo postgres-types 0.2.14 Kind#::Arrayrust-analyzer cargo postgres-types 0.2.14 Kind#Array#(ref inner) => T::acceptsrust-analyzer cargo postgres-types 0.2.14 FromSql#accepts().(inner), |
| 617 | _ => false, |
| 618 | } |
| 619 | } |
| 620 | } |
| 621 | |
| 622 | #[cfg(feature = "array-impls")] |
| 623 | impl<'a, T: FromSqlrust-analyzer cargo postgres-types 0.2.14 FromSql#<'a>, const N: usize> FromSqlrust-analyzer cargo postgres-types 0.2.14 FromSql#<'a> for [T; N] { |
| 624 | fn from_sqlrust-analyzer cargo postgres-types 0.2.14 impl#[`[T; N]`][`FromSql<'a>`]from_sql().(ty: &Typerust-analyzer cargo postgres-types 0.2.14 Type#, raw: &'a [u8]) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo postgres-types 0.2.14 impl#[`[T; N]`][`FromSql<'a>`], Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + 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#>> { |
| 625 | let member_type = match *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().ty.kindrust-analyzer cargo postgres-types 0.2.14 impl#[Type]kind().() { |
| 626 | Kindrust-analyzer cargo postgres-types 0.2.14 Kind#::Arrayrust-analyzer cargo postgres-types 0.2.14 Kind#Array#(ref member) => member, |
| 627 | _ => panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("expected array type"), |
| 628 | }; |
| 629 | |
| 630 | let array = typesrust-analyzer cargo postgres-protocol 0.6.12 types/::array_from_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/array_from_sql().(raw)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 631 | if array.dimensionsrust-analyzer cargo postgres-protocol 0.6.12 types/impl#[`Array<'a>`]dimensions().().count()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/try_trait/Try#branch(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#gt().1 { |
| 632 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("array contains too many dimensions".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()); |
| 633 | } |
| 634 | |
| 635 | let mut values = array.valuesrust-analyzer cargo postgres-protocol 0.6.12 types/impl#[`Array<'a>`]values().(); |
| 636 | let out = array_initrust-analyzer cargo array-init 2.1.0 crate/::try_array_initrust-analyzer cargo array-init 2.1.0 try_array_init().(|i| { |
| 637 | let v = values |
| 638 | .next()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/try_trait/Try#branch(). |
| 639 | .ok_or_else(|| -> Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + 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#> { |
| 640 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("too few elements in array (expected {N}, got {i})").intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().() |
| 641 | })?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/try_trait/Try#branch().; |
| 642 | T::from_sql_nullablerust-analyzer cargo postgres-types 0.2.14 FromSql#from_sql_nullable().(member_type, v) |
| 643 | })?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 644 | if values.next()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/try_trait/Try#branch()..is_some() { |
| 645 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#( |
| 646 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("excess elements in array (expected {N}, got more than that)",).intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 647 | ); |
| 648 | } |
| 649 | |
| 650 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(out) |
| 651 | } |
| 652 | |
| 653 | fn acceptsrust-analyzer cargo postgres-types 0.2.14 impl#[`[T; N]`][`FromSql<'a>`]accepts().(ty: &Typerust-analyzer cargo postgres-types 0.2.14 Type#) -> bool { |
| 654 | match *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().ty.kindrust-analyzer cargo postgres-types 0.2.14 impl#[Type]kind().() { |
| 655 | Kindrust-analyzer cargo postgres-types 0.2.14 Kind#::Arrayrust-analyzer cargo postgres-types 0.2.14 Kind#Array#(ref inner) => T::acceptsrust-analyzer cargo postgres-types 0.2.14 FromSql#accepts().(inner), |
| 656 | _ => false, |
| 657 | } |
| 658 | } |
| 659 | } |
| 660 | |
| 661 | impl<'a, T: FromSqlrust-analyzer cargo postgres-types 0.2.14 FromSql#<'a>> FromSqlrust-analyzer cargo postgres-types 0.2.14 FromSql#<'a> for Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<T> { |
| 662 | fn from_sqlrust-analyzer cargo postgres-types 0.2.14 impl#[`Box<T>`][`FromSql<'a>`]from_sql().(ty: &Typerust-analyzer cargo postgres-types 0.2.14 Type#, row: &'a [u8]) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo postgres-types 0.2.14 impl#[`Box<T>`][`FromSql<'a>`], Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + 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#>> { |
| 663 | T::from_sqlrust-analyzer cargo postgres-types 0.2.14 FromSql#from_sql().(ty, row).maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map().(Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]new().) |
| 664 | } |
| 665 | |
| 666 | fn acceptsrust-analyzer cargo postgres-types 0.2.14 impl#[`Box<T>`][`FromSql<'a>`]accepts().(ty: &Typerust-analyzer cargo postgres-types 0.2.14 Type#) -> bool { |
| 667 | T::acceptsrust-analyzer cargo postgres-types 0.2.14 FromSql#accepts().(ty) |
| 668 | } |
| 669 | } |
| 670 | |
| 671 | impl<'a, T: FromSqlrust-analyzer cargo postgres-types 0.2.14 FromSql#<'a>> FromSqlrust-analyzer cargo postgres-types 0.2.14 FromSql#<'a> for Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<[T]> { |
| 672 | fn from_sqlrust-analyzer cargo postgres-types 0.2.14 impl#[`Box<[T]>`][`FromSql<'a>`]from_sql().(ty: &Typerust-analyzer cargo postgres-types 0.2.14 Type#, raw: &'a [u8]) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo postgres-types 0.2.14 impl#[`Box<[T]>`][`FromSql<'a>`], Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + 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#>> { |
| 673 | Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::<T>::from_sqlrust-analyzer cargo postgres-types 0.2.14 impl#[`Vec<T>`][`FromSql<'a>`]from_sql().(ty, raw).maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map().(Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::into_boxed_slicerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]into_boxed_slice().) |
| 674 | } |
| 675 | |
| 676 | fn acceptsrust-analyzer cargo postgres-types 0.2.14 impl#[`Box<[T]>`][`FromSql<'a>`]accepts().(ty: &Typerust-analyzer cargo postgres-types 0.2.14 Type#) -> bool { |
| 677 | Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::<T>::acceptsrust-analyzer cargo postgres-types 0.2.14 impl#[`Vec<T>`][`FromSql<'a>`]accepts().(ty) |
| 678 | } |
| 679 | } |
| 680 | |
| 681 | impl<'a> FromSqlrust-analyzer cargo postgres-types 0.2.14 FromSql#<'a> for Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8> { |
| 682 | fn from_sqlrust-analyzer cargo postgres-types 0.2.14 impl#[`Vec<u8>`][`FromSql<'a>`]from_sql().(_: &Typerust-analyzer cargo postgres-types 0.2.14 Type#, raw: &'a [u8]) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8>, Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + 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#>> { |
| 683 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(typesrust-analyzer cargo postgres-protocol 0.6.12 types/::bytea_from_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/bytea_from_sql().(raw).to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`][ToOwned]to_owned().()) |
| 684 | } |
| 685 | |
| 686 | acceptsrust-analyzer cargo postgres-types 0.2.14 accepts!!(BYTEArust-analyzer cargo postgres-types 0.2.14 type_gen/impl#[Type]BYTEA.); |
| 687 | } |
| 688 | |
| 689 | impl<'a> FromSqlrust-analyzer cargo postgres-types 0.2.14 FromSql#<'a> for &'a [u8] { |
| 690 | fn from_sqlrust-analyzer cargo postgres-types 0.2.14 impl#[`&'a [u8]`][`FromSql<'a>`]from_sql().(_: &Typerust-analyzer cargo postgres-types 0.2.14 Type#, raw: &'a [u8]) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<&'a [u8], Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + 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#>> { |
| 691 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(typesrust-analyzer cargo postgres-protocol 0.6.12 types/::bytea_from_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/bytea_from_sql().(raw)) |
| 692 | } |
| 693 | |
| 694 | acceptsrust-analyzer cargo postgres-types 0.2.14 accepts!!(BYTEArust-analyzer cargo postgres-types 0.2.14 type_gen/impl#[Type]BYTEA.); |
| 695 | } |
| 696 | |
| 697 | impl<'a> FromSqlrust-analyzer cargo postgres-types 0.2.14 FromSql#<'a> for Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# { |
| 698 | fn from_sqlrust-analyzer cargo postgres-types 0.2.14 impl#[String][`FromSql<'a>`]from_sql().(ty: &Typerust-analyzer cargo postgres-types 0.2.14 Type#, raw: &'a [u8]) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + 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#>> { |
| 699 | <&str as FromSqlrust-analyzer cargo postgres-types 0.2.14 FromSql#>::from_sqlrust-analyzer cargo postgres-types 0.2.14 impl#[`&'a str`][`FromSql<'a>`]from_sql().(ty, raw).maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map().(ToStringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/ToString#::to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().) |
| 700 | } |
| 701 | |
| 702 | fn acceptsrust-analyzer cargo postgres-types 0.2.14 impl#[String][`FromSql<'a>`]accepts().(ty: &Typerust-analyzer cargo postgres-types 0.2.14 Type#) -> bool { |
| 703 | <&str as FromSqlrust-analyzer cargo postgres-types 0.2.14 FromSql#>::acceptsrust-analyzer cargo postgres-types 0.2.14 impl#[`&'a str`][`FromSql<'a>`]accepts().(ty) |
| 704 | } |
| 705 | } |
| 706 | |
| 707 | impl<'a> FromSqlrust-analyzer cargo postgres-types 0.2.14 FromSql#<'a> for Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<str> { |
| 708 | fn from_sqlrust-analyzer cargo postgres-types 0.2.14 impl#[`Box<str>`][`FromSql<'a>`]from_sql().(ty: &Typerust-analyzer cargo postgres-types 0.2.14 Type#, raw: &'a [u8]) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<str>, Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + 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#>> { |
| 709 | <&str as FromSqlrust-analyzer cargo postgres-types 0.2.14 FromSql#>::from_sqlrust-analyzer cargo postgres-types 0.2.14 impl#[`&'a str`][`FromSql<'a>`]from_sql().(ty, raw) |
| 710 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map().(ToStringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/ToString#::to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().) |
| 711 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map().(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::into_boxed_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]into_boxed_str().) |
| 712 | } |
| 713 | |
| 714 | fn acceptsrust-analyzer cargo postgres-types 0.2.14 impl#[`Box<str>`][`FromSql<'a>`]accepts().(ty: &Typerust-analyzer cargo postgres-types 0.2.14 Type#) -> bool { |
| 715 | <&str as FromSqlrust-analyzer cargo postgres-types 0.2.14 FromSql#>::acceptsrust-analyzer cargo postgres-types 0.2.14 impl#[`&'a str`][`FromSql<'a>`]accepts().(ty) |
| 716 | } |
| 717 | } |
| 718 | |
| 719 | impl<'a> FromSqlrust-analyzer cargo postgres-types 0.2.14 FromSql#<'a> for &'a str { |
| 720 | fn from_sqlrust-analyzer cargo postgres-types 0.2.14 impl#[`&'a str`][`FromSql<'a>`]from_sql().(ty: &Typerust-analyzer cargo postgres-types 0.2.14 Type#, raw: &'a [u8]) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<&'a str, Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + 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#>> { |
| 721 | match *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().ty { |
| 722 | ref ty if ty.namerust-analyzer cargo postgres-types 0.2.14 impl#[Type]name().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq()."ltree" => typesrust-analyzer cargo postgres-protocol 0.6.12 types/::ltree_from_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/ltree_from_sql().(raw), |
| 723 | ref ty if ty.namerust-analyzer cargo postgres-types 0.2.14 impl#[Type]name().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq()."lquery" => typesrust-analyzer cargo postgres-protocol 0.6.12 types/::lquery_from_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/lquery_from_sql().(raw), |
| 724 | ref ty if ty.namerust-analyzer cargo postgres-types 0.2.14 impl#[Type]name().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq()."ltxtquery" => typesrust-analyzer cargo postgres-protocol 0.6.12 types/::ltxtquery_from_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/ltxtquery_from_sql().(raw), |
| 725 | _ => typesrust-analyzer cargo postgres-protocol 0.6.12 types/::text_from_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/text_from_sql().(raw), |
| 726 | } |
| 727 | } |
| 728 | |
| 729 | fn acceptsrust-analyzer cargo postgres-types 0.2.14 impl#[`&'a str`][`FromSql<'a>`]accepts().(ty: &Typerust-analyzer cargo postgres-types 0.2.14 Type#) -> bool { |
| 730 | match *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().ty { |
| 731 | Typerust-analyzer cargo postgres-types 0.2.14 Type#::VARCHARrust-analyzer cargo postgres-types 0.2.14 type_gen/impl#[Type]VARCHAR. | Typerust-analyzer cargo postgres-types 0.2.14 Type#::TEXTrust-analyzer cargo postgres-types 0.2.14 type_gen/impl#[Type]TEXT. | Typerust-analyzer cargo postgres-types 0.2.14 Type#::BPCHARrust-analyzer cargo postgres-types 0.2.14 type_gen/impl#[Type]BPCHAR. | Typerust-analyzer cargo postgres-types 0.2.14 Type#::NAMErust-analyzer cargo postgres-types 0.2.14 type_gen/impl#[Type]NAME. | Typerust-analyzer cargo postgres-types 0.2.14 Type#::UNKNOWNrust-analyzer cargo postgres-types 0.2.14 type_gen/impl#[Type]UNKNOWN. => true, |
| 732 | ref ty |
| 733 | if (ty.namerust-analyzer cargo postgres-types 0.2.14 impl#[Type]name().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq()."citext" |
| 734 | || ty.namerust-analyzer cargo postgres-types 0.2.14 impl#[Type]name().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq()."ltree" |
| 735 | || ty.namerust-analyzer cargo postgres-types 0.2.14 impl#[Type]name().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq()."lquery" |
| 736 | || ty.namerust-analyzer cargo postgres-types 0.2.14 impl#[Type]name().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq()."ltxtquery") => |
| 737 | { |
| 738 | true |
| 739 | } |
| 740 | _ => false, |
| 741 | } |
| 742 | } |
| 743 | } |
| 744 | |
| 745 | impl<'a> FromSqlrust-analyzer cargo postgres-types 0.2.14 FromSql#<'a> for Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#<'a, str> { |
| 746 | fn from_sqlrust-analyzer cargo postgres-types 0.2.14 impl#[`Cow<'a, str>`][`FromSql<'a>`]from_sql().(ty: &Typerust-analyzer cargo postgres-types 0.2.14 Type#, raw: &'a [u8]) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#<'a, str>, Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + 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#>> { |
| 747 | <&str as FromSqlrust-analyzer cargo postgres-types 0.2.14 FromSql#>::from_sqlrust-analyzer cargo postgres-types 0.2.14 impl#[`&'a str`][`FromSql<'a>`]from_sql().(ty, raw).maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map().(Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#::Borrowedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#Borrowed#) |
| 748 | } |
| 749 | |
| 750 | fn acceptsrust-analyzer cargo postgres-types 0.2.14 impl#[`Cow<'a, str>`][`FromSql<'a>`]accepts().(ty: &Typerust-analyzer cargo postgres-types 0.2.14 Type#) -> bool { |
| 751 | <&str as FromSqlrust-analyzer cargo postgres-types 0.2.14 FromSql#>::acceptsrust-analyzer cargo postgres-types 0.2.14 impl#[`&'a str`][`FromSql<'a>`]accepts().(ty) |
| 752 | } |
| 753 | } |
| 754 | |
| 755 | macro_rules! simple_fromrust-analyzer cargo postgres-types 0.2.14 simple_from! { |
| 756 | ($t:ty, $f:ident, $($expected:ident),+) => { |
| 757 | impl<'a> FromSql<'a> for $t { |
| 758 | fn from_sql(_: &Type, raw: &'a [u8]) -> Result<$t, Box<dyn Error + Sync + Send>> { |
| 759 | types::$f(raw) |
| 760 | } |
| 761 | |
| 762 | accepts!($($expected),+); |
| 763 | } |
| 764 | } |
| 765 | } |
| 766 | |
| 767 | simple_fromrust-analyzer cargo postgres-types 0.2.14 simple_from!!(bool, bool_from_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/bool_from_sql()., BOOLrust-analyzer cargo postgres-types 0.2.14 type_gen/impl#[Type]BOOL.); |
| 768 | simple_fromrust-analyzer cargo postgres-types 0.2.14 simple_from!!(i8, char_from_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/char_from_sql()., CHARrust-analyzer cargo postgres-types 0.2.14 type_gen/impl#[Type]CHAR.); |
| 769 | simple_fromrust-analyzer cargo postgres-types 0.2.14 simple_from!!(i16, int2_from_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/int2_from_sql()., INT2rust-analyzer cargo postgres-types 0.2.14 type_gen/impl#[Type]INT2.); |
| 770 | simple_fromrust-analyzer cargo postgres-types 0.2.14 simple_from!!(i32, int4_from_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/int4_from_sql()., INT4rust-analyzer cargo postgres-types 0.2.14 type_gen/impl#[Type]INT4.); |
| 771 | simple_fromrust-analyzer cargo postgres-types 0.2.14 simple_from!!(u32, oid_from_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/oid_from_sql()., OIDrust-analyzer cargo postgres-types 0.2.14 type_gen/impl#[Type]OID.); |
| 772 | simple_fromrust-analyzer cargo postgres-types 0.2.14 simple_from!!(i64, int8_from_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/int8_from_sql()., INT8rust-analyzer cargo postgres-types 0.2.14 type_gen/impl#[Type]INT8.); |
| 773 | simple_fromrust-analyzer cargo postgres-types 0.2.14 simple_from!!(f32, float4_from_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/float4_from_sql()., FLOAT4rust-analyzer cargo postgres-types 0.2.14 type_gen/impl#[Type]FLOAT4.); |
| 774 | simple_fromrust-analyzer cargo postgres-types 0.2.14 simple_from!!(f64, float8_from_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/float8_from_sql()., FLOAT8rust-analyzer cargo postgres-types 0.2.14 type_gen/impl#[Type]FLOAT8.); |
| 775 | |
| 776 | impl<'a, S> FromSqlrust-analyzer cargo postgres-types 0.2.14 FromSql#<'a> for HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>, S> |
| 777 | where |
| 778 | S: Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default# + BuildHasherrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/BuildHasher#, |
| 779 | { |
| 780 | fn from_sqlrust-analyzer cargo postgres-types 0.2.14 impl#[`HashMap<String, Option<String>, S>`][`FromSql<'a>`]from_sql().( |
| 781 | _: &Typerust-analyzer cargo postgres-types 0.2.14 Type#, |
| 782 | raw: &'a [u8], |
| 783 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>, S>, Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + 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#>> { |
| 784 | typesrust-analyzer cargo postgres-protocol 0.6.12 types/::hstore_from_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/hstore_from_sql().(raw)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). |
| 785 | .map(|(k, v)| Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#((k.to_owned(), v.map(str::to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().)))) |
| 786 | .collect() |
| 787 | } |
| 788 | |
| 789 | fn acceptsrust-analyzer cargo postgres-types 0.2.14 impl#[`HashMap<String, Option<String>, S>`][`FromSql<'a>`]accepts().(ty: &Typerust-analyzer cargo postgres-types 0.2.14 Type#) -> bool { |
| 790 | ty.namerust-analyzer cargo postgres-types 0.2.14 impl#[Type]name().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq()."hstore" |
| 791 | } |
| 792 | } |
| 793 | |
| 794 | impl<'a> FromSqlrust-analyzer cargo postgres-types 0.2.14 FromSql#<'a> for SystemTimerust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/SystemTime# { |
| 795 | fn from_sqlrust-analyzer cargo postgres-types 0.2.14 impl#[SystemTime][`FromSql<'a>`]from_sql().(_: &Typerust-analyzer cargo postgres-types 0.2.14 Type#, raw: &'a [u8]) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<SystemTimerust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/SystemTime#, Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + 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#>> { |
| 796 | let time = typesrust-analyzer cargo postgres-protocol 0.6.12 types/::timestamp_from_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/timestamp_from_sql().(raw)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 797 | let epoch = UNIX_EPOCHrust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/UNIX_EPOCH. rust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/impl#[SystemTime][`Add<Duration>`]add().+rust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/impl#[SystemTime][`Add<Duration>`]add(). rust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/impl#[SystemTime][`Add<Duration>`]add().Durationrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/Duration#::from_secsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/impl#[Duration]from_secs().(TIME_SEC_CONVERSIONrust-analyzer cargo postgres-types 0.2.14 TIME_SEC_CONVERSION.); |
| 798 | |
| 799 | let negative = time rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i64][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i64][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i64][`PartialOrd<Self>`]lt().0; |
| 800 | let time = time.unsigned_absrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[i64]unsigned_abs().(); |
| 801 | |
| 802 | let secs = time rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Div<Self>`]div().USEC_PER_SECrust-analyzer cargo postgres-types 0.2.14 USEC_PER_SEC.; |
| 803 | let nsec = (time rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Rem<Self>`]rem().%rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Rem<Self>`]rem(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Rem<Self>`]rem().USEC_PER_SECrust-analyzer cargo postgres-types 0.2.14 USEC_PER_SEC.) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul().NSEC_PER_USECrust-analyzer cargo postgres-types 0.2.14 NSEC_PER_USEC.; |
| 804 | let offset = Durationrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/Duration#::newrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/impl#[Duration]new().(secs, nsec as u32); |
| 805 | |
| 806 | let time = if negative { |
| 807 | epoch rust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/impl#[SystemTime][`Sub<Duration>`]sub().-rust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/impl#[SystemTime][`Sub<Duration>`]sub(). rust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/impl#[SystemTime][`Sub<Duration>`]sub().offset |
| 808 | } else { |
| 809 | epoch rust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/impl#[SystemTime][`Add<Duration>`]add().+rust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/impl#[SystemTime][`Add<Duration>`]add(). rust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/impl#[SystemTime][`Add<Duration>`]add().offset |
| 810 | }; |
| 811 | |
| 812 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(time) |
| 813 | } |
| 814 | |
| 815 | acceptsrust-analyzer cargo postgres-types 0.2.14 accepts!!(TIMESTAMPrust-analyzer cargo postgres-types 0.2.14 type_gen/impl#[Type]TIMESTAMP., TIMESTAMPTZrust-analyzer cargo postgres-types 0.2.14 type_gen/impl#[Type]TIMESTAMPTZ.); |
| 816 | } |
| 817 | |
| 818 | impl<'a> FromSqlrust-analyzer cargo postgres-types 0.2.14 FromSql#<'a> for IpAddrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/ip_addr/IpAddr# { |
| 819 | fn from_sqlrust-analyzer cargo postgres-types 0.2.14 impl#[IpAddr][`FromSql<'a>`]from_sql().(_: &Typerust-analyzer cargo postgres-types 0.2.14 Type#, raw: &'a [u8]) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<IpAddrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/ip_addr/IpAddr#, Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + 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#>> { |
| 820 | let inet = typesrust-analyzer cargo postgres-protocol 0.6.12 types/::inet_from_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/inet_from_sql().(raw)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 821 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(inet.addrrust-analyzer cargo postgres-protocol 0.6.12 types/impl#[Inet]addr().()) |
| 822 | } |
| 823 | |
| 824 | acceptsrust-analyzer cargo postgres-types 0.2.14 accepts!!(INETrust-analyzer cargo postgres-types 0.2.14 type_gen/impl#[Type]INET.); |
| 825 | } |
| 826 | |
| 827 | /// An enum representing the nullability of a Postgres value. |
| 828 | pub enum IsNullrust-analyzer cargo postgres-types 0.2.14 IsNull# { |
| 829 | /// The value is NULL. |
| 830 | Yesrust-analyzer cargo postgres-types 0.2.14 IsNull#Yes#, |
| 831 | /// The value is not NULL. |
| 832 | Norust-analyzer cargo postgres-types 0.2.14 IsNull#No#, |
| 833 | } |
| 834 | |
| 835 | /// A trait for types that can be converted into Postgres values. |
| 836 | /// |
| 837 | /// # Types |
| 838 | /// |
| 839 | /// The following implementations are provided by this crate, along with the |
| 840 | /// corresponding Postgres types: |
| 841 | /// |
| 842 | /// | Rust type | Postgres type(s) | |
| 843 | /// |-----------------------------------|--------------------------------------| |
| 844 | /// | `bool` | BOOL | |
| 845 | /// | `i8` | "char" | |
| 846 | /// | `i16` | SMALLINT, SMALLSERIAL | |
| 847 | /// | `i32` | INT, SERIAL | |
| 848 | /// | `u32` | OID | |
| 849 | /// | `i64` | BIGINT, BIGSERIAL | |
| 850 | /// | `f32` | REAL | |
| 851 | /// | `f64` | DOUBLE PRECISION | |
| 852 | /// | `&str`/`String` | VARCHAR, CHAR(n), TEXT, CITEXT, NAME | |
| 853 | /// | | LTREE, LQUERY, LTXTQUERY | |
| 854 | /// | `&[u8]`/`Vec<u8>`/`[u8; N]` | BYTEA | |
| 855 | /// | `HashMap<String, Option<String>>` | HSTORE | |
| 856 | /// | `SystemTime` | TIMESTAMP, TIMESTAMP WITH TIME ZONE | |
| 857 | /// | `IpAddr` | INET | |
| 858 | /// |
| 859 | /// In addition, some implementations are provided for types in third party |
| 860 | /// crates. These are disabled by default; to opt into one of these |
| 861 | /// implementations, activate the Cargo feature corresponding to the crate's |
| 862 | /// name prefixed by `with-`. For example, the `with-serde_json-1` feature enables |
| 863 | /// the implementation for the `serde_json::Value` type. |
| 864 | /// |
| 865 | /// | Rust type | Postgres type(s) | |
| 866 | /// |---------------------------------|-------------------------------------| |
| 867 | /// | `chrono::NaiveDateTime` | TIMESTAMP | |
| 868 | /// | `chrono::DateTime<Utc>` | TIMESTAMP WITH TIME ZONE | |
| 869 | /// | `chrono::DateTime<Local>` | TIMESTAMP WITH TIME ZONE | |
| 870 | /// | `chrono::DateTime<FixedOffset>` | TIMESTAMP WITH TIME ZONE | |
| 871 | /// | `chrono::NaiveDate` | DATE | |
| 872 | /// | `chrono::NaiveTime` | TIME | |
| 873 | /// | `cidr::IpCidr` | CIDR | |
| 874 | /// | `cidr::IpInet` | INET | |
| 875 | /// | `time::PrimitiveDateTime` | TIMESTAMP | |
| 876 | /// | `time::OffsetDateTime` | TIMESTAMP WITH TIME ZONE | |
| 877 | /// | `time::Date` | DATE | |
| 878 | /// | `time::Time` | TIME | |
| 879 | /// | `eui48::MacAddress` | MACADDR | |
| 880 | /// | `geo_types::Point<f64>` | POINT | |
| 881 | /// | `geo_types::Rect<f64>` | BOX | |
| 882 | /// | `geo_types::LineString<f64>` | PATH | |
| 883 | /// | `serde_json::Value` | JSON, JSONB | |
| 884 | /// | `uuid::Uuid` | UUID | |
| 885 | /// | `bit_vec::BitVec` | BIT, VARBIT | |
| 886 | /// | `eui48::MacAddress` | MACADDR | |
| 887 | /// |
| 888 | /// # Nullability |
| 889 | /// |
| 890 | /// In addition to the types listed above, `ToSql` is implemented for |
| 891 | /// `Option<T>` where `T` implements `ToSql`. An `Option<T>` represents a |
| 892 | /// nullable Postgres value. |
| 893 | /// |
| 894 | /// # Arrays |
| 895 | /// |
| 896 | /// `ToSql` is implemented for `[u8; N]`, `Vec<T>`, `&[T]`, `Box<[T]>` and `[T; N]` |
| 897 | /// where `T` implements `ToSql` and `N` is const usize, and corresponds to one-dimensional |
| 898 | /// Postgres arrays with an index offset of 1. |
| 899 | /// To make conversion work correctly for `WHERE ... IN` clauses, for example |
| 900 | /// `WHERE col IN ($1)`, you may instead have to use the construct |
| 901 | /// `WHERE col = ANY ($1)` which expects an array. |
| 902 | /// |
| 903 | /// **Note:** the impl for arrays only exist when the Cargo feature `array-impls` |
| 904 | /// is enabled. |
| 905 | pub trait ToSqlrust-analyzer cargo postgres-types 0.2.14 ToSql#: fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug# { |
| 906 | /// Converts the value of `self` into the binary format of the specified |
| 907 | /// Postgres `Type`, appending it to `out`. |
| 908 | /// |
| 909 | /// The caller of this method is responsible for ensuring that this type |
| 910 | /// is compatible with the Postgres `Type`. |
| 911 | /// |
| 912 | /// The return value indicates if this value should be represented as |
| 913 | /// `NULL`. If this is the case, implementations **must not** write |
| 914 | /// anything to `out`. |
| 915 | fn to_sqlrust-analyzer cargo postgres-types 0.2.14 ToSql#to_sql().(&self, ty: &Typerust-analyzer cargo postgres-types 0.2.14 Type#, out: &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-types 0.2.14 IsNull#, Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + 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#>> |
| 916 | where |
| 917 | Self: Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized#; |
| 918 | |
| 919 | /// Determines if a value of this type can be converted to the specified |
| 920 | /// Postgres `Type`. |
| 921 | fn acceptsrust-analyzer cargo postgres-types 0.2.14 ToSql#accepts().(ty: &Typerust-analyzer cargo postgres-types 0.2.14 Type#) -> bool |
| 922 | where |
| 923 | Self: Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized#; |
| 924 | |
| 925 | /// An adaptor method used internally by Rust-Postgres. |
| 926 | /// |
| 927 | /// *All* implementations of this method should be generated by the |
| 928 | /// `to_sql_checked!()` macro. |
| 929 | fn to_sql_checkedrust-analyzer cargo postgres-types 0.2.14 ToSql#to_sql_checked().( |
| 930 | &self, |
| 931 | ty: &Typerust-analyzer cargo postgres-types 0.2.14 Type#, |
| 932 | out: &mut BytesMutrust-analyzer cargo bytes 1.11.1 bytes_mut/BytesMut#, |
| 933 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<IsNullrust-analyzer cargo postgres-types 0.2.14 IsNull#, Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + 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#>>; |
| 934 | |
| 935 | /// Specify the encode format |
| 936 | fn encode_formatrust-analyzer cargo postgres-types 0.2.14 ToSql#encode_format().(&self, _ty: &Typerust-analyzer cargo postgres-types 0.2.14 Type#) -> Formatrust-analyzer cargo postgres-types 0.2.14 Format# { |
| 937 | Formatrust-analyzer cargo postgres-types 0.2.14 Format#::Binaryrust-analyzer cargo postgres-types 0.2.14 Format#Binary# |
| 938 | } |
| 939 | } |
| 940 | |
| 941 | /// Supported Postgres message format types |
| 942 | /// |
| 943 | /// Using Text format in a message assumes a Postgres `SERVER_ENCODING` of `UTF8` |
| 944 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)] |
| 945 | pub enum Formatrust-analyzer cargo postgres-types 0.2.14 Format# { |
| 946 | /// Text format (UTF-8) |
| 947 | Textrust-analyzer cargo postgres-types 0.2.14 Format#Text#, |
| 948 | /// Compact, typed binary format |
| 949 | Binaryrust-analyzer cargo postgres-types 0.2.14 Format#Binary#, |
| 950 | } |
| 951 | |
| 952 | impl<T> ToSqlrust-analyzer cargo postgres-types 0.2.14 ToSql# for &T |
| 953 | where |
| 954 | T: ToSqlrust-analyzer cargo postgres-types 0.2.14 ToSql#, |
| 955 | { |
| 956 | fn to_sqlrust-analyzer cargo postgres-types 0.2.14 impl#[`&T`][ToSql]to_sql().( |
| 957 | &self, |
| 958 | ty: &Typerust-analyzer cargo postgres-types 0.2.14 Type#, |
| 959 | out: &mut BytesMutrust-analyzer cargo bytes 1.11.1 bytes_mut/BytesMut#, |
| 960 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<IsNullrust-analyzer cargo postgres-types 0.2.14 IsNull#, Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + 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 | (*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self).to_sqlrust-analyzer cargo postgres-types 0.2.14 ToSql#to_sql().(ty, out) |
| 962 | } |
| 963 | |
| 964 | fn acceptsrust-analyzer cargo postgres-types 0.2.14 impl#[`&T`][ToSql]accepts().(ty: &Typerust-analyzer cargo postgres-types 0.2.14 Type#) -> bool { |
| 965 | T::acceptsrust-analyzer cargo postgres-types 0.2.14 ToSql#accepts().(ty) |
| 966 | } |
| 967 | |
| 968 | fn encode_formatrust-analyzer cargo postgres-types 0.2.14 impl#[`&T`][ToSql]encode_format().(&self, ty: &Typerust-analyzer cargo postgres-types 0.2.14 Type#) -> Formatrust-analyzer cargo postgres-types 0.2.14 Format# { |
| 969 | (*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self).encode_formatrust-analyzer cargo postgres-types 0.2.14 ToSql#encode_format().(ty) |
| 970 | } |
| 971 | |
| 972 | to_sql_checkedrust-analyzer cargo postgres-types 0.2.14 to_sql_checked!!(); |
| 973 | } |
| 974 | |
| 975 | impl<T: ToSqlrust-analyzer cargo postgres-types 0.2.14 ToSql#> ToSqlrust-analyzer cargo postgres-types 0.2.14 ToSql# for Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<T> { |
| 976 | fn to_sqlrust-analyzer cargo postgres-types 0.2.14 impl#[`Option<T>`][ToSql]to_sql().( |
| 977 | &self, |
| 978 | ty: &Typerust-analyzer cargo postgres-types 0.2.14 Type#, |
| 979 | out: &mut BytesMutrust-analyzer cargo bytes 1.11.1 bytes_mut/BytesMut#, |
| 980 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<IsNullrust-analyzer cargo postgres-types 0.2.14 IsNull#, Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + 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#>> { |
| 981 | match *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self { |
| 982 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ref val) => val.to_sqlrust-analyzer cargo postgres-types 0.2.14 ToSql#to_sql().(ty, out), |
| 983 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(IsNullrust-analyzer cargo postgres-types 0.2.14 IsNull#::Yesrust-analyzer cargo postgres-types 0.2.14 IsNull#Yes#), |
| 984 | } |
| 985 | } |
| 986 | |
| 987 | fn acceptsrust-analyzer cargo postgres-types 0.2.14 impl#[`Option<T>`][ToSql]accepts().(ty: &Typerust-analyzer cargo postgres-types 0.2.14 Type#) -> bool { |
| 988 | <T as ToSqlrust-analyzer cargo postgres-types 0.2.14 ToSql#>::acceptsrust-analyzer cargo postgres-types 0.2.14 ToSql#accepts().(ty) |
| 989 | } |
| 990 | |
| 991 | fn encode_formatrust-analyzer cargo postgres-types 0.2.14 impl#[`Option<T>`][ToSql]encode_format().(&self, ty: &Typerust-analyzer cargo postgres-types 0.2.14 Type#) -> Formatrust-analyzer cargo postgres-types 0.2.14 Format# { |
| 992 | match self { |
| 993 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(val) => val.encode_formatrust-analyzer cargo postgres-types 0.2.14 ToSql#encode_format().(ty), |
| 994 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => Formatrust-analyzer cargo postgres-types 0.2.14 Format#::Binaryrust-analyzer cargo postgres-types 0.2.14 Format#Binary#, |
| 995 | } |
| 996 | } |
| 997 | |
| 998 | to_sql_checkedrust-analyzer cargo postgres-types 0.2.14 to_sql_checked!!(); |
| 999 | } |
| 1000 | |
| 1001 | impl<T: ToSqlrust-analyzer cargo postgres-types 0.2.14 ToSql#> ToSqlrust-analyzer cargo postgres-types 0.2.14 ToSql# for &[T] { |
| 1002 | fn to_sqlrust-analyzer cargo postgres-types 0.2.14 impl#[`&[T]`][ToSql]to_sql().(&self, ty: &Typerust-analyzer cargo postgres-types 0.2.14 Type#, w: &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-types 0.2.14 IsNull#, Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + 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#>> { |
| 1003 | let member_type = match *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().ty.kindrust-analyzer cargo postgres-types 0.2.14 impl#[Type]kind().() { |
| 1004 | Kindrust-analyzer cargo postgres-types 0.2.14 Kind#::Arrayrust-analyzer cargo postgres-types 0.2.14 Kind#Array#(ref member) => member, |
| 1005 | _ => panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("expected array type"), |
| 1006 | }; |
| 1007 | |
| 1008 | // Arrays are normally one indexed by default but oidvector and int2vector *require* zero indexing |
| 1009 | let lower_bound = match *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().ty { |
| 1010 | Typerust-analyzer cargo postgres-types 0.2.14 Type#::OID_VECTORrust-analyzer cargo postgres-types 0.2.14 type_gen/impl#[Type]OID_VECTOR. | Typerust-analyzer cargo postgres-types 0.2.14 Type#::INT2_VECTORrust-analyzer cargo postgres-types 0.2.14 type_gen/impl#[Type]INT2_VECTOR. => 0, |
| 1011 | _ => 1, |
| 1012 | }; |
| 1013 | |
| 1014 | let dimension = ArrayDimensionrust-analyzer cargo postgres-protocol 0.6.12 types/ArrayDimension# { |
| 1015 | lenrust-analyzer cargo postgres-protocol 0.6.12 types/ArrayDimension#len.: downcastrust-analyzer cargo postgres-types 0.2.14 downcast().(self.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().())?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., |
| 1016 | lower_boundrust-analyzer cargo postgres-protocol 0.6.12 types/ArrayDimension#lower_bound., |
| 1017 | }; |
| 1018 | |
| 1019 | typesrust-analyzer cargo postgres-protocol 0.6.12 types/::array_to_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/array_to_sql().( |
| 1020 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(dimension), |
| 1021 | member_type.oidrust-analyzer cargo postgres-types 0.2.14 impl#[Type]oid().(), |
| 1022 | self.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().(), |
| 1023 | |e, w| match e.to_sqlrust-analyzer cargo postgres-types 0.2.14 ToSql#to_sql().(member_type, w)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). { |
| 1024 | IsNullrust-analyzer cargo postgres-types 0.2.14 IsNull#::Norust-analyzer cargo postgres-types 0.2.14 IsNull#No# => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(postgres_protocolrust-analyzer cargo postgres-protocol 0.6.12 crate/::IsNullrust-analyzer cargo postgres-protocol 0.6.12 IsNull#::Norust-analyzer cargo postgres-protocol 0.6.12 IsNull#No#), |
| 1025 | IsNullrust-analyzer cargo postgres-types 0.2.14 IsNull#::Yesrust-analyzer cargo postgres-types 0.2.14 IsNull#Yes# => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(postgres_protocolrust-analyzer cargo postgres-protocol 0.6.12 crate/::IsNullrust-analyzer cargo postgres-protocol 0.6.12 IsNull#::Yesrust-analyzer cargo postgres-protocol 0.6.12 IsNull#Yes#), |
| 1026 | }, |
| 1027 | w, |
| 1028 | )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 1029 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(IsNullrust-analyzer cargo postgres-types 0.2.14 IsNull#::Norust-analyzer cargo postgres-types 0.2.14 IsNull#No#) |
| 1030 | } |
| 1031 | |
| 1032 | fn acceptsrust-analyzer cargo postgres-types 0.2.14 impl#[`&[T]`][ToSql]accepts().(ty: &Typerust-analyzer cargo postgres-types 0.2.14 Type#) -> bool { |
| 1033 | match *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().ty.kindrust-analyzer cargo postgres-types 0.2.14 impl#[Type]kind().() { |
| 1034 | Kindrust-analyzer cargo postgres-types 0.2.14 Kind#::Arrayrust-analyzer cargo postgres-types 0.2.14 Kind#Array#(ref member) => T::acceptsrust-analyzer cargo postgres-types 0.2.14 ToSql#accepts().(member), |
| 1035 | _ => false, |
| 1036 | } |
| 1037 | } |
| 1038 | |
| 1039 | to_sql_checkedrust-analyzer cargo postgres-types 0.2.14 to_sql_checked!!(); |
| 1040 | } |
| 1041 | |
| 1042 | impl ToSqlrust-analyzer cargo postgres-types 0.2.14 ToSql# for &[u8] { |
| 1043 | fn to_sqlrust-analyzer cargo postgres-types 0.2.14 impl#[`&[u8]`][ToSql]to_sql().(&self, _: &Typerust-analyzer cargo postgres-types 0.2.14 Type#, w: &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-types 0.2.14 IsNull#, Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + 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#>> { |
| 1044 | typesrust-analyzer cargo postgres-protocol 0.6.12 types/::bytea_to_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/bytea_to_sql().(self, w); |
| 1045 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(IsNullrust-analyzer cargo postgres-types 0.2.14 IsNull#::Norust-analyzer cargo postgres-types 0.2.14 IsNull#No#) |
| 1046 | } |
| 1047 | |
| 1048 | acceptsrust-analyzer cargo postgres-types 0.2.14 accepts!!(BYTEArust-analyzer cargo postgres-types 0.2.14 type_gen/impl#[Type]BYTEA.); |
| 1049 | |
| 1050 | to_sql_checkedrust-analyzer cargo postgres-types 0.2.14 to_sql_checked!!(); |
| 1051 | } |
| 1052 | |
| 1053 | #[cfg(feature = "array-impls")] |
| 1054 | impl<const N: usize> ToSqlrust-analyzer cargo postgres-types 0.2.14 ToSql# for [u8; N] { |
| 1055 | fn to_sqlrust-analyzer cargo postgres-types 0.2.14 impl#[`[u8; N]`][ToSql]to_sql().(&self, _: &Typerust-analyzer cargo postgres-types 0.2.14 Type#, w: &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-types 0.2.14 IsNull#, Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + 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#>> { |
| 1056 | typesrust-analyzer cargo postgres-protocol 0.6.12 types/::bytea_to_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/bytea_to_sql().(&self[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/RangeFull#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., w); |
| 1057 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(IsNullrust-analyzer cargo postgres-types 0.2.14 IsNull#::Norust-analyzer cargo postgres-types 0.2.14 IsNull#No#) |
| 1058 | } |
| 1059 | |
| 1060 | acceptsrust-analyzer cargo postgres-types 0.2.14 accepts!!(BYTEArust-analyzer cargo postgres-types 0.2.14 type_gen/impl#[Type]BYTEA.); |
| 1061 | |
| 1062 | to_sql_checkedrust-analyzer cargo postgres-types 0.2.14 to_sql_checked!!(); |
| 1063 | } |
| 1064 | |
| 1065 | #[cfg(feature = "array-impls")] |
| 1066 | impl<T: ToSqlrust-analyzer cargo postgres-types 0.2.14 ToSql#, const N: usize> ToSqlrust-analyzer cargo postgres-types 0.2.14 ToSql# for [T; N] { |
| 1067 | fn to_sqlrust-analyzer cargo postgres-types 0.2.14 impl#[`[T; N]`][ToSql]to_sql().(&self, ty: &Typerust-analyzer cargo postgres-types 0.2.14 Type#, w: &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-types 0.2.14 IsNull#, Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + 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#>> { |
| 1068 | <&[T] as ToSqlrust-analyzer cargo postgres-types 0.2.14 ToSql#>::to_sqlrust-analyzer cargo postgres-types 0.2.14 impl#[`&[T]`][ToSql]to_sql().(&&self[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/RangeFull#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., ty, w) |
| 1069 | } |
| 1070 | |
| 1071 | fn acceptsrust-analyzer cargo postgres-types 0.2.14 impl#[`[T; N]`][ToSql]accepts().(ty: &Typerust-analyzer cargo postgres-types 0.2.14 Type#) -> bool { |
| 1072 | <&[T] as ToSqlrust-analyzer cargo postgres-types 0.2.14 ToSql#>::acceptsrust-analyzer cargo postgres-types 0.2.14 impl#[`&[T]`][ToSql]accepts().(ty) |
| 1073 | } |
| 1074 | |
| 1075 | to_sql_checkedrust-analyzer cargo postgres-types 0.2.14 to_sql_checked!!(); |
| 1076 | } |
| 1077 | |
| 1078 | impl<T: ToSqlrust-analyzer cargo postgres-types 0.2.14 ToSql#> ToSqlrust-analyzer cargo postgres-types 0.2.14 ToSql# for Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<T> { |
| 1079 | fn to_sqlrust-analyzer cargo postgres-types 0.2.14 impl#[`Vec<T>`][ToSql]to_sql().(&self, ty: &Typerust-analyzer cargo postgres-types 0.2.14 Type#, w: &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-types 0.2.14 IsNull#, Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + 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#>> { |
| 1080 | <&[T] as ToSqlrust-analyzer cargo postgres-types 0.2.14 ToSql#>::to_sqlrust-analyzer cargo postgres-types 0.2.14 impl#[`&[T]`][ToSql]to_sql().(&&*rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][Deref]deref().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self, ty, w) |
| 1081 | } |
| 1082 | |
| 1083 | fn acceptsrust-analyzer cargo postgres-types 0.2.14 impl#[`Vec<T>`][ToSql]accepts().(ty: &Typerust-analyzer cargo postgres-types 0.2.14 Type#) -> bool { |
| 1084 | <&[T] as ToSqlrust-analyzer cargo postgres-types 0.2.14 ToSql#>::acceptsrust-analyzer cargo postgres-types 0.2.14 impl#[`&[T]`][ToSql]accepts().(ty) |
| 1085 | } |
| 1086 | |
| 1087 | to_sql_checkedrust-analyzer cargo postgres-types 0.2.14 to_sql_checked!!(); |
| 1088 | } |
| 1089 | |
| 1090 | impl<T: ToSqlrust-analyzer cargo postgres-types 0.2.14 ToSql#> ToSqlrust-analyzer cargo postgres-types 0.2.14 ToSql# for Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<T> { |
| 1091 | fn to_sqlrust-analyzer cargo postgres-types 0.2.14 impl#[`Box<T>`][ToSql]to_sql().(&self, ty: &Typerust-analyzer cargo postgres-types 0.2.14 Type#, w: &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-types 0.2.14 IsNull#, Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + 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#>> { |
| 1092 | <&T as ToSqlrust-analyzer cargo postgres-types 0.2.14 ToSql#>::to_sqlrust-analyzer cargo postgres-types 0.2.14 impl#[`&T`][ToSql]to_sql().(&&*rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T, A>`][Deref]deref().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self, ty, w) |
| 1093 | } |
| 1094 | |
| 1095 | fn acceptsrust-analyzer cargo postgres-types 0.2.14 impl#[`Box<T>`][ToSql]accepts().(ty: &Typerust-analyzer cargo postgres-types 0.2.14 Type#) -> bool { |
| 1096 | <&T as ToSqlrust-analyzer cargo postgres-types 0.2.14 ToSql#>::acceptsrust-analyzer cargo postgres-types 0.2.14 impl#[`&T`][ToSql]accepts().(ty) |
| 1097 | } |
| 1098 | |
| 1099 | to_sql_checkedrust-analyzer cargo postgres-types 0.2.14 to_sql_checked!!(); |
| 1100 | } |
| 1101 | |
| 1102 | impl<T: ToSqlrust-analyzer cargo postgres-types 0.2.14 ToSql#> ToSqlrust-analyzer cargo postgres-types 0.2.14 ToSql# for Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<[T]> { |
| 1103 | fn to_sqlrust-analyzer cargo postgres-types 0.2.14 impl#[`Box<[T]>`][ToSql]to_sql().(&self, ty: &Typerust-analyzer cargo postgres-types 0.2.14 Type#, w: &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-types 0.2.14 IsNull#, Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + 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#>> { |
| 1104 | <&[T] as ToSqlrust-analyzer cargo postgres-types 0.2.14 ToSql#>::to_sqlrust-analyzer cargo postgres-types 0.2.14 impl#[`&[T]`][ToSql]to_sql().(&&*rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T, A>`][Deref]deref().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self, ty, w) |
| 1105 | } |
| 1106 | |
| 1107 | fn acceptsrust-analyzer cargo postgres-types 0.2.14 impl#[`Box<[T]>`][ToSql]accepts().(ty: &Typerust-analyzer cargo postgres-types 0.2.14 Type#) -> bool { |
| 1108 | <&[T] as ToSqlrust-analyzer cargo postgres-types 0.2.14 ToSql#>::acceptsrust-analyzer cargo postgres-types 0.2.14 impl#[`&[T]`][ToSql]accepts().(ty) |
| 1109 | } |
| 1110 | |
| 1111 | to_sql_checkedrust-analyzer cargo postgres-types 0.2.14 to_sql_checked!!(); |
| 1112 | } |
| 1113 | |
| 1114 | impl ToSqlrust-analyzer cargo postgres-types 0.2.14 ToSql# for Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#<'_, [u8]> { |
| 1115 | fn to_sqlrust-analyzer cargo postgres-types 0.2.14 impl#[`Cow<'_, [u8]>`][ToSql]to_sql().(&self, ty: &Typerust-analyzer cargo postgres-types 0.2.14 Type#, w: &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-types 0.2.14 IsNull#, Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + 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#>> { |
| 1116 | <&[u8] as ToSqlrust-analyzer cargo postgres-types 0.2.14 ToSql#>::to_sqlrust-analyzer cargo postgres-types 0.2.14 impl#[`&[u8]`][ToSql]to_sql().(&self.as_refrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/impl#[`Cow<'_, T>`][`AsRef<T>`]as_ref().(), ty, w) |
| 1117 | } |
| 1118 | |
| 1119 | fn acceptsrust-analyzer cargo postgres-types 0.2.14 impl#[`Cow<'_, [u8]>`][ToSql]accepts().(ty: &Typerust-analyzer cargo postgres-types 0.2.14 Type#) -> bool { |
| 1120 | <&[u8] as ToSqlrust-analyzer cargo postgres-types 0.2.14 ToSql#>::acceptsrust-analyzer cargo postgres-types 0.2.14 impl#[`&[u8]`][ToSql]accepts().(ty) |
| 1121 | } |
| 1122 | |
| 1123 | to_sql_checkedrust-analyzer cargo postgres-types 0.2.14 to_sql_checked!!(); |
| 1124 | } |
| 1125 | |
| 1126 | impl ToSqlrust-analyzer cargo postgres-types 0.2.14 ToSql# for Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8> { |
| 1127 | fn to_sqlrust-analyzer cargo postgres-types 0.2.14 impl#[`Vec<u8>`][ToSql]to_sql().(&self, ty: &Typerust-analyzer cargo postgres-types 0.2.14 Type#, w: &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-types 0.2.14 IsNull#, Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + 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#>> { |
| 1128 | <&[u8] as ToSqlrust-analyzer cargo postgres-types 0.2.14 ToSql#>::to_sqlrust-analyzer cargo postgres-types 0.2.14 impl#[`&[u8]`][ToSql]to_sql().(&&*rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][Deref]deref().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self, ty, w) |
| 1129 | } |
| 1130 | |
| 1131 | fn acceptsrust-analyzer cargo postgres-types 0.2.14 impl#[`Vec<u8>`][ToSql]accepts().(ty: &Typerust-analyzer cargo postgres-types 0.2.14 Type#) -> bool { |
| 1132 | <&[u8] as ToSqlrust-analyzer cargo postgres-types 0.2.14 ToSql#>::acceptsrust-analyzer cargo postgres-types 0.2.14 impl#[`&[u8]`][ToSql]accepts().(ty) |
| 1133 | } |
| 1134 | |
| 1135 | to_sql_checkedrust-analyzer cargo postgres-types 0.2.14 to_sql_checked!!(); |
| 1136 | } |
| 1137 | |
| 1138 | impl ToSqlrust-analyzer cargo postgres-types 0.2.14 ToSql# for &str { |
| 1139 | fn to_sqlrust-analyzer cargo postgres-types 0.2.14 impl#[`&str`][ToSql]to_sql().(&self, ty: &Typerust-analyzer cargo postgres-types 0.2.14 Type#, w: &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-types 0.2.14 IsNull#, Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + 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#>> { |
| 1140 | match ty.namerust-analyzer cargo postgres-types 0.2.14 impl#[Type]name().() { |
| 1141 | "ltree" => typesrust-analyzer cargo postgres-protocol 0.6.12 types/::ltree_to_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/ltree_to_sql().(self, w), |
| 1142 | "lquery" => typesrust-analyzer cargo postgres-protocol 0.6.12 types/::lquery_to_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/lquery_to_sql().(self, w), |
| 1143 | "ltxtquery" => typesrust-analyzer cargo postgres-protocol 0.6.12 types/::ltxtquery_to_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/ltxtquery_to_sql().(self, w), |
| 1144 | _ => typesrust-analyzer cargo postgres-protocol 0.6.12 types/::text_to_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/text_to_sql().(self, w), |
| 1145 | } |
| 1146 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(IsNullrust-analyzer cargo postgres-types 0.2.14 IsNull#::Norust-analyzer cargo postgres-types 0.2.14 IsNull#No#) |
| 1147 | } |
| 1148 | |
| 1149 | fn acceptsrust-analyzer cargo postgres-types 0.2.14 impl#[`&str`][ToSql]accepts().(ty: &Typerust-analyzer cargo postgres-types 0.2.14 Type#) -> bool { |
| 1150 | matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!( |
| 1151 | *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().ty, |
| 1152 | Typerust-analyzer cargo postgres-types 0.2.14 Type#::VARCHARrust-analyzer cargo postgres-types 0.2.14 type_gen/impl#[Type]VARCHAR. | Typerust-analyzer cargo postgres-types 0.2.14 Type#::TEXTrust-analyzer cargo postgres-types 0.2.14 type_gen/impl#[Type]TEXT. | Typerust-analyzer cargo postgres-types 0.2.14 Type#::BPCHARrust-analyzer cargo postgres-types 0.2.14 type_gen/impl#[Type]BPCHAR. | Typerust-analyzer cargo postgres-types 0.2.14 Type#::NAMErust-analyzer cargo postgres-types 0.2.14 type_gen/impl#[Type]NAME. | Typerust-analyzer cargo postgres-types 0.2.14 Type#::UNKNOWNrust-analyzer cargo postgres-types 0.2.14 type_gen/impl#[Type]UNKNOWN. |
| 1153 | ) || matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!(ty.namerust-analyzer cargo postgres-types 0.2.14 impl#[Type]name().(), "citext" | "ltree" | "lquery" | "ltxtquery") |
| 1154 | } |
| 1155 | |
| 1156 | to_sql_checkedrust-analyzer cargo postgres-types 0.2.14 to_sql_checked!!(); |
| 1157 | } |
| 1158 | |
| 1159 | impl ToSqlrust-analyzer cargo postgres-types 0.2.14 ToSql# for Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#<'_, str> { |
| 1160 | fn to_sqlrust-analyzer cargo postgres-types 0.2.14 impl#[`Cow<'_, str>`][ToSql]to_sql().(&self, ty: &Typerust-analyzer cargo postgres-types 0.2.14 Type#, w: &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-types 0.2.14 IsNull#, Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + 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#>> { |
| 1161 | <&str as ToSqlrust-analyzer cargo postgres-types 0.2.14 ToSql#>::to_sqlrust-analyzer cargo postgres-types 0.2.14 impl#[`&str`][ToSql]to_sql().(&self.as_refrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/impl#[`Cow<'_, T>`][`AsRef<T>`]as_ref().(), ty, w) |
| 1162 | } |
| 1163 | |
| 1164 | fn acceptsrust-analyzer cargo postgres-types 0.2.14 impl#[`Cow<'_, str>`][ToSql]accepts().(ty: &Typerust-analyzer cargo postgres-types 0.2.14 Type#) -> bool { |
| 1165 | <&str as ToSqlrust-analyzer cargo postgres-types 0.2.14 ToSql#>::acceptsrust-analyzer cargo postgres-types 0.2.14 impl#[`&str`][ToSql]accepts().(ty) |
| 1166 | } |
| 1167 | |
| 1168 | to_sql_checkedrust-analyzer cargo postgres-types 0.2.14 to_sql_checked!!(); |
| 1169 | } |
| 1170 | |
| 1171 | impl ToSqlrust-analyzer cargo postgres-types 0.2.14 ToSql# for Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# { |
| 1172 | fn to_sqlrust-analyzer cargo postgres-types 0.2.14 impl#[String][ToSql]to_sql().(&self, ty: &Typerust-analyzer cargo postgres-types 0.2.14 Type#, w: &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-types 0.2.14 IsNull#, Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + 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#>> { |
| 1173 | <&str as ToSqlrust-analyzer cargo postgres-types 0.2.14 ToSql#>::to_sqlrust-analyzer cargo postgres-types 0.2.14 impl#[`&str`][ToSql]to_sql().(&&*rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Deref]deref().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self, ty, w) |
| 1174 | } |
| 1175 | |
| 1176 | fn acceptsrust-analyzer cargo postgres-types 0.2.14 impl#[String][ToSql]accepts().(ty: &Typerust-analyzer cargo postgres-types 0.2.14 Type#) -> bool { |
| 1177 | <&str as ToSqlrust-analyzer cargo postgres-types 0.2.14 ToSql#>::acceptsrust-analyzer cargo postgres-types 0.2.14 impl#[`&str`][ToSql]accepts().(ty) |
| 1178 | } |
| 1179 | |
| 1180 | to_sql_checkedrust-analyzer cargo postgres-types 0.2.14 to_sql_checked!!(); |
| 1181 | } |
| 1182 | |
| 1183 | impl ToSqlrust-analyzer cargo postgres-types 0.2.14 ToSql# for Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<str> { |
| 1184 | fn to_sqlrust-analyzer cargo postgres-types 0.2.14 impl#[`Box<str>`][ToSql]to_sql().(&self, ty: &Typerust-analyzer cargo postgres-types 0.2.14 Type#, w: &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-types 0.2.14 IsNull#, Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + 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#>> { |
| 1185 | <&str as ToSqlrust-analyzer cargo postgres-types 0.2.14 ToSql#>::to_sqlrust-analyzer cargo postgres-types 0.2.14 impl#[`&str`][ToSql]to_sql().(&&*rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T, A>`][Deref]deref().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self, ty, w) |
| 1186 | } |
| 1187 | |
| 1188 | fn acceptsrust-analyzer cargo postgres-types 0.2.14 impl#[`Box<str>`][ToSql]accepts().(ty: &Typerust-analyzer cargo postgres-types 0.2.14 Type#) -> bool { |
| 1189 | <&str as ToSqlrust-analyzer cargo postgres-types 0.2.14 ToSql#>::acceptsrust-analyzer cargo postgres-types 0.2.14 impl#[`&str`][ToSql]accepts().(ty) |
| 1190 | } |
| 1191 | |
| 1192 | to_sql_checkedrust-analyzer cargo postgres-types 0.2.14 to_sql_checked!!(); |
| 1193 | } |
| 1194 | |
| 1195 | macro_rules! simple_torust-analyzer cargo postgres-types 0.2.14 simple_to! { |
| 1196 | ($t:ty, $f:ident, $($expected:ident),+) => { |
| 1197 | impl ToSql for $t { |
| 1198 | fn to_sql(&self, |
| 1199 | _: &Type, |
| 1200 | w: &mut BytesMut) |
| 1201 | -> Result<IsNull, Box<dyn Error + Sync + Send>> { |
| 1202 | types::$f(*self, w); |
| 1203 | Ok(IsNull::No) |
| 1204 | } |
| 1205 | |
| 1206 | accepts!($($expected),+); |
| 1207 | |
| 1208 | to_sql_checked!(); |
| 1209 | } |
| 1210 | } |
| 1211 | } |
| 1212 | |
| 1213 | simple_torust-analyzer cargo postgres-types 0.2.14 simple_to!!(bool, bool_to_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/bool_to_sql()., BOOLrust-analyzer cargo postgres-types 0.2.14 type_gen/impl#[Type]BOOL.); |
| 1214 | simple_torust-analyzer cargo postgres-types 0.2.14 simple_to!!(i8, char_to_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/char_to_sql()., CHARrust-analyzer cargo postgres-types 0.2.14 type_gen/impl#[Type]CHAR.); |
| 1215 | simple_torust-analyzer cargo postgres-types 0.2.14 simple_to!!(i16, int2_to_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/int2_to_sql()., INT2rust-analyzer cargo postgres-types 0.2.14 type_gen/impl#[Type]INT2.); |
| 1216 | simple_torust-analyzer cargo postgres-types 0.2.14 simple_to!!(i32, int4_to_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/int4_to_sql()., INT4rust-analyzer cargo postgres-types 0.2.14 type_gen/impl#[Type]INT4.); |
| 1217 | simple_torust-analyzer cargo postgres-types 0.2.14 simple_to!!(u32, oid_to_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/oid_to_sql()., OIDrust-analyzer cargo postgres-types 0.2.14 type_gen/impl#[Type]OID.); |
| 1218 | simple_torust-analyzer cargo postgres-types 0.2.14 simple_to!!(i64, int8_to_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/int8_to_sql()., INT8rust-analyzer cargo postgres-types 0.2.14 type_gen/impl#[Type]INT8.); |
| 1219 | simple_torust-analyzer cargo postgres-types 0.2.14 simple_to!!(f32, float4_to_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/float4_to_sql()., FLOAT4rust-analyzer cargo postgres-types 0.2.14 type_gen/impl#[Type]FLOAT4.); |
| 1220 | simple_torust-analyzer cargo postgres-types 0.2.14 simple_to!!(f64, float8_to_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/float8_to_sql()., FLOAT8rust-analyzer cargo postgres-types 0.2.14 type_gen/impl#[Type]FLOAT8.); |
| 1221 | |
| 1222 | impl<H> ToSqlrust-analyzer cargo postgres-types 0.2.14 ToSql# for HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>, H> |
| 1223 | where |
| 1224 | H: BuildHasherrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/BuildHasher#, |
| 1225 | { |
| 1226 | fn to_sqlrust-analyzer cargo postgres-types 0.2.14 impl#[`HashMap<String, Option<String>, H>`][ToSql]to_sql().(&self, _: &Typerust-analyzer cargo postgres-types 0.2.14 Type#, w: &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-types 0.2.14 IsNull#, Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + 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#>> { |
| 1227 | typesrust-analyzer cargo postgres-protocol 0.6.12 types/::hstore_to_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/hstore_to_sql().( |
| 1228 | self.iterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]iter().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|(k, v)| (&*rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Deref]deref().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().k, v.as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|v| &*rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Deref]deref().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().v))), |
| 1229 | w, |
| 1230 | )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 1231 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(IsNullrust-analyzer cargo postgres-types 0.2.14 IsNull#::Norust-analyzer cargo postgres-types 0.2.14 IsNull#No#) |
| 1232 | } |
| 1233 | |
| 1234 | fn acceptsrust-analyzer cargo postgres-types 0.2.14 impl#[`HashMap<String, Option<String>, H>`][ToSql]accepts().(ty: &Typerust-analyzer cargo postgres-types 0.2.14 Type#) -> bool { |
| 1235 | ty.namerust-analyzer cargo postgres-types 0.2.14 impl#[Type]name().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq()."hstore" |
| 1236 | } |
| 1237 | |
| 1238 | to_sql_checkedrust-analyzer cargo postgres-types 0.2.14 to_sql_checked!!(); |
| 1239 | } |
| 1240 | |
| 1241 | impl ToSqlrust-analyzer cargo postgres-types 0.2.14 ToSql# for SystemTimerust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/SystemTime# { |
| 1242 | fn to_sqlrust-analyzer cargo postgres-types 0.2.14 impl#[SystemTime][ToSql]to_sql().(&self, _: &Typerust-analyzer cargo postgres-types 0.2.14 Type#, w: &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-types 0.2.14 IsNull#, Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + 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#>> { |
| 1243 | let epoch = UNIX_EPOCHrust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/UNIX_EPOCH. rust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/impl#[SystemTime][`Add<Duration>`]add().+rust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/impl#[SystemTime][`Add<Duration>`]add(). rust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/impl#[SystemTime][`Add<Duration>`]add().Durationrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/Duration#::from_secsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/impl#[Duration]from_secs().(TIME_SEC_CONVERSIONrust-analyzer cargo postgres-types 0.2.14 TIME_SEC_CONVERSION.); |
| 1244 | |
| 1245 | let to_usec = |
| 1246 | |d: Durationrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/Duration#| d.as_secsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/impl#[Duration]as_secs().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul().USEC_PER_SECrust-analyzer cargo postgres-types 0.2.14 USEC_PER_SEC. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Add<Self>`]add().u64::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[u64][`From<u32>`]from().(d.subsec_nanosrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/impl#[Duration]subsec_nanos().()) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Div<Self>`]div().NSEC_PER_USECrust-analyzer cargo postgres-types 0.2.14 NSEC_PER_USEC.; |
| 1247 | |
| 1248 | let time = match self.duration_sincerust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/impl#[SystemTime]duration_since().(epoch) { |
| 1249 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(duration) => to_usec(duration) as i64, |
| 1250 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(e) => -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][Neg]neg().(to_usec(e.durationrust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/impl#[SystemTimeError]duration().()) as i64), |
| 1251 | }; |
| 1252 | |
| 1253 | typesrust-analyzer cargo postgres-protocol 0.6.12 types/::timestamp_to_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/timestamp_to_sql().(time, w); |
| 1254 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(IsNullrust-analyzer cargo postgres-types 0.2.14 IsNull#::Norust-analyzer cargo postgres-types 0.2.14 IsNull#No#) |
| 1255 | } |
| 1256 | |
| 1257 | acceptsrust-analyzer cargo postgres-types 0.2.14 accepts!!(TIMESTAMPrust-analyzer cargo postgres-types 0.2.14 type_gen/impl#[Type]TIMESTAMP., TIMESTAMPTZrust-analyzer cargo postgres-types 0.2.14 type_gen/impl#[Type]TIMESTAMPTZ.); |
| 1258 | |
| 1259 | to_sql_checkedrust-analyzer cargo postgres-types 0.2.14 to_sql_checked!!(); |
| 1260 | } |
| 1261 | |
| 1262 | impl ToSqlrust-analyzer cargo postgres-types 0.2.14 ToSql# for IpAddrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/ip_addr/IpAddr# { |
| 1263 | fn to_sqlrust-analyzer cargo postgres-types 0.2.14 impl#[IpAddr][ToSql]to_sql().(&self, _: &Typerust-analyzer cargo postgres-types 0.2.14 Type#, w: &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-types 0.2.14 IsNull#, Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + 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#>> { |
| 1264 | let netmask = match self { |
| 1265 | 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#(_) => 32, |
| 1266 | 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#(_) => 128, |
| 1267 | }; |
| 1268 | typesrust-analyzer cargo postgres-protocol 0.6.12 types/::inet_to_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/inet_to_sql().(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self, netmask, w); |
| 1269 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(IsNullrust-analyzer cargo postgres-types 0.2.14 IsNull#::Norust-analyzer cargo postgres-types 0.2.14 IsNull#No#) |
| 1270 | } |
| 1271 | |
| 1272 | acceptsrust-analyzer cargo postgres-types 0.2.14 accepts!!(INETrust-analyzer cargo postgres-types 0.2.14 type_gen/impl#[Type]INET.); |
| 1273 | |
| 1274 | to_sql_checkedrust-analyzer cargo postgres-types 0.2.14 to_sql_checked!!(); |
| 1275 | } |
| 1276 | |
| 1277 | fn downcastrust-analyzer cargo postgres-types 0.2.14 downcast().(len: usize) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<i32, Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + 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#>> { |
| 1278 | if len rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().i32::MAXrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[i32]MAX. as usize { |
| 1279 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("value too large to transmit".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()) |
| 1280 | } else { |
| 1281 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(len as i32) |
| 1282 | } |
| 1283 | } |
| 1284 | |
| 1285 | mod sealedrust-analyzer cargo postgres-types 0.2.14 sealed/ { |
| 1286 | pub trait Sealedrust-analyzer cargo postgres-types 0.2.14 sealed/Sealed# {} |
| 1287 | } |
| 1288 | |
| 1289 | /// A trait used by clients to abstract over `&dyn ToSql` and `T: ToSql`. |
| 1290 | /// |
| 1291 | /// This cannot be implemented outside of this crate. |
| 1292 | pub trait BorrowToSqlrust-analyzer cargo postgres-types 0.2.14 BorrowToSql#: sealedrust-analyzer cargo postgres-types 0.2.14 sealed/::Sealedrust-analyzer cargo postgres-types 0.2.14 sealed/Sealed# { |
| 1293 | /// Returns a reference to `self` as a `ToSql` trait object. |
| 1294 | fn borrow_to_sqlrust-analyzer cargo postgres-types 0.2.14 BorrowToSql#borrow_to_sql().(&self) -> &dyn ToSqlrust-analyzer cargo postgres-types 0.2.14 ToSql#; |
| 1295 | } |
| 1296 | |
| 1297 | impl sealedrust-analyzer cargo postgres-types 0.2.14 sealed/::Sealedrust-analyzer cargo postgres-types 0.2.14 sealed/Sealed# for &dyn ToSqlrust-analyzer cargo postgres-types 0.2.14 ToSql# {} |
| 1298 | |
| 1299 | impl BorrowToSqlrust-analyzer cargo postgres-types 0.2.14 BorrowToSql# for &dyn ToSqlrust-analyzer cargo postgres-types 0.2.14 ToSql# { |
| 1300 | #[inline] |
| 1301 | fn borrow_to_sqlrust-analyzer cargo postgres-types 0.2.14 impl#[`&(dyn ToSql + 'static)`][BorrowToSql]borrow_to_sql().(&self) -> &dyn ToSqlrust-analyzer cargo postgres-types 0.2.14 ToSql# { |
| 1302 | *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self |
| 1303 | } |
| 1304 | } |
| 1305 | |
| 1306 | impl sealedrust-analyzer cargo postgres-types 0.2.14 sealed/::Sealedrust-analyzer cargo postgres-types 0.2.14 sealed/Sealed# for Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn ToSqlrust-analyzer cargo postgres-types 0.2.14 ToSql# + Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync# + '_> {} |
| 1307 | |
| 1308 | impl BorrowToSqlrust-analyzer cargo postgres-types 0.2.14 BorrowToSql# for Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn ToSqlrust-analyzer cargo postgres-types 0.2.14 ToSql# + Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync# + '_> { |
| 1309 | #[inline] |
| 1310 | fn borrow_to_sqlrust-analyzer cargo postgres-types 0.2.14 impl#[`Box<dyn ToSql + Sync>`][BorrowToSql]borrow_to_sql().(&self) -> &dyn ToSqlrust-analyzer cargo postgres-types 0.2.14 ToSql# { |
| 1311 | self.as_refrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T, A>`][`AsRef<T>`]as_ref().() |
| 1312 | } |
| 1313 | } |
| 1314 | |
| 1315 | impl sealedrust-analyzer cargo postgres-types 0.2.14 sealed/::Sealedrust-analyzer cargo postgres-types 0.2.14 sealed/Sealed# for Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn ToSqlrust-analyzer cargo postgres-types 0.2.14 ToSql# + 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# + '_> {} |
| 1316 | impl BorrowToSqlrust-analyzer cargo postgres-types 0.2.14 BorrowToSql# for Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn ToSqlrust-analyzer cargo postgres-types 0.2.14 ToSql# + 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# + '_> { |
| 1317 | #[inline] |
| 1318 | fn borrow_to_sqlrust-analyzer cargo postgres-types 0.2.14 impl#[`Box<dyn ToSql + Send + Sync>`][BorrowToSql]borrow_to_sql().(&self) -> &dyn ToSqlrust-analyzer cargo postgres-types 0.2.14 ToSql# { |
| 1319 | self.as_refrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T, A>`][`AsRef<T>`]as_ref().() |
| 1320 | } |
| 1321 | } |
| 1322 | |
| 1323 | impl sealedrust-analyzer cargo postgres-types 0.2.14 sealed/::Sealedrust-analyzer cargo postgres-types 0.2.14 sealed/Sealed# for &(dyn ToSqlrust-analyzer cargo postgres-types 0.2.14 ToSql# + Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync#) {} |
| 1324 | |
| 1325 | /// In async contexts it is sometimes necessary to have the additional |
| 1326 | /// Sync requirement on parameters for queries since this enables the |
| 1327 | /// resulting Futures to be Send, hence usable in, e.g., tokio::spawn. |
| 1328 | /// This instance is provided for those cases. |
| 1329 | impl BorrowToSqlrust-analyzer cargo postgres-types 0.2.14 BorrowToSql# for &(dyn ToSqlrust-analyzer cargo postgres-types 0.2.14 ToSql# + Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync#) { |
| 1330 | #[inline] |
| 1331 | fn borrow_to_sqlrust-analyzer cargo postgres-types 0.2.14 impl#[`&(dyn ToSql + Sync + 'static)`][BorrowToSql]borrow_to_sql().(&self) -> &dyn ToSqlrust-analyzer cargo postgres-types 0.2.14 ToSql# { |
| 1332 | *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self |
| 1333 | } |
| 1334 | } |
| 1335 | |
| 1336 | impl<T> sealedrust-analyzer cargo postgres-types 0.2.14 sealed/::Sealedrust-analyzer cargo postgres-types 0.2.14 sealed/Sealed# for T where T: ToSqlrust-analyzer cargo postgres-types 0.2.14 ToSql# {} |
| 1337 | |
| 1338 | impl<T> BorrowToSqlrust-analyzer cargo postgres-types 0.2.14 BorrowToSql# for T |
| 1339 | where |
| 1340 | T: ToSqlrust-analyzer cargo postgres-types 0.2.14 ToSql#, |
| 1341 | { |
| 1342 | #[inline] |
| 1343 | fn borrow_to_sqlrust-analyzer cargo postgres-types 0.2.14 impl#[T][BorrowToSql]borrow_to_sql().(&self) -> &dyn ToSqlrust-analyzer cargo postgres-types 0.2.14 ToSql# { |
| 1344 | self |
| 1345 | } |
| 1346 | } |