| 1 | use craterust-analyzer cargo sqlx-postgres 0.8.3 crate/::decoderust-analyzer cargo sqlx-core 0.8.3 decode/::Decoderust-analyzer cargo sqlx-core 0.8.3 decode/Decode#; |
| 2 | use craterust-analyzer cargo sqlx-postgres 0.8.3 crate/::encoderust-analyzer cargo sqlx-core 0.8.3 encode/::{Encoderust-analyzer cargo sqlx-core 0.8.3 encode/Encode#, IsNullrust-analyzer cargo sqlx-core 0.8.3 encode/IsNull#}; |
| 3 | use craterust-analyzer cargo sqlx-postgres 0.8.3 crate/::errorrust-analyzer cargo sqlx-postgres 0.8.3 error/::BoxDynErrorrust-analyzer cargo sqlx-core 0.8.3 error/BoxDynError#; |
| 4 | use craterust-analyzer cargo sqlx-postgres 0.8.3 crate/::typesrust-analyzer cargo sqlx-postgres 0.8.3 types/::Typerust-analyzer cargo sqlx-core 0.8.3 types/Type#; |
| 5 | use craterust-analyzer cargo sqlx-postgres 0.8.3 crate/::{PgArgumentBufferrust-analyzer cargo sqlx-postgres 0.8.3 arguments/PgArgumentBuffer#, PgHasArrayTyperust-analyzer cargo sqlx-postgres 0.8.3 types/array/PgHasArrayType#, PgTypeInforust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgTypeInfo#, PgValueFormatrust-analyzer cargo sqlx-postgres 0.8.3 value/PgValueFormat#, PgValueRefrust-analyzer cargo sqlx-postgres 0.8.3 value/PgValueRef#, Postgresrust-analyzer cargo sqlx-postgres 0.8.3 database/Postgres#}; |
| 6 | use byteorderrust-analyzer cargo byteorder 1.5.0 crate/::{BigEndianrust-analyzer cargo byteorder 1.5.0 BigEndian#, ReadBytesExtrust-analyzer cargo byteorder 1.5.0 io/ReadBytesExt#}; |
| 7 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Cursorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/cursor/Cursor#; |
| 8 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/; |
| 9 | |
| 10 | #[cfg(feature = "time")] |
| 11 | type DefaultTimerust-analyzer cargo sqlx-postgres 0.8.3 types/time_tz/DefaultTime# = ::timerust-analyzer cargo time 0.3.55 crate/::Timerust-analyzer cargo time 0.3.55 time/Time#; |
| 12 | |
| 13 | #[cfg(all(not(feature = "time"), feature = "chrono"))] |
| 14 | type DefaultTime = ::chronorust-analyzer cargo chrono 0.4.45 crate/::NaiveTimerust-analyzer cargo chrono 0.4.45 naive/time/NaiveTime#; |
| 15 | |
| 16 | #[cfg(feature = "time")] |
| 17 | type DefaultOffsetrust-analyzer cargo sqlx-postgres 0.8.3 types/time_tz/DefaultOffset# = ::timerust-analyzer cargo time 0.3.55 crate/::UtcOffsetrust-analyzer cargo time 0.3.55 utc_offset/UtcOffset#; |
| 18 | |
| 19 | #[cfg(all(not(feature = "time"), feature = "chrono"))] |
| 20 | type DefaultOffset = ::chronorust-analyzer cargo chrono 0.4.45 crate/::FixedOffsetrust-analyzer cargo chrono 0.4.45 offset/fixed/FixedOffset#; |
| 21 | |
| 22 | /// Represents a moment of time, in a specified timezone. |
| 23 | /// |
| 24 | /// # Warning |
| 25 | /// |
| 26 | /// `PgTimeTz` provides `TIMETZ` and is supported only for reading from legacy databases. |
| 27 | /// [PostgreSQL recommends] to use `TIMESTAMPTZ` instead. |
| 28 | /// |
| 29 | /// [PostgreSQL recommends]: https://wiki.postgresql.org/wiki/Don't_Do_This#Don.27t_use_timetz |
| 30 | #[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:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, 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:)] |
| 31 | pub struct PgTimeTzrust-analyzer cargo sqlx-postgres 0.8.3 types/time_tz/PgTimeTz#<Time = DefaultTimerust-analyzer cargo sqlx-postgres 0.8.3 types/time_tz/DefaultTime#, Offset = DefaultOffsetrust-analyzer cargo sqlx-postgres 0.8.3 types/time_tz/DefaultOffset#> { |
| 32 | pub timerust-analyzer cargo sqlx-postgres 0.8.3 types/time_tz/PgTimeTz#time.: Time, |
| 33 | pub offsetrust-analyzer cargo sqlx-postgres 0.8.3 types/time_tz/PgTimeTz#offset.: Offset, |
| 34 | } |
| 35 | |
| 36 | impl<Time, Offset> PgHasArrayTyperust-analyzer cargo sqlx-postgres 0.8.3 types/array/PgHasArrayType# for PgTimeTzrust-analyzer cargo sqlx-postgres 0.8.3 types/time_tz/PgTimeTz#<Time, Offset> { |
| 37 | fn array_type_inforust-analyzer cargo sqlx-postgres 0.8.3 types/time_tz/impl#[`PgTimeTz<Time, Offset>`][PgHasArrayType]array_type_info().() -> PgTypeInforust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgTypeInfo# { |
| 38 | PgTypeInforust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgTypeInfo#::TIMETZ_ARRAYrust-analyzer cargo sqlx-postgres 0.8.3 type_info/impl#[PgTypeInfo]TIMETZ_ARRAY. |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | #[cfg(feature = "chrono")] |
| 43 | mod chronorust-analyzer cargo sqlx-postgres 0.8.3 types/time_tz/chrono/ { |
| 44 | use superrust-analyzer cargo sqlx-postgres 0.8.3 types/time_tz/::*; |
| 45 | use ::chronorust-analyzer cargo chrono 0.4.45 crate/::{DateTimerust-analyzer cargo chrono 0.4.45 datetime/DateTime#, Durationrust-analyzer cargo chrono 0.4.45 Duration#, FixedOffsetrust-analyzer cargo chrono 0.4.45 offset/fixed/FixedOffset#, NaiveTimerust-analyzer cargo chrono 0.4.45 naive/time/NaiveTime#}; |
| 46 | |
| 47 | impl Typerust-analyzer cargo sqlx-core 0.8.3 types/Type#<Postgresrust-analyzer cargo sqlx-postgres 0.8.3 database/Postgres#> for PgTimeTzrust-analyzer cargo sqlx-postgres 0.8.3 types/time_tz/PgTimeTz#<NaiveTimerust-analyzer cargo chrono 0.4.45 naive/time/NaiveTime#, FixedOffsetrust-analyzer cargo chrono 0.4.45 offset/fixed/FixedOffset#> { |
| 48 | fn type_inforust-analyzer cargo sqlx-postgres 0.8.3 types/time_tz/chrono/impl#[`PgTimeTz<NaiveTime, FixedOffset>`][`Type<Postgres>`]type_info().() -> PgTypeInforust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgTypeInfo# { |
| 49 | PgTypeInforust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgTypeInfo#::TIMETZrust-analyzer cargo sqlx-postgres 0.8.3 type_info/impl#[PgTypeInfo]TIMETZ. |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | impl Encoderust-analyzer cargo sqlx-core 0.8.3 encode/Encode#<'_, Postgresrust-analyzer cargo sqlx-postgres 0.8.3 database/Postgres#> for PgTimeTzrust-analyzer cargo sqlx-postgres 0.8.3 types/time_tz/PgTimeTz#<NaiveTimerust-analyzer cargo chrono 0.4.45 naive/time/NaiveTime#, FixedOffsetrust-analyzer cargo chrono 0.4.45 offset/fixed/FixedOffset#> { |
| 54 | fn encode_by_refrust-analyzer cargo sqlx-postgres 0.8.3 types/time_tz/chrono/impl#[`PgTimeTz<NaiveTime, FixedOffset>`][`Encode<'_, Postgres>`]encode_by_ref().(&self, buf: &mut PgArgumentBufferrust-analyzer cargo sqlx-postgres 0.8.3 arguments/PgArgumentBuffer#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<IsNullrust-analyzer cargo sqlx-core 0.8.3 encode/IsNull#, BoxDynErrorrust-analyzer cargo sqlx-core 0.8.3 error/BoxDynError#> { |
| 55 | let _: IsNullrust-analyzer cargo sqlx-core 0.8.3 encode/IsNull# = <NaiveTimerust-analyzer cargo chrono 0.4.45 naive/time/NaiveTime# as Encoderust-analyzer cargo sqlx-core 0.8.3 encode/Encode#<'_, Postgresrust-analyzer cargo sqlx-postgres 0.8.3 database/Postgres#>>::encoderust-analyzer cargo sqlx-core 0.8.3 encode/Encode#encode().(self.timerust-analyzer cargo sqlx-postgres 0.8.3 types/time_tz/PgTimeTz#time., buf)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 56 | let _: IsNullrust-analyzer cargo sqlx-core 0.8.3 encode/IsNull# = |
| 57 | <i32 as Encoderust-analyzer cargo sqlx-core 0.8.3 encode/Encode#<'_, Postgresrust-analyzer cargo sqlx-postgres 0.8.3 database/Postgres#>>::encoderust-analyzer cargo sqlx-core 0.8.3 encode/Encode#encode().(self.offsetrust-analyzer cargo sqlx-postgres 0.8.3 types/time_tz/PgTimeTz#offset..utc_minus_localrust-analyzer cargo chrono 0.4.45 offset/fixed/impl#[FixedOffset]utc_minus_local().(), buf)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 58 | |
| 59 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(IsNullrust-analyzer cargo sqlx-core 0.8.3 encode/IsNull#::Norust-analyzer cargo sqlx-core 0.8.3 encode/IsNull#No#) |
| 60 | } |
| 61 | |
| 62 | fn size_hintrust-analyzer cargo sqlx-postgres 0.8.3 types/time_tz/chrono/impl#[`PgTimeTz<NaiveTime, FixedOffset>`][`Encode<'_, Postgres>`]size_hint().(&self) -> usize { |
| 63 | memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::size_ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/size_of().::<i64>() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::size_ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/size_of().::<i32>() |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | impl<'r> Decoderust-analyzer cargo sqlx-core 0.8.3 decode/Decode#<'r, Postgresrust-analyzer cargo sqlx-postgres 0.8.3 database/Postgres#> for PgTimeTzrust-analyzer cargo sqlx-postgres 0.8.3 types/time_tz/PgTimeTz#<NaiveTimerust-analyzer cargo chrono 0.4.45 naive/time/NaiveTime#, FixedOffsetrust-analyzer cargo chrono 0.4.45 offset/fixed/FixedOffset#> { |
| 68 | fn decoderust-analyzer cargo sqlx-postgres 0.8.3 types/time_tz/chrono/impl#[`PgTimeTz<NaiveTime, FixedOffset>`][`Decode<'r, Postgres>`]decode().(value: PgValueRefrust-analyzer cargo sqlx-postgres 0.8.3 value/PgValueRef#<'r>) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo sqlx-postgres 0.8.3 types/time_tz/chrono/impl#[`PgTimeTz<NaiveTime, FixedOffset>`][`Decode<'r, Postgres>`], BoxDynErrorrust-analyzer cargo sqlx-core 0.8.3 error/BoxDynError#> { |
| 69 | match value.formatrust-analyzer cargo sqlx-postgres 0.8.3 value/impl#[`PgValueRef<'r>`]format().() { |
| 70 | PgValueFormatrust-analyzer cargo sqlx-postgres 0.8.3 value/PgValueFormat#::Binaryrust-analyzer cargo sqlx-postgres 0.8.3 value/PgValueFormat#Binary# => { |
| 71 | let mut buf = Cursorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/cursor/Cursor#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/cursor/impl#[`Cursor<T>`]new().(value.as_bytesrust-analyzer cargo sqlx-postgres 0.8.3 value/impl#[`PgValueRef<'r>`]as_bytes().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().); |
| 72 | |
| 73 | // TIME is encoded as the microseconds since midnight |
| 74 | let us = buf.read_i64rust-analyzer cargo byteorder 1.5.0 io/ReadBytesExt#read_i64().::<BigEndianrust-analyzer cargo byteorder 1.5.0 BigEndian#>()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 75 | // default is midnight, there is a canary test for this |
| 76 | // in `sqlx-postgres/src/types/chrono/time.rs` |
| 77 | let time = NaiveTimerust-analyzer cargo chrono 0.4.45 naive/time/NaiveTime#::defaultrust-analyzer cargo chrono 0.4.45 naive/time/impl#[NaiveTime][Default]default().() rust-analyzer cargo chrono 0.4.45 naive/time/impl#[NaiveTime][`Add<TimeDelta>`]add().+rust-analyzer cargo chrono 0.4.45 naive/time/impl#[NaiveTime][`Add<TimeDelta>`]add(). rust-analyzer cargo chrono 0.4.45 naive/time/impl#[NaiveTime][`Add<TimeDelta>`]add().Durationrust-analyzer cargo chrono 0.4.45 Duration#::microsecondsrust-analyzer cargo chrono 0.4.45 time_delta/impl#[TimeDelta]microseconds().(us); |
| 78 | |
| 79 | // OFFSET is encoded as seconds from UTC |
| 80 | let offset_seconds = buf.read_i32rust-analyzer cargo byteorder 1.5.0 io/ReadBytesExt#read_i32().::<BigEndianrust-analyzer cargo byteorder 1.5.0 BigEndian#>()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 81 | |
| 82 | let offset = FixedOffsetrust-analyzer cargo chrono 0.4.45 offset/fixed/FixedOffset#::west_optrust-analyzer cargo chrono 0.4.45 offset/fixed/impl#[FixedOffset]west_opt().(offset_seconds).ok_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]ok_or_else().(|| { |
| 83 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!( |
| 84 | "server returned out-of-range offset for `TIMETZ`: {offset_seconds} seconds" |
| 85 | ) |
| 86 | })?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 87 | |
| 88 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(PgTimeTzrust-analyzer cargo sqlx-postgres 0.8.3 types/time_tz/PgTimeTz# { timerust-analyzer cargo sqlx-postgres 0.8.3 types/time_tz/PgTimeTz#time., offsetrust-analyzer cargo sqlx-postgres 0.8.3 types/time_tz/PgTimeTz#offset. }) |
| 89 | } |
| 90 | |
| 91 | PgValueFormatrust-analyzer cargo sqlx-postgres 0.8.3 value/PgValueFormat#::Textrust-analyzer cargo sqlx-postgres 0.8.3 value/PgValueFormat#Text# => try_parse_timetzrust-analyzer cargo sqlx-postgres 0.8.3 types/time_tz/chrono/try_parse_timetz().(value.as_strrust-analyzer cargo sqlx-postgres 0.8.3 value/impl#[`PgValueRef<'r>`]as_str().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().), |
| 92 | } |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | fn try_parse_timetzrust-analyzer cargo sqlx-postgres 0.8.3 types/time_tz/chrono/try_parse_timetz().(s: &str) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<PgTimeTzrust-analyzer cargo sqlx-postgres 0.8.3 types/time_tz/PgTimeTz#<NaiveTimerust-analyzer cargo chrono 0.4.45 naive/time/NaiveTime#, FixedOffsetrust-analyzer cargo chrono 0.4.45 offset/fixed/FixedOffset#>, BoxDynErrorrust-analyzer cargo sqlx-core 0.8.3 error/BoxDynError#> { |
| 97 | let mut tmp = Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::with_capacityrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]with_capacity().(11 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().s.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().()); |
| 98 | tmp.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().("2001-07-08 "); |
| 99 | tmp.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().(s); |
| 100 | |
| 101 | let mut err = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#; |
| 102 | |
| 103 | for fmt in &["%Y-%m-%d %H:%M:%S%.f%#z", "%Y-%m-%d %H:%M:%S%.f"] { |
| 104 | match DateTimerust-analyzer cargo chrono 0.4.45 datetime/DateTime#::parse_from_strrust-analyzer cargo chrono 0.4.45 datetime/impl#[`DateTime<FixedOffset>`]parse_from_str().(&tmp, fmt) { |
| 105 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(dt) => { |
| 106 | let time = dt.timerust-analyzer cargo chrono 0.4.45 datetime/impl#[`DateTime<Tz>`]time().(); |
| 107 | let offset = *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().dt.offsetrust-analyzer cargo chrono 0.4.45 datetime/impl#[`DateTime<Tz>`]offset().(); |
| 108 | |
| 109 | return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(PgTimeTzrust-analyzer cargo sqlx-postgres 0.8.3 types/time_tz/PgTimeTz# { timerust-analyzer cargo sqlx-postgres 0.8.3 types/time_tz/PgTimeTz#time., offsetrust-analyzer cargo sqlx-postgres 0.8.3 types/time_tz/PgTimeTz#offset. }); |
| 110 | } |
| 111 | |
| 112 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(error) => { |
| 113 | err = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(error); |
| 114 | } |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(err |
| 119 | .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]expect().("BUG: loop should have set `err` to `Some()` before exiting") |
| 120 | .intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()) |
| 121 | } |
| 122 | } |
| 123 | |
| 124 | #[cfg(feature = "time")] |
| 125 | mod timerust-analyzer cargo sqlx-postgres 0.8.3 types/time_tz/time/ { |
| 126 | use superrust-analyzer cargo sqlx-postgres 0.8.3 types/time_tz/::*; |
| 127 | use ::timerust-analyzer cargo time 0.3.55 crate/::{Durationrust-analyzer cargo time 0.3.55 Duration#, Timerust-analyzer cargo time 0.3.55 time/Time#, UtcOffsetrust-analyzer cargo time 0.3.55 utc_offset/UtcOffset#}; |
| 128 | |
| 129 | impl Typerust-analyzer cargo sqlx-core 0.8.3 types/Type#<Postgresrust-analyzer cargo sqlx-postgres 0.8.3 database/Postgres#> for PgTimeTzrust-analyzer cargo sqlx-postgres 0.8.3 types/time_tz/PgTimeTz#<Timerust-analyzer cargo time 0.3.55 time/Time#, UtcOffsetrust-analyzer cargo time 0.3.55 utc_offset/UtcOffset#> { |
| 130 | fn type_inforust-analyzer cargo sqlx-postgres 0.8.3 types/time_tz/time/impl#[PgTimeTz][`Type<Postgres>`]type_info().() -> PgTypeInforust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgTypeInfo# { |
| 131 | PgTypeInforust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgTypeInfo#::TIMETZrust-analyzer cargo sqlx-postgres 0.8.3 type_info/impl#[PgTypeInfo]TIMETZ. |
| 132 | } |
| 133 | } |
| 134 | |
| 135 | impl Encoderust-analyzer cargo sqlx-core 0.8.3 encode/Encode#<'_, Postgresrust-analyzer cargo sqlx-postgres 0.8.3 database/Postgres#> for PgTimeTzrust-analyzer cargo sqlx-postgres 0.8.3 types/time_tz/PgTimeTz#<Timerust-analyzer cargo time 0.3.55 time/Time#, UtcOffsetrust-analyzer cargo time 0.3.55 utc_offset/UtcOffset#> { |
| 136 | fn encode_by_refrust-analyzer cargo sqlx-postgres 0.8.3 types/time_tz/time/impl#[PgTimeTz][`Encode<'_, Postgres>`]encode_by_ref().(&self, buf: &mut PgArgumentBufferrust-analyzer cargo sqlx-postgres 0.8.3 arguments/PgArgumentBuffer#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<IsNullrust-analyzer cargo sqlx-core 0.8.3 encode/IsNull#, BoxDynErrorrust-analyzer cargo sqlx-core 0.8.3 error/BoxDynError#> { |
| 137 | let _: IsNullrust-analyzer cargo sqlx-core 0.8.3 encode/IsNull# = <Timerust-analyzer cargo time 0.3.55 time/Time# as Encoderust-analyzer cargo sqlx-core 0.8.3 encode/Encode#<'_, Postgresrust-analyzer cargo sqlx-postgres 0.8.3 database/Postgres#>>::encoderust-analyzer cargo sqlx-core 0.8.3 encode/Encode#encode().(self.timerust-analyzer cargo sqlx-postgres 0.8.3 types/time_tz/PgTimeTz#time., buf)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 138 | let _: IsNullrust-analyzer cargo sqlx-core 0.8.3 encode/IsNull# = |
| 139 | <i32 as Encoderust-analyzer cargo sqlx-core 0.8.3 encode/Encode#<'_, Postgresrust-analyzer cargo sqlx-postgres 0.8.3 database/Postgres#>>::encoderust-analyzer cargo sqlx-core 0.8.3 encode/Encode#encode().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][Neg]neg().self.offsetrust-analyzer cargo sqlx-postgres 0.8.3 types/time_tz/PgTimeTz#offset..whole_secondsrust-analyzer cargo time 0.3.55 utc_offset/impl#[UtcOffset]whole_seconds().(), buf)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 140 | |
| 141 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(IsNullrust-analyzer cargo sqlx-core 0.8.3 encode/IsNull#::Norust-analyzer cargo sqlx-core 0.8.3 encode/IsNull#No#) |
| 142 | } |
| 143 | |
| 144 | fn size_hintrust-analyzer cargo sqlx-postgres 0.8.3 types/time_tz/time/impl#[PgTimeTz][`Encode<'_, Postgres>`]size_hint().(&self) -> usize { |
| 145 | memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::size_ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/size_of().::<i64>() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::size_ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/size_of().::<i32>() |
| 146 | } |
| 147 | } |
| 148 | |
| 149 | impl<'r> Decoderust-analyzer cargo sqlx-core 0.8.3 decode/Decode#<'r, Postgresrust-analyzer cargo sqlx-postgres 0.8.3 database/Postgres#> for PgTimeTzrust-analyzer cargo sqlx-postgres 0.8.3 types/time_tz/PgTimeTz#<Timerust-analyzer cargo time 0.3.55 time/Time#, UtcOffsetrust-analyzer cargo time 0.3.55 utc_offset/UtcOffset#> { |
| 150 | fn decoderust-analyzer cargo sqlx-postgres 0.8.3 types/time_tz/time/impl#[PgTimeTz][`Decode<'r, Postgres>`]decode().(value: PgValueRefrust-analyzer cargo sqlx-postgres 0.8.3 value/PgValueRef#<'r>) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo sqlx-postgres 0.8.3 types/time_tz/time/impl#[PgTimeTz][`Decode<'r, Postgres>`], BoxDynErrorrust-analyzer cargo sqlx-core 0.8.3 error/BoxDynError#> { |
| 151 | match value.formatrust-analyzer cargo sqlx-postgres 0.8.3 value/impl#[`PgValueRef<'r>`]format().() { |
| 152 | PgValueFormatrust-analyzer cargo sqlx-postgres 0.8.3 value/PgValueFormat#::Binaryrust-analyzer cargo sqlx-postgres 0.8.3 value/PgValueFormat#Binary# => { |
| 153 | let mut buf = Cursorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/cursor/Cursor#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/cursor/impl#[`Cursor<T>`]new().(value.as_bytesrust-analyzer cargo sqlx-postgres 0.8.3 value/impl#[`PgValueRef<'r>`]as_bytes().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().); |
| 154 | |
| 155 | // TIME is encoded as the microseconds since midnight |
| 156 | let us = buf.read_i64rust-analyzer cargo byteorder 1.5.0 io/ReadBytesExt#read_i64().::<BigEndianrust-analyzer cargo byteorder 1.5.0 BigEndian#>()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 157 | let time = Timerust-analyzer cargo time 0.3.55 time/Time#::MIDNIGHTrust-analyzer cargo time 0.3.55 time/impl#[Time]MIDNIGHT. rust-analyzer cargo time 0.3.55 time/impl#[Time][`Add<SignedDuration>`]add().+rust-analyzer cargo time 0.3.55 time/impl#[Time][`Add<SignedDuration>`]add(). rust-analyzer cargo time 0.3.55 time/impl#[Time][`Add<SignedDuration>`]add().Durationrust-analyzer cargo time 0.3.55 Duration#::microsecondsrust-analyzer cargo time 0.3.55 signed_duration/impl#[SignedDuration]microseconds().(us); |
| 158 | |
| 159 | // OFFSET is encoded as seconds from UTC |
| 160 | let seconds = buf.read_i32rust-analyzer cargo byteorder 1.5.0 io/ReadBytesExt#read_i32().::<BigEndianrust-analyzer cargo byteorder 1.5.0 BigEndian#>()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 161 | |
| 162 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(PgTimeTzrust-analyzer cargo sqlx-postgres 0.8.3 types/time_tz/PgTimeTz# { |
| 163 | timerust-analyzer cargo sqlx-postgres 0.8.3 types/time_tz/PgTimeTz#time., |
| 164 | offsetrust-analyzer cargo sqlx-postgres 0.8.3 types/time_tz/PgTimeTz#offset.: -rust-analyzer cargo time 0.3.55 utc_offset/impl#[UtcOffset][Neg]neg().UtcOffsetrust-analyzer cargo time 0.3.55 utc_offset/UtcOffset#::from_whole_secondsrust-analyzer cargo time 0.3.55 utc_offset/impl#[UtcOffset]from_whole_seconds().(seconds)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., |
| 165 | }) |
| 166 | } |
| 167 | |
| 168 | PgValueFormatrust-analyzer cargo sqlx-postgres 0.8.3 value/PgValueFormat#::Textrust-analyzer cargo sqlx-postgres 0.8.3 value/PgValueFormat#Text# => { |
| 169 | // the `time` crate has a limited ability to parse and can't parse the |
| 170 | // timezone format |
| 171 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("reading a `TIMETZ` value in text format is not supported.".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()) |
| 172 | } |
| 173 | } |
| 174 | } |
| 175 | } |
| 176 | } |