size_of/support/
chrono.rs1#![cfg(feature = "chrono")]
2
3use crate::{Context, SizeOf};
4use chrono::{
5 format::{
6 Fixed, InternalFixed, InternalNumeric, Item, Numeric, Pad, ParseError, ParseErrorKind,
7 Parsed,
8 },
9 Date, DateTime, Duration, FixedOffset, IsoWeek, Local, LocalResult, Month, Months, NaiveDate,
10 NaiveDateTime, NaiveTime, NaiveWeek, ParseMonthError, ParseWeekdayError, RoundingError,
11 SecondsFormat, TimeZone, Utc, Weekday,
12};
13
14impl_total_size_childless! {
15 Pad,
16 Utc,
17 Local,
18 Fixed,
19 Month,
20 Months,
21 Parsed,
22 Numeric,
23 IsoWeek,
24 Weekday,
25 Duration,
26 NaiveDate,
27 NaiveTime,
28 NaiveWeek,
29 ParseError,
30 FixedOffset,
31 InternalFixed,
32 NaiveDateTime,
33 RoundingError,
34 SecondsFormat,
35 ParseErrorKind,
36 ParseMonthError,
37 InternalNumeric,
38 ParseWeekdayError,
39}
40
41impl<Tz> SizeOf for Date<Tz>
42where
43 Tz: TimeZone,
44 Tz::Offset: SizeOf,
45{
46 fn size_of_children(&self, context: &mut Context) {
47 self.offset().size_of_children(context);
48 }
49}
50
51impl<Tz> SizeOf for DateTime<Tz>
52where
53 Tz: TimeZone,
54 Tz::Offset: SizeOf,
55{
56 fn size_of_children(&self, context: &mut Context) {
57 self.offset().size_of_children(context);
58 }
59}
60
61impl<T> SizeOf for LocalResult<T>
62where
63 T: SizeOf,
64{
65 fn size_of_children(&self, context: &mut Context) {
66 match self {
67 Self::None => {}
68 Self::Single(result) => T::size_of_children(result, context),
69 Self::Ambiguous(first, second) => {
70 T::size_of_children(first, context);
71 T::size_of_children(second, context);
72 }
73 }
74 }
75}
76
77impl SizeOf for Item<'_> {
78 fn size_of_children(&self, context: &mut Context) {
79 match self {
80 &Self::Literal(string) | &Self::Space(string) => string.size_of_children(context),
81 Self::OwnedLiteral(string) | Self::OwnedSpace(string) => {
82 string.size_of_children(context)
83 }
84 Self::Numeric(numeric, pad) => {
85 numeric.size_of_children(context);
86 pad.size_of_children(context);
87 }
88 Self::Fixed(fixed) => fixed.size_of_children(context),
89 Self::Error => {}
90 }
91 }
92}