Debian Codegraph @

src/time_03.rs

raw symbols SCIP
1 use bytesrust-analyzer cargo bytes 1.11.1 crate/::BytesMutrust-analyzer cargo bytes 1.11.1 bytes_mut/BytesMut#;
2 use postgres_protocolrust-analyzer cargo postgres-protocol 0.6.12 crate/::typesrust-analyzer cargo postgres-protocol 0.6.12 types/;
3 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#;
4 use time_03rust-analyzer cargo time 0.3.45 crate/::{Daterust-analyzer cargo time 0.3.45 date/Date#, Durationrust-analyzer cargo time 0.3.45 duration/Duration#, OffsetDateTimerust-analyzer cargo time 0.3.45 offset_date_time/OffsetDateTime#, PrimitiveDateTimerust-analyzer cargo time 0.3.45 primitive_date_time/PrimitiveDateTime#, Timerust-analyzer cargo time 0.3.45 time/Time#, UtcOffsetrust-analyzer cargo time 0.3.45 utc_offset/UtcOffset#};
5
6 use craterust-analyzer cargo postgres-types 0.2.14 crate/::{FromSqlrust-analyzer cargo postgres-types 0.2.14 FromSql#, IsNullrust-analyzer cargo postgres-types 0.2.14 IsNull#, ToSqlrust-analyzer cargo postgres-types 0.2.14 ToSql#, Typerust-analyzer cargo postgres-types 0.2.14 Type#};
7
8 fn baserust-analyzer cargo postgres-types 0.2.14 time_03/base().() -> PrimitiveDateTimerust-analyzer cargo time 0.3.45 primitive_date_time/PrimitiveDateTime# {
9 PrimitiveDateTimerust-analyzer cargo time 0.3.45 primitive_date_time/PrimitiveDateTime#::newrust-analyzer cargo time 0.3.45 primitive_date_time/impl#[PrimitiveDateTime]new().(Daterust-analyzer cargo time 0.3.45 date/Date#::from_ordinal_daterust-analyzer cargo time 0.3.45 date/impl#[Date]from_ordinal_date().(2000, 1).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), Timerust-analyzer cargo time 0.3.45 time/Time#::MIDNIGHTrust-analyzer cargo time 0.3.45 time/impl#[Time]MIDNIGHT.)
10 }
11
12 impl<'a> FromSqlrust-analyzer cargo postgres-types 0.2.14 FromSql#<'a> for PrimitiveDateTimerust-analyzer cargo time 0.3.45 primitive_date_time/PrimitiveDateTime# {
13 fn from_sqlrust-analyzer cargo postgres-types 0.2.14 time_03/impl#[PrimitiveDateTime][`FromSql<'a>`]from_sql().(_: &Typerust-analyzer cargo postgres-types 0.2.14 Type#, raw: &[u8]) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<PrimitiveDateTimerust-analyzer cargo time 0.3.45 primitive_date_time/PrimitiveDateTime#, 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#>> {
14 let t = 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().;
15 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(baserust-analyzer cargo postgres-types 0.2.14 time_03/base().()
16 .checked_addrust-analyzer cargo time 0.3.45 primitive_date_time/impl#[PrimitiveDateTime]checked_add().(Durationrust-analyzer cargo time 0.3.45 duration/Duration#::microsecondsrust-analyzer cargo time 0.3.45 duration/impl#[Duration]microseconds().(t))
17 .ok_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]ok_or().("value too large to decode")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().)
18 }
19
20 acceptsrust-analyzer cargo postgres-types 0.2.14 accepts!!(TIMESTAMPrust-analyzer cargo postgres-types 0.2.14 type_gen/impl#[Type]TIMESTAMP.);
21 }
22
23 impl ToSqlrust-analyzer cargo postgres-types 0.2.14 ToSql# for PrimitiveDateTimerust-analyzer cargo time 0.3.45 primitive_date_time/PrimitiveDateTime# {
24 fn to_sqlrust-analyzer cargo postgres-types 0.2.14 time_03/impl#[PrimitiveDateTime][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#>> {
25 let time = match i64::try_fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[i64][`TryFrom<i128>`]try_from().((*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.45 primitive_date_time/impl#[PrimitiveDateTime][`Sub<Self>`]sub().-rust-analyzer cargo time 0.3.45 primitive_date_time/impl#[PrimitiveDateTime][`Sub<Self>`]sub(). rust-analyzer cargo time 0.3.45 primitive_date_time/impl#[PrimitiveDateTime][`Sub<Self>`]sub().baserust-analyzer cargo postgres-types 0.2.14 time_03/base().()).whole_microsecondsrust-analyzer cargo time 0.3.45 duration/impl#[Duration]whole_microseconds().()) {
26 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(time) => time,
27 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(_) => return 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().()),
28 };
29 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);
30 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#)
31 }
32
33 acceptsrust-analyzer cargo postgres-types 0.2.14 accepts!!(TIMESTAMPrust-analyzer cargo postgres-types 0.2.14 type_gen/impl#[Type]TIMESTAMP.);
34 to_sql_checkedrust-analyzer cargo postgres-types 0.2.14 to_sql_checked!!();
35 }
36
37 impl<'a> FromSqlrust-analyzer cargo postgres-types 0.2.14 FromSql#<'a> for OffsetDateTimerust-analyzer cargo time 0.3.45 offset_date_time/OffsetDateTime# {
38 fn from_sqlrust-analyzer cargo postgres-types 0.2.14 time_03/impl#[OffsetDateTime][`FromSql<'a>`]from_sql().(type_: &Typerust-analyzer cargo postgres-types 0.2.14 Type#, raw: &[u8]) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<OffsetDateTimerust-analyzer cargo time 0.3.45 offset_date_time/OffsetDateTime#, 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#>> {
39 let primitive = PrimitiveDateTimerust-analyzer cargo time 0.3.45 primitive_date_time/PrimitiveDateTime#::from_sqlrust-analyzer cargo postgres-types 0.2.14 time_03/impl#[PrimitiveDateTime][`FromSql<'a>`]from_sql().(type_, raw)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
40 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(primitive.assume_utcrust-analyzer cargo time 0.3.45 primitive_date_time/impl#[PrimitiveDateTime]assume_utc().())
41 }
42
43 acceptsrust-analyzer cargo postgres-types 0.2.14 accepts!!(TIMESTAMPTZrust-analyzer cargo postgres-types 0.2.14 type_gen/impl#[Type]TIMESTAMPTZ.);
44 }
45
46 impl ToSqlrust-analyzer cargo postgres-types 0.2.14 ToSql# for OffsetDateTimerust-analyzer cargo time 0.3.45 offset_date_time/OffsetDateTime# {
47 fn to_sqlrust-analyzer cargo postgres-types 0.2.14 time_03/impl#[OffsetDateTime][ToSql]to_sql().(
48 &self,
49 type_: &Typerust-analyzer cargo postgres-types 0.2.14 Type#,
50 w: &mut BytesMutrust-analyzer cargo bytes 1.11.1 bytes_mut/BytesMut#,
51 ) -> 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#>> {
52 let utc_datetime = self.to_offsetrust-analyzer cargo time 0.3.45 offset_date_time/impl#[OffsetDateTime]to_offset().(UtcOffsetrust-analyzer cargo time 0.3.45 utc_offset/UtcOffset#::UTCrust-analyzer cargo time 0.3.45 utc_offset/impl#[UtcOffset]UTC.);
53 let date = utc_datetime.daterust-analyzer cargo time 0.3.45 offset_date_time/impl#[OffsetDateTime]date().();
54 let time = utc_datetime.timerust-analyzer cargo time 0.3.45 offset_date_time/impl#[OffsetDateTime]time().();
55 let primitive = PrimitiveDateTimerust-analyzer cargo time 0.3.45 primitive_date_time/PrimitiveDateTime#::newrust-analyzer cargo time 0.3.45 primitive_date_time/impl#[PrimitiveDateTime]new().(date, time);
56 primitive.to_sqlrust-analyzer cargo postgres-types 0.2.14 time_03/impl#[PrimitiveDateTime][ToSql]to_sql().(type_, w)
57 }
58
59 acceptsrust-analyzer cargo postgres-types 0.2.14 accepts!!(TIMESTAMPTZrust-analyzer cargo postgres-types 0.2.14 type_gen/impl#[Type]TIMESTAMPTZ.);
60 to_sql_checkedrust-analyzer cargo postgres-types 0.2.14 to_sql_checked!!();
61 }
62
63 impl<'a> FromSqlrust-analyzer cargo postgres-types 0.2.14 FromSql#<'a> for Daterust-analyzer cargo time 0.3.45 date/Date# {
64 fn from_sqlrust-analyzer cargo postgres-types 0.2.14 time_03/impl#[Date][`FromSql<'a>`]from_sql().(_: &Typerust-analyzer cargo postgres-types 0.2.14 Type#, raw: &[u8]) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Daterust-analyzer cargo time 0.3.45 date/Date#, 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#>> {
65 let jd = typesrust-analyzer cargo postgres-protocol 0.6.12 types/::date_from_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/date_from_sql().(raw)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
66 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(baserust-analyzer cargo postgres-types 0.2.14 time_03/base().()
67 .daterust-analyzer cargo time 0.3.45 primitive_date_time/impl#[PrimitiveDateTime]date().()
68 .checked_addrust-analyzer cargo time 0.3.45 date/impl#[Date]checked_add().(Durationrust-analyzer cargo time 0.3.45 duration/Duration#::daysrust-analyzer cargo time 0.3.45 duration/impl#[Duration]days().(i64::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[i64][`From<i32>`]from().(jd)))
69 .ok_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]ok_or().("value too large to decode")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().)
70 }
71
72 acceptsrust-analyzer cargo postgres-types 0.2.14 accepts!!(DATErust-analyzer cargo postgres-types 0.2.14 type_gen/impl#[Type]DATE.);
73 }
74
75 impl ToSqlrust-analyzer cargo postgres-types 0.2.14 ToSql# for Daterust-analyzer cargo time 0.3.45 date/Date# {
76 fn to_sqlrust-analyzer cargo postgres-types 0.2.14 time_03/impl#[Date][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#>> {
77 let jd = (*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.45 date/impl#[Date][`Sub<Self>`]sub().-rust-analyzer cargo time 0.3.45 date/impl#[Date][`Sub<Self>`]sub(). rust-analyzer cargo time 0.3.45 date/impl#[Date][`Sub<Self>`]sub().baserust-analyzer cargo postgres-types 0.2.14 time_03/base().().daterust-analyzer cargo time 0.3.45 primitive_date_time/impl#[PrimitiveDateTime]date().()).whole_daysrust-analyzer cargo time 0.3.45 duration/impl#[Duration]whole_days().();
78 let jd = i32::try_fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[i32][`TryFrom<i64>`]try_from().(jd).map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|_| "value too large to transmit")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
79
80 typesrust-analyzer cargo postgres-protocol 0.6.12 types/::date_to_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/date_to_sql().(jd, w);
81 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#)
82 }
83
84 acceptsrust-analyzer cargo postgres-types 0.2.14 accepts!!(DATErust-analyzer cargo postgres-types 0.2.14 type_gen/impl#[Type]DATE.);
85 to_sql_checkedrust-analyzer cargo postgres-types 0.2.14 to_sql_checked!!();
86 }
87
88 impl<'a> FromSqlrust-analyzer cargo postgres-types 0.2.14 FromSql#<'a> for Timerust-analyzer cargo time 0.3.45 time/Time# {
89 fn from_sqlrust-analyzer cargo postgres-types 0.2.14 time_03/impl#[Time][`FromSql<'a>`]from_sql().(_: &Typerust-analyzer cargo postgres-types 0.2.14 Type#, raw: &[u8]) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Timerust-analyzer cargo time 0.3.45 time/Time#, 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#>> {
90 let usec = typesrust-analyzer cargo postgres-protocol 0.6.12 types/::time_from_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/time_from_sql().(raw)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
91 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Timerust-analyzer cargo time 0.3.45 time/Time#::MIDNIGHTrust-analyzer cargo time 0.3.45 time/impl#[Time]MIDNIGHT. rust-analyzer cargo time 0.3.45 time/impl#[Time][`Add<Duration>`]add().+rust-analyzer cargo time 0.3.45 time/impl#[Time][`Add<Duration>`]add(). rust-analyzer cargo time 0.3.45 time/impl#[Time][`Add<Duration>`]add().Durationrust-analyzer cargo time 0.3.45 duration/Duration#::microsecondsrust-analyzer cargo time 0.3.45 duration/impl#[Duration]microseconds().(usec))
92 }
93
94 acceptsrust-analyzer cargo postgres-types 0.2.14 accepts!!(TIMErust-analyzer cargo postgres-types 0.2.14 type_gen/impl#[Type]TIME.);
95 }
96
97 impl ToSqlrust-analyzer cargo postgres-types 0.2.14 ToSql# for Timerust-analyzer cargo time 0.3.45 time/Time# {
98 fn to_sqlrust-analyzer cargo postgres-types 0.2.14 time_03/impl#[Time][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#>> {
99 let delta = *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.45 time/impl#[Time][`Sub<Self>`]sub().-rust-analyzer cargo time 0.3.45 time/impl#[Time][`Sub<Self>`]sub(). rust-analyzer cargo time 0.3.45 time/impl#[Time][`Sub<Self>`]sub().Timerust-analyzer cargo time 0.3.45 time/Time#::MIDNIGHTrust-analyzer cargo time 0.3.45 time/impl#[Time]MIDNIGHT.;
100 let time = match i64::try_fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[i64][`TryFrom<i128>`]try_from().(delta.whole_microsecondsrust-analyzer cargo time 0.3.45 duration/impl#[Duration]whole_microseconds().()) {
101 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(time) => time,
102 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(_) => return 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().()),
103 };
104 typesrust-analyzer cargo postgres-protocol 0.6.12 types/::time_to_sqlrust-analyzer cargo postgres-protocol 0.6.12 types/time_to_sql().(time, w);
105 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#)
106 }
107
108 acceptsrust-analyzer cargo postgres-types 0.2.14 accepts!!(TIMErust-analyzer cargo postgres-types 0.2.14 type_gen/impl#[Type]TIME.);
109 to_sql_checkedrust-analyzer cargo postgres-types 0.2.14 to_sql_checked!!();
110 }