Debian Codegraph @

src/serialize.rs

raw symbols SCIP
1 pub(craterust-analyzer cargo railway-core 0.3.0 crate/) mod durationrust-analyzer cargo railway-core 0.3.0 serialize/duration/ {
2 use chronorust-analyzer cargo chrono 0.4.42 crate/::Durationrust-analyzer cargo chrono 0.4.42 Duration#;
3 use serderust-analyzer cargo serde 1.0.228 crate/::{Deserializerust-analyzer cargo serde_core 1.0.228 de/Deserialize#, Deserializerrust-analyzer cargo serde_core 1.0.228 de/Deserializer#, Serializerrust-analyzer cargo serde_core 1.0.228 ser/Serializer#};
4
5 pub(craterust-analyzer cargo railway-core 0.3.0 crate/) fn serializerust-analyzer cargo railway-core 0.3.0 serialize/duration/serialize().<S>(v: &Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Durationrust-analyzer cargo chrono 0.4.42 Duration#>, s: S) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<S::Okrust-analyzer cargo serde_core 1.0.228 ser/Serializer#Ok#, S::Errorrust-analyzer cargo serde_core 1.0.228 ser/Serializer#Error#>
6 where
7 S: Serializerrust-analyzer cargo serde_core 1.0.228 ser/Serializer#,
8 {
9 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(d) = v {
10 s.serialize_somerust-analyzer cargo serde_core 1.0.228 ser/Serializer#serialize_some().(&d.num_minutesrust-analyzer cargo chrono 0.4.42 time_delta/impl#[TimeDelta]num_minutes().())
11 } else {
12 s.serialize_nonerust-analyzer cargo serde_core 1.0.228 ser/Serializer#serialize_none().()
13 }
14 }
15
16 pub(craterust-analyzer cargo railway-core 0.3.0 crate/) fn deserializerust-analyzer cargo railway-core 0.3.0 serialize/duration/deserialize().<'de, D>(d: D) -> 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#<Durationrust-analyzer cargo chrono 0.4.42 Duration#>, D::Errorrust-analyzer cargo serde_core 1.0.228 de/Deserializer#Error#>
17 where
18 D: Deserializerrust-analyzer cargo serde_core 1.0.228 de/Deserializer#<'de>,
19 {
20 let v = Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#::<i64>::deserializerust-analyzer cargo serde_core 1.0.228 de/impls/impl#[`Option<T>`][`Deserialize<'de>`]deserialize().(d)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
21 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(v.maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(Durationrust-analyzer cargo chrono 0.4.42 Duration#::minutesrust-analyzer cargo chrono 0.4.42 time_delta/impl#[TimeDelta]minutes().))
22 }
23 }
24
25 pub(craterust-analyzer cargo railway-core 0.3.0 crate/) mod datetime_with_timezonerust-analyzer cargo railway-core 0.3.0 serialize/datetime_with_timezone/ {
26 use chronorust-analyzer cargo chrono 0.4.42 crate/::{DateTimerust-analyzer cargo chrono 0.4.42 datetime/DateTime#, NaiveDateTimerust-analyzer cargo chrono 0.4.42 naive/datetime/NaiveDateTime#};
27 use chrono_tzrust-analyzer cargo chrono-tz 0.10.4 crate/::Tzrust-analyzer cargo chrono-tz 0.10.4 prebuilt/timezones/Tz#;
28 use serderust-analyzer cargo serde 1.0.228 crate/::{Deserializerust-analyzer cargo serde_core 1.0.228 de/Deserialize#, Deserializerrust-analyzer cargo serde_core 1.0.228 de/Deserializer#, Serializerrust-analyzer cargo serde_core 1.0.228 ser/Serializer#};
29
30 pub(craterust-analyzer cargo railway-core 0.3.0 crate/) fn serializerust-analyzer cargo railway-core 0.3.0 serialize/datetime_with_timezone/serialize().<S>(v: &Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<DateTimerust-analyzer cargo chrono 0.4.42 datetime/DateTime#<Tzrust-analyzer cargo chrono-tz 0.10.4 prebuilt/timezones/Tz#>>, s: S) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<S::Okrust-analyzer cargo serde_core 1.0.228 ser/Serializer#Ok#, S::Errorrust-analyzer cargo serde_core 1.0.228 ser/Serializer#Error#>
31 where
32 S: Serializerrust-analyzer cargo serde_core 1.0.228 ser/Serializer#,
33 {
34 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(d) = v {
35 let tz = d.timezonerust-analyzer cargo chrono 0.4.42 datetime/impl#[`DateTime<Tz>`]timezone().().to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().();
36 let naive = d.naive_utcrust-analyzer cargo chrono 0.4.42 datetime/impl#[`DateTime<Tz>`]naive_utc().();
37 s.serialize_somerust-analyzer cargo serde_core 1.0.228 ser/Serializer#serialize_some().(&(naive, tz))
38 } else {
39 s.serialize_nonerust-analyzer cargo serde_core 1.0.228 ser/Serializer#serialize_none().()
40 }
41 }
42
43 pub(craterust-analyzer cargo railway-core 0.3.0 crate/) fn deserializerust-analyzer cargo railway-core 0.3.0 serialize/datetime_with_timezone/deserialize().<'de, D>(d: D) -> 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#<DateTimerust-analyzer cargo chrono 0.4.42 datetime/DateTime#<Tzrust-analyzer cargo chrono-tz 0.10.4 prebuilt/timezones/Tz#>>, D::Errorrust-analyzer cargo serde_core 1.0.228 de/Deserializer#Error#>
44 where
45 D: Deserializerrust-analyzer cargo serde_core 1.0.228 de/Deserializer#<'de>,
46 {
47 let v = Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#::<(NaiveDateTimerust-analyzer cargo chrono 0.4.42 naive/datetime/NaiveDateTime#, Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#)>::deserializerust-analyzer cargo serde_core 1.0.228 de/impls/impl#[`Option<T>`][`Deserialize<'de>`]deserialize().(d)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
48 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((d, tz)) = v {
49 let tz = tz
50 .parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().()
51 .map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|_| serderust-analyzer cargo serde 1.0.228 crate/::derust-analyzer cargo serde_core 1.0.228 de/::Errorrust-analyzer cargo serde_core 1.0.228 de/Error#::customrust-analyzer cargo serde_core 1.0.228 de/Error#custom().("Failed to parse timezone"))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/try_trait/Try#branch().;
52 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#(d.and_utcrust-analyzer cargo chrono 0.4.42 naive/datetime/impl#[NaiveDateTime]and_utc().().with_timezonerust-analyzer cargo chrono 0.4.42 datetime/impl#[`DateTime<Tz>`]with_timezone().(&tz)))
53 } else {
54 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#)
55 }
56 }
57 }