| 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 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/; |
| 7 | use timerust-analyzer cargo time 0.3.55 crate/::macrosrust-analyzer cargo time 0.3.55 macros/::format_descriptionrust-analyzer cargo time-macros 0.2.32 format_description!; |
| 8 | 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#}; |
| 9 | |
| 10 | impl Typerust-analyzer cargo sqlx-core 0.8.3 types/Type#<Postgresrust-analyzer cargo sqlx-postgres 0.8.3 database/Postgres#> for Timerust-analyzer cargo time 0.3.55 time/Time# { |
| 11 | fn type_inforust-analyzer cargo sqlx-postgres 0.8.3 types/time/time/impl#[Time][`Type<Postgres>`]type_info().() -> PgTypeInforust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgTypeInfo# { |
| 12 | PgTypeInforust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgTypeInfo#::TIMErust-analyzer cargo sqlx-postgres 0.8.3 type_info/impl#[PgTypeInfo]TIME. |
| 13 | } |
| 14 | } |
| 15 | |
| 16 | impl PgHasArrayTyperust-analyzer cargo sqlx-postgres 0.8.3 types/array/PgHasArrayType# for Timerust-analyzer cargo time 0.3.55 time/Time# { |
| 17 | fn array_type_inforust-analyzer cargo sqlx-postgres 0.8.3 types/time/time/impl#[Time][PgHasArrayType]array_type_info().() -> PgTypeInforust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgTypeInfo# { |
| 18 | PgTypeInforust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgTypeInfo#::TIME_ARRAYrust-analyzer cargo sqlx-postgres 0.8.3 type_info/impl#[PgTypeInfo]TIME_ARRAY. |
| 19 | } |
| 20 | } |
| 21 | |
| 22 | impl Encoderust-analyzer cargo sqlx-core 0.8.3 encode/Encode#<'_, Postgresrust-analyzer cargo sqlx-postgres 0.8.3 database/Postgres#> for Timerust-analyzer cargo time 0.3.55 time/Time# { |
| 23 | fn encode_by_refrust-analyzer cargo sqlx-postgres 0.8.3 types/time/time/impl#[Time][`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#> { |
| 24 | // TIME is encoded as the microseconds since midnight. |
| 25 | // |
| 26 | // A truncating cast is fine because `self - Time::MIDNIGHT` cannot exceed a span of 24 hours. |
| 27 | #[allow(clippy::cast_possible_truncation)] |
| 28 | let micros: i64 = (*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self rust-analyzer cargo time 0.3.55 time/impl#[Time][`Sub<Self>`]sub().-rust-analyzer cargo time 0.3.55 time/impl#[Time][`Sub<Self>`]sub(). rust-analyzer cargo time 0.3.55 time/impl#[Time][`Sub<Self>`]sub().Timerust-analyzer cargo time 0.3.55 time/Time#::MIDNIGHTrust-analyzer cargo time 0.3.55 time/impl#[Time]MIDNIGHT.).whole_microsecondsrust-analyzer cargo time 0.3.55 signed_duration/impl#[SignedDuration]whole_microseconds().() as i64; |
| 29 | 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().(micros, buf) |
| 30 | } |
| 31 | |
| 32 | fn size_hintrust-analyzer cargo sqlx-postgres 0.8.3 types/time/time/impl#[Time][`Encode<'_, Postgres>`]size_hint().(&self) -> usize { |
| 33 | 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().::<u64>() |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | impl<'r> Decoderust-analyzer cargo sqlx-core 0.8.3 decode/Decode#<'r, Postgresrust-analyzer cargo sqlx-postgres 0.8.3 database/Postgres#> for Timerust-analyzer cargo time 0.3.55 time/Time# { |
| 38 | fn decoderust-analyzer cargo sqlx-postgres 0.8.3 types/time/time/impl#[Time][`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/time/impl#[Time][`Decode<'r, Postgres>`], BoxDynErrorrust-analyzer cargo sqlx-core 0.8.3 error/BoxDynError#> { |
| 39 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(match value.formatrust-analyzer cargo sqlx-postgres 0.8.3 value/impl#[`PgValueRef<'r>`]format().() { |
| 40 | PgValueFormatrust-analyzer cargo sqlx-postgres 0.8.3 value/PgValueFormat#::Binaryrust-analyzer cargo sqlx-postgres 0.8.3 value/PgValueFormat#Binary# => { |
| 41 | // TIME is encoded as the microseconds since midnight |
| 42 | let us = Decoderust-analyzer cargo sqlx-core 0.8.3 decode/Decode#::<Postgresrust-analyzer cargo sqlx-postgres 0.8.3 database/Postgres#>::decoderust-analyzer cargo sqlx-postgres 0.8.3 types/int/impl#[i64][`Decode<'_, Postgres>`]decode().(value)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 43 | 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) |
| 44 | } |
| 45 | |
| 46 | PgValueFormatrust-analyzer cargo sqlx-postgres 0.8.3 value/PgValueFormat#::Textrust-analyzer cargo sqlx-postgres 0.8.3 value/PgValueFormat#Text# => Timerust-analyzer cargo time 0.3.55 time/Time#::parserust-analyzer cargo time 0.3.55 time/impl#[Time]parse().( |
| 47 | 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()., |
| 48 | // Postgres will not include the subsecond part if it's zero. |
| 49 | &format_descriptionrust-analyzer cargo time-macros 0.2.32 format_description!!("[hour]:[minute]:[second][optional [.[subsecond]]]"), |
| 50 | )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., |
| 51 | }) |
| 52 | } |
| 53 | } |