| 1 | use bytesrust-analyzer cargo bytes 1.12.1 crate/::Bufrust-analyzer cargo bytes 1.12.1 buf/buf_impl/Buf#; |
| 2 | use chronorust-analyzer cargo chrono 0.4.45 crate/::{ |
| 3 | DateTimerust-analyzer cargo chrono 0.4.45 datetime/DateTime#, Datelikerust-analyzer cargo chrono 0.4.45 traits/Datelike#, Localrust-analyzer cargo chrono 0.4.45 offset/local/Local#, NaiveDaterust-analyzer cargo chrono 0.4.45 naive/date/NaiveDate#, NaiveDateTimerust-analyzer cargo chrono 0.4.45 naive/datetime/NaiveDateTime#, NaiveTimerust-analyzer cargo chrono 0.4.45 naive/time/NaiveTime#, TimeZonerust-analyzer cargo chrono 0.4.45 offset/TimeZone#, Timelikerust-analyzer cargo chrono 0.4.45 traits/Timelike#, Utcrust-analyzer cargo chrono 0.4.45 offset/utc/Utc#, |
| 4 | }; |
| 5 | use sqlx_corerust-analyzer cargo sqlx-core 0.8.3 crate/::databaserust-analyzer cargo sqlx-core 0.8.3 database/::Databaserust-analyzer cargo sqlx-core 0.8.3 database/Database#; |
| 6 | |
| 7 | use craterust-analyzer cargo sqlx-mysql 0.8.3 crate/::decoderust-analyzer cargo sqlx-core 0.8.3 decode/::Decoderust-analyzer cargo sqlx-core 0.8.3 decode/Decode#; |
| 8 | use craterust-analyzer cargo sqlx-mysql 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#}; |
| 9 | use craterust-analyzer cargo sqlx-mysql 0.8.3 crate/::errorrust-analyzer cargo sqlx-mysql 0.8.3 error/::{BoxDynErrorrust-analyzer cargo sqlx-core 0.8.3 error/BoxDynError#, UnexpectedNullErrorrust-analyzer cargo sqlx-core 0.8.3 error/UnexpectedNullError#}; |
| 10 | use craterust-analyzer cargo sqlx-mysql 0.8.3 crate/::protocolrust-analyzer cargo sqlx-mysql 0.8.3 protocol/::textrust-analyzer cargo sqlx-mysql 0.8.3 protocol/text/::ColumnTyperust-analyzer cargo sqlx-mysql 0.8.3 protocol/text/column/ColumnType#; |
| 11 | use craterust-analyzer cargo sqlx-mysql 0.8.3 crate/::type_inforust-analyzer cargo sqlx-mysql 0.8.3 type_info/::MySqlTypeInforust-analyzer cargo sqlx-mysql 0.8.3 type_info/MySqlTypeInfo#; |
| 12 | use craterust-analyzer cargo sqlx-mysql 0.8.3 crate/::typesrust-analyzer cargo sqlx-mysql 0.8.3 types/::{MySqlTimerust-analyzer cargo sqlx-mysql 0.8.3 types/mysql_time/MySqlTime#, MySqlTimeSignrust-analyzer cargo sqlx-mysql 0.8.3 types/mysql_time/MySqlTimeSign#, Typerust-analyzer cargo sqlx-core 0.8.3 types/Type#}; |
| 13 | use craterust-analyzer cargo sqlx-mysql 0.8.3 crate/::{MySqlrust-analyzer cargo sqlx-mysql 0.8.3 database/MySql#, MySqlValueFormatrust-analyzer cargo sqlx-mysql 0.8.3 value/MySqlValueFormat#, MySqlValueRefrust-analyzer cargo sqlx-mysql 0.8.3 value/MySqlValueRef#}; |
| 14 | |
| 15 | impl Typerust-analyzer cargo sqlx-core 0.8.3 types/Type#<MySqlrust-analyzer cargo sqlx-mysql 0.8.3 database/MySql#> for DateTimerust-analyzer cargo chrono 0.4.45 datetime/DateTime#<Utcrust-analyzer cargo chrono 0.4.45 offset/utc/Utc#> { |
| 16 | fn type_inforust-analyzer cargo sqlx-mysql 0.8.3 types/chrono/impl#[`DateTime<Utc>`][`Type<MySql>`]type_info().() -> MySqlTypeInforust-analyzer cargo sqlx-mysql 0.8.3 type_info/MySqlTypeInfo# { |
| 17 | MySqlTypeInforust-analyzer cargo sqlx-mysql 0.8.3 type_info/MySqlTypeInfo#::binaryrust-analyzer cargo sqlx-mysql 0.8.3 type_info/impl#[MySqlTypeInfo]binary().(ColumnTyperust-analyzer cargo sqlx-mysql 0.8.3 protocol/text/column/ColumnType#::Timestamprust-analyzer cargo sqlx-mysql 0.8.3 protocol/text/column/ColumnType#Timestamp#) |
| 18 | } |
| 19 | |
| 20 | fn compatiblerust-analyzer cargo sqlx-mysql 0.8.3 types/chrono/impl#[`DateTime<Utc>`][`Type<MySql>`]compatible().(ty: &MySqlTypeInforust-analyzer cargo sqlx-mysql 0.8.3 type_info/MySqlTypeInfo#) -> bool { |
| 21 | matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!(ty.r#typerust-analyzer cargo sqlx-mysql 0.8.3 type_info/MySqlTypeInfo#`r#type`., ColumnTyperust-analyzer cargo sqlx-mysql 0.8.3 protocol/text/column/ColumnType#::Datetimerust-analyzer cargo sqlx-mysql 0.8.3 protocol/text/column/ColumnType#Datetime# | ColumnTyperust-analyzer cargo sqlx-mysql 0.8.3 protocol/text/column/ColumnType#::Timestamprust-analyzer cargo sqlx-mysql 0.8.3 protocol/text/column/ColumnType#Timestamp#) |
| 22 | } |
| 23 | } |
| 24 | |
| 25 | /// Note: assumes the connection's `time_zone` is set to `+00:00` (UTC). |
| 26 | impl Encoderust-analyzer cargo sqlx-core 0.8.3 encode/Encode#<'_, MySqlrust-analyzer cargo sqlx-mysql 0.8.3 database/MySql#> for DateTimerust-analyzer cargo chrono 0.4.45 datetime/DateTime#<Utcrust-analyzer cargo chrono 0.4.45 offset/utc/Utc#> { |
| 27 | fn encode_by_refrust-analyzer cargo sqlx-mysql 0.8.3 types/chrono/impl#[`DateTime<Utc>`][`Encode<'_, MySql>`]encode_by_ref().(&self, buf: &mut Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8>) -> 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#> { |
| 28 | Encoderust-analyzer cargo sqlx-core 0.8.3 encode/Encode#::<MySqlrust-analyzer cargo sqlx-mysql 0.8.3 database/MySql#>::encoderust-analyzer cargo sqlx-core 0.8.3 encode/Encode#encode().(self.naive_utcrust-analyzer cargo chrono 0.4.45 datetime/impl#[`DateTime<Tz>`]naive_utc().(), buf) |
| 29 | } |
| 30 | } |
| 31 | |
| 32 | /// Note: assumes the connection's `time_zone` is set to `+00:00` (UTC). |
| 33 | impl<'r> Decoderust-analyzer cargo sqlx-core 0.8.3 decode/Decode#<'r, MySqlrust-analyzer cargo sqlx-mysql 0.8.3 database/MySql#> for DateTimerust-analyzer cargo chrono 0.4.45 datetime/DateTime#<Utcrust-analyzer cargo chrono 0.4.45 offset/utc/Utc#> { |
| 34 | fn decoderust-analyzer cargo sqlx-mysql 0.8.3 types/chrono/impl#[`DateTime<Utc>`][`Decode<'r, MySql>`]decode().(value: MySqlValueRefrust-analyzer cargo sqlx-mysql 0.8.3 value/MySqlValueRef#<'r>) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo sqlx-mysql 0.8.3 types/chrono/impl#[`DateTime<Utc>`][`Decode<'r, MySql>`], BoxDynErrorrust-analyzer cargo sqlx-core 0.8.3 error/BoxDynError#> { |
| 35 | let naive: NaiveDateTimerust-analyzer cargo chrono 0.4.45 naive/datetime/NaiveDateTime# = Decoderust-analyzer cargo sqlx-core 0.8.3 decode/Decode#::<MySqlrust-analyzer cargo sqlx-mysql 0.8.3 database/MySql#>::decoderust-analyzer cargo sqlx-mysql 0.8.3 types/chrono/impl#[NaiveDateTime][`Decode<'r, MySql>`]decode().(value)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 36 | |
| 37 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Utcrust-analyzer cargo chrono 0.4.45 offset/utc/Utc#.from_utc_datetimerust-analyzer cargo chrono 0.4.45 offset/TimeZone#from_utc_datetime().(&naive)) |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | impl Typerust-analyzer cargo sqlx-core 0.8.3 types/Type#<MySqlrust-analyzer cargo sqlx-mysql 0.8.3 database/MySql#> for DateTimerust-analyzer cargo chrono 0.4.45 datetime/DateTime#<Localrust-analyzer cargo chrono 0.4.45 offset/local/Local#> { |
| 42 | fn type_inforust-analyzer cargo sqlx-mysql 0.8.3 types/chrono/impl#[`DateTime<Local>`][`Type<MySql>`]type_info().() -> MySqlTypeInforust-analyzer cargo sqlx-mysql 0.8.3 type_info/MySqlTypeInfo# { |
| 43 | MySqlTypeInforust-analyzer cargo sqlx-mysql 0.8.3 type_info/MySqlTypeInfo#::binaryrust-analyzer cargo sqlx-mysql 0.8.3 type_info/impl#[MySqlTypeInfo]binary().(ColumnTyperust-analyzer cargo sqlx-mysql 0.8.3 protocol/text/column/ColumnType#::Timestamprust-analyzer cargo sqlx-mysql 0.8.3 protocol/text/column/ColumnType#Timestamp#) |
| 44 | } |
| 45 | |
| 46 | fn compatiblerust-analyzer cargo sqlx-mysql 0.8.3 types/chrono/impl#[`DateTime<Local>`][`Type<MySql>`]compatible().(ty: &MySqlTypeInforust-analyzer cargo sqlx-mysql 0.8.3 type_info/MySqlTypeInfo#) -> bool { |
| 47 | matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!(ty.r#typerust-analyzer cargo sqlx-mysql 0.8.3 type_info/MySqlTypeInfo#`r#type`., ColumnTyperust-analyzer cargo sqlx-mysql 0.8.3 protocol/text/column/ColumnType#::Datetimerust-analyzer cargo sqlx-mysql 0.8.3 protocol/text/column/ColumnType#Datetime# | ColumnTyperust-analyzer cargo sqlx-mysql 0.8.3 protocol/text/column/ColumnType#::Timestamprust-analyzer cargo sqlx-mysql 0.8.3 protocol/text/column/ColumnType#Timestamp#) |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | /// Note: assumes the connection's `time_zone` is set to `+00:00` (UTC). |
| 52 | impl Encoderust-analyzer cargo sqlx-core 0.8.3 encode/Encode#<'_, MySqlrust-analyzer cargo sqlx-mysql 0.8.3 database/MySql#> for DateTimerust-analyzer cargo chrono 0.4.45 datetime/DateTime#<Localrust-analyzer cargo chrono 0.4.45 offset/local/Local#> { |
| 53 | fn encode_by_refrust-analyzer cargo sqlx-mysql 0.8.3 types/chrono/impl#[`DateTime<Local>`][`Encode<'_, MySql>`]encode_by_ref().(&self, buf: &mut Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8>) -> 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#> { |
| 54 | Encoderust-analyzer cargo sqlx-core 0.8.3 encode/Encode#::<MySqlrust-analyzer cargo sqlx-mysql 0.8.3 database/MySql#>::encoderust-analyzer cargo sqlx-core 0.8.3 encode/Encode#encode().(self.naive_utcrust-analyzer cargo chrono 0.4.45 datetime/impl#[`DateTime<Tz>`]naive_utc().(), buf) |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | /// Note: assumes the connection's `time_zone` is set to `+00:00` (UTC). |
| 59 | impl<'r> Decoderust-analyzer cargo sqlx-core 0.8.3 decode/Decode#<'r, MySqlrust-analyzer cargo sqlx-mysql 0.8.3 database/MySql#> for DateTimerust-analyzer cargo chrono 0.4.45 datetime/DateTime#<Localrust-analyzer cargo chrono 0.4.45 offset/local/Local#> { |
| 60 | fn decoderust-analyzer cargo sqlx-mysql 0.8.3 types/chrono/impl#[`DateTime<Local>`][`Decode<'r, MySql>`]decode().(value: MySqlValueRefrust-analyzer cargo sqlx-mysql 0.8.3 value/MySqlValueRef#<'r>) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo sqlx-mysql 0.8.3 types/chrono/impl#[`DateTime<Local>`][`Decode<'r, MySql>`], BoxDynErrorrust-analyzer cargo sqlx-core 0.8.3 error/BoxDynError#> { |
| 61 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(<DateTimerust-analyzer cargo chrono 0.4.45 datetime/DateTime#<Utcrust-analyzer cargo chrono 0.4.45 offset/utc/Utc#> as Decoderust-analyzer cargo sqlx-core 0.8.3 decode/Decode#<'r, MySqlrust-analyzer cargo sqlx-mysql 0.8.3 database/MySql#>>::decoderust-analyzer cargo sqlx-mysql 0.8.3 types/chrono/impl#[`DateTime<Utc>`][`Decode<'r, MySql>`]decode().(value)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()..with_timezonerust-analyzer cargo chrono 0.4.45 datetime/impl#[`DateTime<Tz>`]with_timezone().(&Localrust-analyzer cargo chrono 0.4.45 offset/local/Local#)) |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | impl Typerust-analyzer cargo sqlx-core 0.8.3 types/Type#<MySqlrust-analyzer cargo sqlx-mysql 0.8.3 database/MySql#> for NaiveTimerust-analyzer cargo chrono 0.4.45 naive/time/NaiveTime# { |
| 66 | fn type_inforust-analyzer cargo sqlx-mysql 0.8.3 types/chrono/impl#[NaiveTime][`Type<MySql>`]type_info().() -> MySqlTypeInforust-analyzer cargo sqlx-mysql 0.8.3 type_info/MySqlTypeInfo# { |
| 67 | MySqlTimerust-analyzer cargo sqlx-mysql 0.8.3 types/mysql_time/MySqlTime#::type_inforust-analyzer cargo sqlx-mysql 0.8.3 types/mysql_time/impl#[MySqlTime][`Type<MySql>`]type_info().() |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | impl Encoderust-analyzer cargo sqlx-core 0.8.3 encode/Encode#<'_, MySqlrust-analyzer cargo sqlx-mysql 0.8.3 database/MySql#> for NaiveTimerust-analyzer cargo chrono 0.4.45 naive/time/NaiveTime# { |
| 72 | fn encode_by_refrust-analyzer cargo sqlx-mysql 0.8.3 types/chrono/impl#[NaiveTime][`Encode<'_, MySql>`]encode_by_ref().(&self, buf: &mut Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8>) -> 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#> { |
| 73 | let len = naive_time_encoded_lenrust-analyzer cargo sqlx-mysql 0.8.3 types/chrono/naive_time_encoded_len().(self); |
| 74 | buf.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(len); |
| 75 | |
| 76 | // NaiveTime is not negative |
| 77 | buf.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(0); |
| 78 | |
| 79 | // Number of days in the interval; always 0 for time-of-day values. |
| 80 | // https://mariadb.com/kb/en/resultset-row/#teimstamp-binary-encoding |
| 81 | buf.extend_from_slicerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]extend_from_slice().(&[0_u8; 4]); |
| 82 | |
| 83 | encode_timerust-analyzer cargo sqlx-mysql 0.8.3 types/chrono/encode_time().(self, len rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]gt().8, buf); |
| 84 | |
| 85 | 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#) |
| 86 | } |
| 87 | |
| 88 | fn size_hintrust-analyzer cargo sqlx-mysql 0.8.3 types/chrono/impl#[NaiveTime][`Encode<'_, MySql>`]size_hint().(&self) -> usize { |
| 89 | naive_time_encoded_lenrust-analyzer cargo sqlx-mysql 0.8.3 types/chrono/naive_time_encoded_len().(self) as usize 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().1 // plus length byte |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | /// Decode from a `TIME` value. |
| 94 | /// |
| 95 | /// ### Errors |
| 96 | /// Returns an error if the `TIME` value is negative or exceeds `23:59:59.999999`. |
| 97 | impl<'r> Decoderust-analyzer cargo sqlx-core 0.8.3 decode/Decode#<'r, MySqlrust-analyzer cargo sqlx-mysql 0.8.3 database/MySql#> for NaiveTimerust-analyzer cargo chrono 0.4.45 naive/time/NaiveTime# { |
| 98 | fn decoderust-analyzer cargo sqlx-mysql 0.8.3 types/chrono/impl#[NaiveTime][`Decode<'r, MySql>`]decode().(value: MySqlValueRefrust-analyzer cargo sqlx-mysql 0.8.3 value/MySqlValueRef#<'r>) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo sqlx-mysql 0.8.3 types/chrono/impl#[NaiveTime][`Decode<'r, MySql>`], BoxDynErrorrust-analyzer cargo sqlx-core 0.8.3 error/BoxDynError#> { |
| 99 | match value.formatrust-analyzer cargo sqlx-mysql 0.8.3 value/impl#[`MySqlValueRef<'r>`]format().() { |
| 100 | MySqlValueFormatrust-analyzer cargo sqlx-mysql 0.8.3 value/MySqlValueFormat#::Binaryrust-analyzer cargo sqlx-mysql 0.8.3 value/MySqlValueFormat#Binary# => { |
| 101 | // Covers most possible failure modes. |
| 102 | MySqlTimerust-analyzer cargo sqlx-mysql 0.8.3 types/mysql_time/MySqlTime#::decoderust-analyzer cargo sqlx-mysql 0.8.3 types/mysql_time/impl#[MySqlTime][`Decode<'r, MySql>`]decode().(value)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()..try_intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`TryInto<U>`]try_into().() |
| 103 | } |
| 104 | // Retaining this parsing for now as it allows us to cross-check our impl. |
| 105 | MySqlValueFormatrust-analyzer cargo sqlx-mysql 0.8.3 value/MySqlValueFormat#::Textrust-analyzer cargo sqlx-mysql 0.8.3 value/MySqlValueFormat#Text# => { |
| 106 | let s = value.as_strrust-analyzer cargo sqlx-mysql 0.8.3 value/impl#[`MySqlValueRef<'r>`]as_str().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 107 | NaiveTimerust-analyzer cargo chrono 0.4.45 naive/time/NaiveTime#::parse_from_strrust-analyzer cargo chrono 0.4.45 naive/time/impl#[NaiveTime]parse_from_str().(s, "%H:%M:%S%.f").map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#::intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().) |
| 108 | } |
| 109 | } |
| 110 | } |
| 111 | } |
| 112 | |
| 113 | impl TryFromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/TryFrom#<MySqlTimerust-analyzer cargo sqlx-mysql 0.8.3 types/mysql_time/MySqlTime#> for NaiveTimerust-analyzer cargo chrono 0.4.45 naive/time/NaiveTime# { |
| 114 | type Errorrust-analyzer cargo sqlx-mysql 0.8.3 types/chrono/impl#[NaiveTime][`TryFrom<MySqlTime>`]Error# = BoxDynErrorrust-analyzer cargo sqlx-core 0.8.3 error/BoxDynError#; |
| 115 | |
| 116 | fn try_fromrust-analyzer cargo sqlx-mysql 0.8.3 types/chrono/impl#[NaiveTime][`TryFrom<MySqlTime>`]try_from().(time: MySqlTimerust-analyzer cargo sqlx-mysql 0.8.3 types/mysql_time/MySqlTime#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo sqlx-mysql 0.8.3 types/chrono/impl#[NaiveTime][`TryFrom<MySqlTime>`], Selfrust-analyzer cargo sqlx-mysql 0.8.3 types/chrono/impl#[NaiveTime][`TryFrom<MySqlTime>`]::Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/TryFrom#Error#> { |
| 117 | NaiveTimerust-analyzer cargo chrono 0.4.45 naive/time/NaiveTime#::from_hms_micro_optrust-analyzer cargo chrono 0.4.45 naive/time/impl#[NaiveTime]from_hms_micro_opt().( |
| 118 | time.hoursrust-analyzer cargo sqlx-mysql 0.8.3 types/mysql_time/impl#[MySqlTime]hours().(), |
| 119 | time.minutesrust-analyzer cargo sqlx-mysql 0.8.3 types/mysql_time/impl#[MySqlTime]minutes().() as u32, |
| 120 | time.secondsrust-analyzer cargo sqlx-mysql 0.8.3 types/mysql_time/impl#[MySqlTime]seconds().() as u32, |
| 121 | time.microsecondsrust-analyzer cargo sqlx-mysql 0.8.3 types/mysql_time/impl#[MySqlTime]microseconds().(), |
| 122 | ) |
| 123 | .ok_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]ok_or_else().(|| formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("Cannot convert `MySqlTime` value to `NaiveTime`: {time}").intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()) |
| 124 | } |
| 125 | } |
| 126 | |
| 127 | impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<MySqlTimerust-analyzer cargo sqlx-mysql 0.8.3 types/mysql_time/MySqlTime#> for chronorust-analyzer cargo chrono 0.4.45 crate/::TimeDeltarust-analyzer cargo chrono 0.4.45 time_delta/TimeDelta# { |
| 128 | fn fromrust-analyzer cargo sqlx-mysql 0.8.3 types/chrono/impl#[`chrono::TimeDelta`][`From<MySqlTime>`]from().(time: MySqlTimerust-analyzer cargo sqlx-mysql 0.8.3 types/mysql_time/MySqlTime#) -> Selfrust-analyzer cargo sqlx-mysql 0.8.3 types/chrono/impl#[`chrono::TimeDelta`][`From<MySqlTime>`] { |
| 129 | chronorust-analyzer cargo chrono 0.4.45 crate/::TimeDeltarust-analyzer cargo chrono 0.4.45 time_delta/TimeDelta#::newrust-analyzer cargo chrono 0.4.45 time_delta/impl#[TimeDelta]new().(time.whole_seconds_signedrust-analyzer cargo sqlx-mysql 0.8.3 types/mysql_time/impl#[MySqlTime]whole_seconds_signed().(), time.subsec_nanosrust-analyzer cargo sqlx-mysql 0.8.3 types/mysql_time/impl#[MySqlTime]subsec_nanos().()) |
| 130 | .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]expect().("BUG: chrono::TimeDelta should have a greater range than MySqlTime") |
| 131 | } |
| 132 | } |
| 133 | |
| 134 | impl TryFromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/TryFrom#<chronorust-analyzer cargo chrono 0.4.45 crate/::TimeDeltarust-analyzer cargo chrono 0.4.45 time_delta/TimeDelta#> for MySqlTimerust-analyzer cargo sqlx-mysql 0.8.3 types/mysql_time/MySqlTime# { |
| 135 | type Errorrust-analyzer cargo sqlx-mysql 0.8.3 types/chrono/impl#[MySqlTime][`TryFrom<chrono::TimeDelta>`]Error# = BoxDynErrorrust-analyzer cargo sqlx-core 0.8.3 error/BoxDynError#; |
| 136 | |
| 137 | fn try_fromrust-analyzer cargo sqlx-mysql 0.8.3 types/chrono/impl#[MySqlTime][`TryFrom<chrono::TimeDelta>`]try_from().(value: chronorust-analyzer cargo chrono 0.4.45 crate/::TimeDeltarust-analyzer cargo chrono 0.4.45 time_delta/TimeDelta#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo sqlx-mysql 0.8.3 types/chrono/impl#[MySqlTime][`TryFrom<chrono::TimeDelta>`], Selfrust-analyzer cargo sqlx-mysql 0.8.3 types/chrono/impl#[MySqlTime][`TryFrom<chrono::TimeDelta>`]::Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/TryFrom#Error#> { |
| 138 | let sign = if value rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#lt().chronorust-analyzer cargo chrono 0.4.45 crate/::TimeDeltarust-analyzer cargo chrono 0.4.45 time_delta/TimeDelta#::zerorust-analyzer cargo chrono 0.4.45 time_delta/impl#[TimeDelta]zero().() { |
| 139 | MySqlTimeSignrust-analyzer cargo sqlx-mysql 0.8.3 types/mysql_time/MySqlTimeSign#::Negativerust-analyzer cargo sqlx-mysql 0.8.3 types/mysql_time/MySqlTimeSign#Negative# |
| 140 | } else { |
| 141 | MySqlTimeSignrust-analyzer cargo sqlx-mysql 0.8.3 types/mysql_time/MySqlTimeSign#::Positiverust-analyzer cargo sqlx-mysql 0.8.3 types/mysql_time/MySqlTimeSign#Positive# |
| 142 | }; |
| 143 | |
| 144 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#( |
| 145 | // `std::time::Duration` has a greater positive range than `TimeDelta` |
| 146 | // which makes it a great intermediate if you ignore the sign. |
| 147 | MySqlTimerust-analyzer cargo sqlx-mysql 0.8.3 types/mysql_time/MySqlTime#::try_fromrust-analyzer cargo sqlx-mysql 0.8.3 types/mysql_time/impl#[MySqlTime][`TryFrom<Duration>`]try_from().(value.absrust-analyzer cargo chrono 0.4.45 time_delta/impl#[TimeDelta]abs().().to_stdrust-analyzer cargo chrono 0.4.45 time_delta/impl#[TimeDelta]to_std().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()..with_signrust-analyzer cargo sqlx-mysql 0.8.3 types/mysql_time/impl#[MySqlTime]with_sign().(sign), |
| 148 | ) |
| 149 | } |
| 150 | } |
| 151 | |
| 152 | impl Typerust-analyzer cargo sqlx-core 0.8.3 types/Type#<MySqlrust-analyzer cargo sqlx-mysql 0.8.3 database/MySql#> for chronorust-analyzer cargo chrono 0.4.45 crate/::TimeDeltarust-analyzer cargo chrono 0.4.45 time_delta/TimeDelta# { |
| 153 | fn type_inforust-analyzer cargo sqlx-mysql 0.8.3 types/chrono/impl#[`chrono::TimeDelta`][`Type<MySql>`]type_info().() -> MySqlTypeInforust-analyzer cargo sqlx-mysql 0.8.3 type_info/MySqlTypeInfo# { |
| 154 | MySqlTimerust-analyzer cargo sqlx-mysql 0.8.3 types/mysql_time/MySqlTime#::type_inforust-analyzer cargo sqlx-mysql 0.8.3 types/mysql_time/impl#[MySqlTime][`Type<MySql>`]type_info().() |
| 155 | } |
| 156 | } |
| 157 | |
| 158 | impl<'r> Decoderust-analyzer cargo sqlx-core 0.8.3 decode/Decode#<'r, MySqlrust-analyzer cargo sqlx-mysql 0.8.3 database/MySql#> for chronorust-analyzer cargo chrono 0.4.45 crate/::TimeDeltarust-analyzer cargo chrono 0.4.45 time_delta/TimeDelta# { |
| 159 | fn decoderust-analyzer cargo sqlx-mysql 0.8.3 types/chrono/impl#[`chrono::TimeDelta`][`Decode<'r, MySql>`]decode().(value: <MySqlrust-analyzer cargo sqlx-mysql 0.8.3 database/MySql# as Databaserust-analyzer cargo sqlx-core 0.8.3 database/Database#>::ValueRefrust-analyzer cargo sqlx-core 0.8.3 database/Database#ValueRef#<'r>) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo sqlx-mysql 0.8.3 types/chrono/impl#[`chrono::TimeDelta`][`Decode<'r, MySql>`], BoxDynErrorrust-analyzer cargo sqlx-core 0.8.3 error/BoxDynError#> { |
| 160 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(MySqlTimerust-analyzer cargo sqlx-mysql 0.8.3 types/mysql_time/MySqlTime#::decoderust-analyzer cargo sqlx-mysql 0.8.3 types/mysql_time/impl#[MySqlTime][`Decode<'r, MySql>`]decode().(value)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()..intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()) |
| 161 | } |
| 162 | } |
| 163 | |
| 164 | impl Typerust-analyzer cargo sqlx-core 0.8.3 types/Type#<MySqlrust-analyzer cargo sqlx-mysql 0.8.3 database/MySql#> for NaiveDaterust-analyzer cargo chrono 0.4.45 naive/date/NaiveDate# { |
| 165 | fn type_inforust-analyzer cargo sqlx-mysql 0.8.3 types/chrono/impl#[NaiveDate][`Type<MySql>`]type_info().() -> MySqlTypeInforust-analyzer cargo sqlx-mysql 0.8.3 type_info/MySqlTypeInfo# { |
| 166 | MySqlTypeInforust-analyzer cargo sqlx-mysql 0.8.3 type_info/MySqlTypeInfo#::binaryrust-analyzer cargo sqlx-mysql 0.8.3 type_info/impl#[MySqlTypeInfo]binary().(ColumnTyperust-analyzer cargo sqlx-mysql 0.8.3 protocol/text/column/ColumnType#::Daterust-analyzer cargo sqlx-mysql 0.8.3 protocol/text/column/ColumnType#Date#) |
| 167 | } |
| 168 | } |
| 169 | |
| 170 | impl Encoderust-analyzer cargo sqlx-core 0.8.3 encode/Encode#<'_, MySqlrust-analyzer cargo sqlx-mysql 0.8.3 database/MySql#> for NaiveDaterust-analyzer cargo chrono 0.4.45 naive/date/NaiveDate# { |
| 171 | fn encode_by_refrust-analyzer cargo sqlx-mysql 0.8.3 types/chrono/impl#[NaiveDate][`Encode<'_, MySql>`]encode_by_ref().(&self, buf: &mut Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8>) -> 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#> { |
| 172 | buf.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(4); |
| 173 | |
| 174 | encode_daterust-analyzer cargo sqlx-mysql 0.8.3 types/chrono/encode_date().(self, buf)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 175 | |
| 176 | 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#) |
| 177 | } |
| 178 | |
| 179 | fn size_hintrust-analyzer cargo sqlx-mysql 0.8.3 types/chrono/impl#[NaiveDate][`Encode<'_, MySql>`]size_hint().(&self) -> usize { |
| 180 | 5 |
| 181 | } |
| 182 | } |
| 183 | |
| 184 | impl<'r> Decoderust-analyzer cargo sqlx-core 0.8.3 decode/Decode#<'r, MySqlrust-analyzer cargo sqlx-mysql 0.8.3 database/MySql#> for NaiveDaterust-analyzer cargo chrono 0.4.45 naive/date/NaiveDate# { |
| 185 | fn decoderust-analyzer cargo sqlx-mysql 0.8.3 types/chrono/impl#[NaiveDate][`Decode<'r, MySql>`]decode().(value: MySqlValueRefrust-analyzer cargo sqlx-mysql 0.8.3 value/MySqlValueRef#<'r>) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo sqlx-mysql 0.8.3 types/chrono/impl#[NaiveDate][`Decode<'r, MySql>`], BoxDynErrorrust-analyzer cargo sqlx-core 0.8.3 error/BoxDynError#> { |
| 186 | match value.formatrust-analyzer cargo sqlx-mysql 0.8.3 value/impl#[`MySqlValueRef<'r>`]format().() { |
| 187 | MySqlValueFormatrust-analyzer cargo sqlx-mysql 0.8.3 value/MySqlValueFormat#::Binaryrust-analyzer cargo sqlx-mysql 0.8.3 value/MySqlValueFormat#Binary# => { |
| 188 | let buf = value.as_bytesrust-analyzer cargo sqlx-mysql 0.8.3 value/impl#[`MySqlValueRef<'r>`]as_bytes().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 189 | |
| 190 | // Row decoding should have left the length prefix. |
| 191 | if buf.is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]is_empty().() { |
| 192 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("empty buffer".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()); |
| 193 | } |
| 194 | |
| 195 | decode_daterust-analyzer cargo sqlx-mysql 0.8.3 types/chrono/decode_date().(&buf[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()..ok_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]ok_or_else().(|| UnexpectedNullErrorrust-analyzer cargo sqlx-core 0.8.3 error/UnexpectedNullError#.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()) |
| 196 | } |
| 197 | |
| 198 | MySqlValueFormatrust-analyzer cargo sqlx-mysql 0.8.3 value/MySqlValueFormat#::Textrust-analyzer cargo sqlx-mysql 0.8.3 value/MySqlValueFormat#Text# => { |
| 199 | let s = value.as_strrust-analyzer cargo sqlx-mysql 0.8.3 value/impl#[`MySqlValueRef<'r>`]as_str().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 200 | NaiveDaterust-analyzer cargo chrono 0.4.45 naive/date/NaiveDate#::parse_from_strrust-analyzer cargo chrono 0.4.45 naive/date/impl#[NaiveDate]parse_from_str().(s, "%Y-%m-%d").map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#::intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().) |
| 201 | } |
| 202 | } |
| 203 | } |
| 204 | } |
| 205 | |
| 206 | impl Typerust-analyzer cargo sqlx-core 0.8.3 types/Type#<MySqlrust-analyzer cargo sqlx-mysql 0.8.3 database/MySql#> for NaiveDateTimerust-analyzer cargo chrono 0.4.45 naive/datetime/NaiveDateTime# { |
| 207 | fn type_inforust-analyzer cargo sqlx-mysql 0.8.3 types/chrono/impl#[NaiveDateTime][`Type<MySql>`]type_info().() -> MySqlTypeInforust-analyzer cargo sqlx-mysql 0.8.3 type_info/MySqlTypeInfo# { |
| 208 | MySqlTypeInforust-analyzer cargo sqlx-mysql 0.8.3 type_info/MySqlTypeInfo#::binaryrust-analyzer cargo sqlx-mysql 0.8.3 type_info/impl#[MySqlTypeInfo]binary().(ColumnTyperust-analyzer cargo sqlx-mysql 0.8.3 protocol/text/column/ColumnType#::Datetimerust-analyzer cargo sqlx-mysql 0.8.3 protocol/text/column/ColumnType#Datetime#) |
| 209 | } |
| 210 | } |
| 211 | |
| 212 | impl Encoderust-analyzer cargo sqlx-core 0.8.3 encode/Encode#<'_, MySqlrust-analyzer cargo sqlx-mysql 0.8.3 database/MySql#> for NaiveDateTimerust-analyzer cargo chrono 0.4.45 naive/datetime/NaiveDateTime# { |
| 213 | fn encode_by_refrust-analyzer cargo sqlx-mysql 0.8.3 types/chrono/impl#[NaiveDateTime][`Encode<'_, MySql>`]encode_by_ref().(&self, buf: &mut Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8>) -> 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#> { |
| 214 | let len = naive_dt_encoded_lenrust-analyzer cargo sqlx-mysql 0.8.3 types/chrono/naive_dt_encoded_len().(self); |
| 215 | buf.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(len); |
| 216 | |
| 217 | encode_daterust-analyzer cargo sqlx-mysql 0.8.3 types/chrono/encode_date().(&self.daterust-analyzer cargo chrono 0.4.45 naive/datetime/impl#[NaiveDateTime]date().(), buf)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 218 | |
| 219 | if len rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]gt().4 { |
| 220 | encode_timerust-analyzer cargo sqlx-mysql 0.8.3 types/chrono/encode_time().(&self.timerust-analyzer cargo chrono 0.4.45 naive/datetime/impl#[NaiveDateTime]time().(), len rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]gt().7, buf); |
| 221 | } |
| 222 | |
| 223 | 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#) |
| 224 | } |
| 225 | |
| 226 | fn size_hintrust-analyzer cargo sqlx-mysql 0.8.3 types/chrono/impl#[NaiveDateTime][`Encode<'_, MySql>`]size_hint().(&self) -> usize { |
| 227 | naive_dt_encoded_lenrust-analyzer cargo sqlx-mysql 0.8.3 types/chrono/naive_dt_encoded_len().(self) as usize 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().1 // plus length byte |
| 228 | } |
| 229 | } |
| 230 | |
| 231 | impl<'r> Decoderust-analyzer cargo sqlx-core 0.8.3 decode/Decode#<'r, MySqlrust-analyzer cargo sqlx-mysql 0.8.3 database/MySql#> for NaiveDateTimerust-analyzer cargo chrono 0.4.45 naive/datetime/NaiveDateTime# { |
| 232 | fn decoderust-analyzer cargo sqlx-mysql 0.8.3 types/chrono/impl#[NaiveDateTime][`Decode<'r, MySql>`]decode().(value: MySqlValueRefrust-analyzer cargo sqlx-mysql 0.8.3 value/MySqlValueRef#<'r>) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo sqlx-mysql 0.8.3 types/chrono/impl#[NaiveDateTime][`Decode<'r, MySql>`], BoxDynErrorrust-analyzer cargo sqlx-core 0.8.3 error/BoxDynError#> { |
| 233 | match value.formatrust-analyzer cargo sqlx-mysql 0.8.3 value/impl#[`MySqlValueRef<'r>`]format().() { |
| 234 | MySqlValueFormatrust-analyzer cargo sqlx-mysql 0.8.3 value/MySqlValueFormat#::Binaryrust-analyzer cargo sqlx-mysql 0.8.3 value/MySqlValueFormat#Binary# => { |
| 235 | let buf = value.as_bytesrust-analyzer cargo sqlx-mysql 0.8.3 value/impl#[`MySqlValueRef<'r>`]as_bytes().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 236 | |
| 237 | if buf.is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]is_empty().() { |
| 238 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("empty buffer".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()); |
| 239 | } |
| 240 | |
| 241 | let len = buf[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().; |
| 242 | let date = decode_daterust-analyzer cargo sqlx-mysql 0.8.3 types/chrono/decode_date().(&buf[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()..ok_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]ok_or().(UnexpectedNullErrorrust-analyzer cargo sqlx-core 0.8.3 error/UnexpectedNullError#)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 243 | |
| 244 | let dt = if len rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]gt().4 { |
| 245 | date.and_timerust-analyzer cargo chrono 0.4.45 naive/date/impl#[NaiveDate]and_time().(decode_timerust-analyzer cargo sqlx-mysql 0.8.3 types/chrono/decode_time().(len rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Sub<Self>`]sub().4, &buf[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().5..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().) |
| 246 | } else { |
| 247 | date.and_hms_optrust-analyzer cargo chrono 0.4.45 naive/date/impl#[NaiveDate]and_hms_opt().(0, 0, 0) |
| 248 | .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]expect().("expected `NaiveDate::and_hms_opt(0, 0, 0)` to be valid") |
| 249 | }; |
| 250 | |
| 251 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(dt) |
| 252 | } |
| 253 | |
| 254 | MySqlValueFormatrust-analyzer cargo sqlx-mysql 0.8.3 value/MySqlValueFormat#::Textrust-analyzer cargo sqlx-mysql 0.8.3 value/MySqlValueFormat#Text# => { |
| 255 | let s = value.as_strrust-analyzer cargo sqlx-mysql 0.8.3 value/impl#[`MySqlValueRef<'r>`]as_str().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 256 | NaiveDateTimerust-analyzer cargo chrono 0.4.45 naive/datetime/NaiveDateTime#::parse_from_strrust-analyzer cargo chrono 0.4.45 naive/datetime/impl#[NaiveDateTime]parse_from_str().(s, "%Y-%m-%d %H:%M:%S%.f").map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#::intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().) |
| 257 | } |
| 258 | } |
| 259 | } |
| 260 | } |
| 261 | |
| 262 | fn encode_daterust-analyzer cargo sqlx-mysql 0.8.3 types/chrono/encode_date().(date: &NaiveDaterust-analyzer cargo chrono 0.4.45 naive/date/NaiveDate#, buf: &mut Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8>) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), BoxDynErrorrust-analyzer cargo sqlx-core 0.8.3 error/BoxDynError#> { |
| 263 | // MySQL supports years 1000 - 9999 |
| 264 | let year = u16::try_fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[u16][`TryFrom<i32>`]try_from().(date.yearrust-analyzer cargo chrono 0.4.45 naive/date/impl#[NaiveDate][Datelike]year().()) |
| 265 | .map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|_| formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("NaiveDateTime out of range for Mysql: {date}"))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 266 | |
| 267 | buf.extend_from_slicerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]extend_from_slice().(&year.to_le_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u16]to_le_bytes().()); |
| 268 | |
| 269 | // `NaiveDate` guarantees the ranges of these values |
| 270 | #[allow(clippy::cast_possible_truncation)] |
| 271 | { |
| 272 | buf.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(date.monthrust-analyzer cargo chrono 0.4.45 naive/date/impl#[NaiveDate][Datelike]month().() as u8); |
| 273 | buf.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(date.dayrust-analyzer cargo chrono 0.4.45 naive/date/impl#[NaiveDate][Datelike]day().() as u8); |
| 274 | } |
| 275 | |
| 276 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 277 | } |
| 278 | |
| 279 | fn decode_daterust-analyzer cargo sqlx-mysql 0.8.3 types/chrono/decode_date().(mut buf: &[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#<NaiveDaterust-analyzer cargo chrono 0.4.45 naive/date/NaiveDate#>, BoxDynErrorrust-analyzer cargo sqlx-core 0.8.3 error/BoxDynError#> { |
| 280 | match buf.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() { |
| 281 | // MySQL specifies that if there are no bytes, this is all zeros |
| 282 | 0 => 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#), |
| 283 | 4..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom# => { |
| 284 | let year = buf.get_u16_lerust-analyzer cargo bytes 1.12.1 buf/buf_impl/Buf#get_u16_le().() as i32; |
| 285 | let month = buf[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). as u32; |
| 286 | let day = buf[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().1]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). as u32; |
| 287 | |
| 288 | let date = NaiveDaterust-analyzer cargo chrono 0.4.45 naive/date/NaiveDate#::from_ymd_optrust-analyzer cargo chrono 0.4.45 naive/date/impl#[NaiveDate]from_ymd_opt().(year, month, day) |
| 289 | .ok_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]ok_or_else().(|| formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("server returned invalid date: {year}/{month}/{day}"))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 290 | |
| 291 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(date)) |
| 292 | } |
| 293 | len => Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("expected at least 4 bytes for date, got {len}").intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()), |
| 294 | } |
| 295 | } |
| 296 | |
| 297 | fn encode_timerust-analyzer cargo sqlx-mysql 0.8.3 types/chrono/encode_time().(time: &NaiveTimerust-analyzer cargo chrono 0.4.45 naive/time/NaiveTime#, include_micros: bool, buf: &mut Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8>) { |
| 298 | // `NaiveTime` API guarantees the ranges of these values |
| 299 | #[allow(clippy::cast_possible_truncation)] |
| 300 | { |
| 301 | buf.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(time.hourrust-analyzer cargo chrono 0.4.45 naive/time/impl#[NaiveTime][Timelike]hour().() as u8); |
| 302 | buf.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(time.minuterust-analyzer cargo chrono 0.4.45 naive/time/impl#[NaiveTime][Timelike]minute().() as u8); |
| 303 | buf.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(time.secondrust-analyzer cargo chrono 0.4.45 naive/time/impl#[NaiveTime][Timelike]second().() as u8); |
| 304 | } |
| 305 | |
| 306 | if include_micros { |
| 307 | buf.extendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Extend<T>`]extend().((time.nanosecondrust-analyzer cargo chrono 0.4.45 naive/time/impl#[NaiveTime][Timelike]nanosecond().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Div<Self>`]div().1000).to_le_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]to_le_bytes().()); |
| 308 | } |
| 309 | } |
| 310 | |
| 311 | fn decode_timerust-analyzer cargo sqlx-mysql 0.8.3 types/chrono/decode_time().(len: u8, mut buf: &[u8]) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<NaiveTimerust-analyzer cargo chrono 0.4.45 naive/time/NaiveTime#, BoxDynErrorrust-analyzer cargo sqlx-core 0.8.3 error/BoxDynError#> { |
| 312 | let hour = buf.get_u8rust-analyzer cargo bytes 1.12.1 buf/buf_impl/Buf#get_u8().(); |
| 313 | let minute = buf.get_u8rust-analyzer cargo bytes 1.12.1 buf/buf_impl/Buf#get_u8().(); |
| 314 | let seconds = buf.get_u8rust-analyzer cargo bytes 1.12.1 buf/buf_impl/Buf#get_u8().(); |
| 315 | |
| 316 | let micros = if len rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]gt().3 { |
| 317 | // microseconds : int<EOF> |
| 318 | buf.get_uint_lerust-analyzer cargo bytes 1.12.1 buf/buf_impl/Buf#get_uint_le().(buf.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().()) |
| 319 | } else { |
| 320 | 0 |
| 321 | }; |
| 322 | |
| 323 | let micros = u32::try_fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[u32][`TryFrom<u64>`]try_from().(micros) |
| 324 | .map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|_| formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("server returned microseconds out of range: {micros}"))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 325 | |
| 326 | NaiveTimerust-analyzer cargo chrono 0.4.45 naive/time/NaiveTime#::from_hms_micro_optrust-analyzer cargo chrono 0.4.45 naive/time/impl#[NaiveTime]from_hms_micro_opt().(hour as u32, minute as u32, seconds as u32, micros) |
| 327 | .ok_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]ok_or_else().(|| formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("server returned invalid time: {hour:02}:{minute:02}:{seconds:02}; micros: {micros}").intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()) |
| 328 | } |
| 329 | |
| 330 | #[inline(always)] |
| 331 | fn naive_dt_encoded_lenrust-analyzer cargo sqlx-mysql 0.8.3 types/chrono/naive_dt_encoded_len().(time: &NaiveDateTimerust-analyzer cargo chrono 0.4.45 naive/datetime/NaiveDateTime#) -> u8 { |
| 332 | // to save space the packet can be compressed: |
| 333 | match ( |
| 334 | time.hourrust-analyzer cargo chrono 0.4.45 naive/datetime/impl#[NaiveDateTime][Timelike]hour().(), |
| 335 | time.minuterust-analyzer cargo chrono 0.4.45 naive/datetime/impl#[NaiveDateTime][Timelike]minute().(), |
| 336 | time.secondrust-analyzer cargo chrono 0.4.45 naive/datetime/impl#[NaiveDateTime][Timelike]second().(), |
| 337 | #[allow(deprecated)] |
| 338 | time.timestamp_subsec_nanosrust-analyzer cargo chrono 0.4.45 naive/datetime/impl#[NaiveDateTime]timestamp_subsec_nanos().(), |
| 339 | ) { |
| 340 | // if hour, minutes, seconds and micro_seconds are all 0, |
| 341 | // length is 4 and no other field is sent |
| 342 | (0, 0, 0, 0) => 4, |
| 343 | |
| 344 | // if micro_seconds is 0, length is 7 |
| 345 | // and micro_seconds is not sent |
| 346 | (_, _, _, 0) => 7, |
| 347 | |
| 348 | // otherwise length is 11 |
| 349 | (_, _, _, _) => 11, |
| 350 | } |
| 351 | } |
| 352 | |
| 353 | #[inline(always)] |
| 354 | fn naive_time_encoded_lenrust-analyzer cargo sqlx-mysql 0.8.3 types/chrono/naive_time_encoded_len().(time: &NaiveTimerust-analyzer cargo chrono 0.4.45 naive/time/NaiveTime#) -> u8 { |
| 355 | if time.nanosecondrust-analyzer cargo chrono 0.4.45 naive/time/impl#[NaiveTime][Timelike]nanosecond().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]eq().0 { |
| 356 | // if micro_seconds is 0, length is 8 and micro_seconds is not sent |
| 357 | 8 |
| 358 | } else { |
| 359 | // otherwise length is 12 |
| 360 | 12 |
| 361 | } |
| 362 | } |