Skip to main content

time/format_description/
modifier.rs

1//! Various modifiers for components.
2
3use core::num::NonZero;
4
5/// Generate the provided code if and only if `pub` is present.
6macro_rules! if_pub {
7    (pub $(#[$attr:meta])*; $($x:tt)*) => {
8        $(#[$attr])*
9        ///
10        /// This function exists since [`Default::default()`] cannot be used in a `const` context.
11        /// It may be removed once that becomes possible. As the [`Default`] trait is in the
12        /// prelude, removing this function in the future will not cause any resolution failures for
13        /// the overwhelming majority of users; only users who use `#![no_implicit_prelude]` will be
14        /// affected. As such it will not be considered a breaking change.
15        $($x)*
16    };
17    ($($_:tt)*) => {};
18}
19
20/// Implement `Default` for the given type. This also generates an inherent implementation of a
21/// `default` method that is `const fn`, permitting the default value to be used in const contexts.
22// Every modifier should use this macro rather than a derived `Default`.
23macro_rules! impl_const_default {
24    ($($(#[$doc:meta])* $(@$pub:ident)? $type:ty => $default:expr;)*) => {$(
25        impl $type {
26            if_pub! {
27                $($pub)?
28                $(#[$doc])*;
29                #[inline]
30                pub const fn default() -> Self {
31                    $default
32                }
33            }
34        }
35
36        $(#[$doc])*
37        impl Default for $type {
38            #[inline]
39            fn default() -> Self {
40                $default
41            }
42        }
43    )*};
44}
45
46// Keep this first so that it's shown at the top of documentation.
47impl End {
    #[doc =
    r" Creates a modifier used to represent the end of input, not allowing any trailing input (i.e."]
    #[doc = r" the input must be fully consumed)."]
    ///
    /// This function exists since [`Default::default()`] cannot be used in a `const` context.
    /// It may be removed once that becomes possible. As the [`Default`] trait is in the
    /// prelude, removing this function in the future will not cause any resolution failures for
    /// the overwhelming majority of users; only users who use `#![no_implicit_prelude]` will be
    /// affected. As such it will not be considered a breaking change.
    #[inline]
    pub const fn default() -> Self {
        Self { trailing_input: TrailingInput::Prohibit }
    }
}
#[doc =
r" Creates a modifier used to represent the end of input, not allowing any trailing input (i.e."]
#[doc = r" the input must be fully consumed)."]
impl Default for End {
    #[inline]
    fn default() -> Self { Self { trailing_input: TrailingInput::Prohibit } }
}impl_const_default! {
48    /// Creates a modifier that indicates the value is [padded with zeroes](Padding::Zero).
49    @pub Day => Self { padding: Padding::Zero };
50    /// Creates a modifier that indicates the value uses the
51    /// [`Numerical`](Self::Numerical) representation.
52    MonthRepr => Self::Numerical;
53    /// Creates an instance of this type that indicates the value uses the
54    /// [`Numerical`](MonthRepr::Numerical) representation, is [padded with zeroes](Padding::Zero),
55    /// and is case-sensitive when parsing.
56    @pub Month => Self {
57        padding: Padding::Zero,
58        repr: MonthRepr::Numerical,
59        case_sensitive: true,
60    };
61    /// Creates a modifier that indicates the value is [padded with zeroes](Padding::Zero).
62    @pub Ordinal => Self { padding: Padding::Zero };
63    /// Creates a modifier that indicates the value uses the [`Long`](Self::Long) representation.
64    WeekdayRepr => Self::Long;
65    /// Creates a modifier that indicates the value uses the [`Long`](WeekdayRepr::Long)
66    /// representation and is case-sensitive when parsing. If the representation is changed to a
67    /// numerical one, the instance defaults to one-based indexing.
68    @pub Weekday => Self {
69        repr: WeekdayRepr::Long,
70        one_indexed: true,
71        case_sensitive: true,
72    };
73    /// Creates a modifier that indicates that the value uses the [`Iso`](Self::Iso) representation.
74    WeekNumberRepr => Self::Iso;
75    /// Creates a modifier that indicates that the value is [padded with zeroes](Padding::Zero)
76            /// and uses the [`Iso`](WeekNumberRepr::Iso) representation.
77    @pub WeekNumber => Self {
78        padding: Padding::Zero,
79        repr: WeekNumberRepr::Iso,
80    };
81    /// Creates a modifier that indicates the value uses the [`Full`](Self::Full) representation.
82    YearRepr => Self::Full;
83    /// Creates a modifier that indicates the value uses the [`Extended`](Self::Extended) range.
84    YearRange => Self::Extended;
85    /// Creates a modifier that indicates the value uses the [`Full`](YearRepr::Full)
86    /// representation, is [padded with zeroes](Padding::Zero), uses the Gregorian calendar as its
87    /// base, and only includes the year's sign if necessary.
88    @pub Year => Self {
89        padding: Padding::Zero,
90        repr: YearRepr::Full,
91        range: YearRange::Extended,
92        iso_week_based: false,
93        sign_is_mandatory: false,
94    };
95    /// Creates a modifier that indicates the value is [padded with zeroes](Padding::Zero) and
96    /// has the 24-hour representation.
97    @pub Hour => Self {
98        padding: Padding::Zero,
99        is_12_hour_clock: false,
100    };
101    /// Creates a modifier that indicates the value is [padded with zeroes](Padding::Zero).
102    @pub Minute => Self { padding: Padding::Zero };
103    /// Creates a modifier that indicates the value uses the upper-case representation and is
104    /// case-sensitive when parsing.
105    @pub Period => Self {
106        is_uppercase: true,
107        case_sensitive: true,
108    };
109    /// Creates a modifier that indicates the value is [padded with zeroes](Padding::Zero).
110    @pub Second => Self { padding: Padding::Zero };
111    /// Creates a modifier that indicates the stringified value contains [one or more
112    /// digits](Self::OneOrMore).
113    SubsecondDigits => Self::OneOrMore;
114    /// Creates a modifier that indicates the stringified value contains [one or more
115    /// digits](SubsecondDigits::OneOrMore).
116    @pub Subsecond => Self { digits: SubsecondDigits::OneOrMore };
117    /// Creates a modifier that indicates the value only uses a sign for negative values and is
118    /// [padded with zeroes](Padding::Zero).
119    @pub OffsetHour => Self {
120        sign_is_mandatory: false,
121        padding: Padding::Zero,
122    };
123    /// Creates a modifier that indicates the value is [padded with zeroes](Padding::Zero).
124    @pub OffsetMinute => Self { padding: Padding::Zero };
125    /// Creates a modifier that indicates the value is [padded with zeroes](Padding::Zero).
126    @pub OffsetSecond => Self { padding: Padding::Zero };
127    /// Creates a modifier that indicates the value is [padded with zeroes](Self::Zero).
128    Padding => Self::Zero;
129    /// Creates a modifier that indicates the value represents the [number of seconds](Self::Second)
130    /// since the Unix epoch.
131    UnixTimestampPrecision => Self::Second;
132    /// Creates a modifier that indicates the value represents the [number of
133    /// seconds](UnixTimestampPrecision::Second) since the Unix epoch. The sign is not mandatory.
134    @pub UnixTimestamp => Self {
135        precision: UnixTimestampPrecision::Second,
136        sign_is_mandatory: false,
137    };
138    /// Indicate that any trailing characters after the end of input are prohibited and will cause
139    /// an error when used with `parse`.
140    TrailingInput => Self::Prohibit;
141    /// Creates a modifier used to represent the end of input, not allowing any trailing input (i.e.
142    /// the input must be fully consumed).
143    @pub End => Self { trailing_input: TrailingInput::Prohibit };
144}
145
146/// Day of the month.
147#[non_exhaustive]
148#[derive(#[automatically_derived]
impl ::core::fmt::Debug for Day {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field1_finish(f, "Day",
            "padding", &&self.padding)
    }
}Debug, #[automatically_derived]
impl ::core::clone::Clone for Day {
    #[inline]
    fn clone(&self) -> Day {
        let _: ::core::clone::AssertParamIsClone<Padding>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for Day { }Copy, #[automatically_derived]
impl ::core::cmp::PartialEq for Day {
    #[inline]
    fn eq(&self, other: &Day) -> bool { self.padding == other.padding }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for Day {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_receiver_is_total_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<Padding>;
    }
}Eq)]
149pub struct Day {
150    /// The padding to obtain the minimum width.
151    pub padding: Padding,
152}
153
154impl Day {
155    /// Set the padding type.
156    #[inline]
157    #[must_use = "this returns the result of the operation, without modifying the original"]
158    pub const fn with_padding(self, padding: Padding) -> Self {
159        Self { padding }
160    }
161}
162
163/// The representation of a month.
164#[non_exhaustive]
165#[derive(#[automatically_derived]
impl ::core::fmt::Debug for MonthRepr {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                MonthRepr::Numerical => "Numerical",
                MonthRepr::Long => "Long",
                MonthRepr::Short => "Short",
            })
    }
}Debug, #[automatically_derived]
impl ::core::clone::Clone for MonthRepr {
    #[inline]
    fn clone(&self) -> MonthRepr { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for MonthRepr { }Copy, #[automatically_derived]
impl ::core::cmp::PartialEq for MonthRepr {
    #[inline]
    fn eq(&self, other: &MonthRepr) -> bool {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        __self_discr == __arg1_discr
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for MonthRepr {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_receiver_is_total_eq(&self) {}
}Eq)]
166pub enum MonthRepr {
167    /// The number of the month (January is 1, December is 12).
168    Numerical,
169    /// The long form of the month name (e.g. "January").
170    Long,
171    /// The short form of the month name (e.g. "Jan").
172    Short,
173}
174
175/// Month of the year.
176#[non_exhaustive]
177#[derive(#[automatically_derived]
impl ::core::fmt::Debug for Month {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field3_finish(f, "Month",
            "padding", &self.padding, "repr", &self.repr, "case_sensitive",
            &&self.case_sensitive)
    }
}Debug, #[automatically_derived]
impl ::core::clone::Clone for Month {
    #[inline]
    fn clone(&self) -> Month {
        let _: ::core::clone::AssertParamIsClone<Padding>;
        let _: ::core::clone::AssertParamIsClone<MonthRepr>;
        let _: ::core::clone::AssertParamIsClone<bool>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for Month { }Copy, #[automatically_derived]
impl ::core::cmp::PartialEq for Month {
    #[inline]
    fn eq(&self, other: &Month) -> bool {
        self.case_sensitive == other.case_sensitive &&
                self.padding == other.padding && self.repr == other.repr
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for Month {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_receiver_is_total_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<Padding>;
        let _: ::core::cmp::AssertParamIsEq<MonthRepr>;
        let _: ::core::cmp::AssertParamIsEq<bool>;
    }
}Eq)]
178pub struct Month {
179    /// The padding to obtain the minimum width.
180    pub padding: Padding,
181    /// What form of representation should be used?
182    pub repr: MonthRepr,
183    /// Is the value case sensitive when parsing?
184    pub case_sensitive: bool,
185}
186
187impl Month {
188    /// Set the padding type.
189    #[inline]
190    #[must_use = "this returns the result of the operation, without modifying the original"]
191    pub const fn with_padding(self, padding: Padding) -> Self {
192        Self { padding, ..self }
193    }
194
195    /// Set the manner in which the month is represented.
196    #[inline]
197    #[must_use = "this returns the result of the operation, without modifying the original"]
198    pub const fn with_repr(self, repr: MonthRepr) -> Self {
199        Self { repr, ..self }
200    }
201
202    /// Set whether the value is case sensitive when parsing.
203    #[inline]
204    #[must_use = "this returns the result of the operation, without modifying the original"]
205    pub const fn with_case_sensitive(self, case_sensitive: bool) -> Self {
206        Self {
207            case_sensitive,
208            ..self
209        }
210    }
211}
212
213/// Ordinal day of the year.
214#[non_exhaustive]
215#[derive(#[automatically_derived]
impl ::core::fmt::Debug for Ordinal {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field1_finish(f, "Ordinal",
            "padding", &&self.padding)
    }
}Debug, #[automatically_derived]
impl ::core::clone::Clone for Ordinal {
    #[inline]
    fn clone(&self) -> Ordinal {
        let _: ::core::clone::AssertParamIsClone<Padding>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for Ordinal { }Copy, #[automatically_derived]
impl ::core::cmp::PartialEq for Ordinal {
    #[inline]
    fn eq(&self, other: &Ordinal) -> bool { self.padding == other.padding }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for Ordinal {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_receiver_is_total_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<Padding>;
    }
}Eq)]
216pub struct Ordinal {
217    /// The padding to obtain the minimum width.
218    pub padding: Padding,
219}
220
221impl Ordinal {
222    /// Set the padding type.
223    #[inline]
224    #[must_use = "this returns the result of the operation, without modifying the original"]
225    pub const fn with_padding(self, padding: Padding) -> Self {
226        Self { padding }
227    }
228}
229
230/// The representation used for the day of the week.
231#[non_exhaustive]
232#[derive(#[automatically_derived]
impl ::core::fmt::Debug for WeekdayRepr {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                WeekdayRepr::Short => "Short",
                WeekdayRepr::Long => "Long",
                WeekdayRepr::Sunday => "Sunday",
                WeekdayRepr::Monday => "Monday",
            })
    }
}Debug, #[automatically_derived]
impl ::core::clone::Clone for WeekdayRepr {
    #[inline]
    fn clone(&self) -> WeekdayRepr { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for WeekdayRepr { }Copy, #[automatically_derived]
impl ::core::cmp::PartialEq for WeekdayRepr {
    #[inline]
    fn eq(&self, other: &WeekdayRepr) -> bool {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        __self_discr == __arg1_discr
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for WeekdayRepr {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_receiver_is_total_eq(&self) {}
}Eq)]
233pub enum WeekdayRepr {
234    /// The short form of the weekday (e.g. "Mon").
235    Short,
236    /// The long form of the weekday (e.g. "Monday").
237    Long,
238    /// A numerical representation using Sunday as the first day of the week.
239    ///
240    /// Sunday is either 0 or 1, depending on the other modifier's value.
241    Sunday,
242    /// A numerical representation using Monday as the first day of the week.
243    ///
244    /// Monday is either 0 or 1, depending on the other modifier's value.
245    Monday,
246}
247
248/// Day of the week.
249#[non_exhaustive]
250#[derive(#[automatically_derived]
impl ::core::fmt::Debug for Weekday {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field3_finish(f, "Weekday",
            "repr", &self.repr, "one_indexed", &self.one_indexed,
            "case_sensitive", &&self.case_sensitive)
    }
}Debug, #[automatically_derived]
impl ::core::clone::Clone for Weekday {
    #[inline]
    fn clone(&self) -> Weekday {
        let _: ::core::clone::AssertParamIsClone<WeekdayRepr>;
        let _: ::core::clone::AssertParamIsClone<bool>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for Weekday { }Copy, #[automatically_derived]
impl ::core::cmp::PartialEq for Weekday {
    #[inline]
    fn eq(&self, other: &Weekday) -> bool {
        self.one_indexed == other.one_indexed &&
                self.case_sensitive == other.case_sensitive &&
            self.repr == other.repr
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for Weekday {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_receiver_is_total_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<WeekdayRepr>;
        let _: ::core::cmp::AssertParamIsEq<bool>;
    }
}Eq)]
251pub struct Weekday {
252    /// What form of representation should be used?
253    pub repr: WeekdayRepr,
254    /// When using a numerical representation, should it be zero or one-indexed?
255    pub one_indexed: bool,
256    /// Is the value case sensitive when parsing?
257    pub case_sensitive: bool,
258}
259
260impl Weekday {
261    /// Set the manner in which the weekday is represented.
262    #[inline]
263    #[must_use = "this returns the result of the operation, without modifying the original"]
264    pub const fn with_repr(self, repr: WeekdayRepr) -> Self {
265        Self { repr, ..self }
266    }
267
268    /// Set whether the value is one-indexed when using a numerical representation.
269    #[inline]
270    #[must_use = "this returns the result of the operation, without modifying the original"]
271    pub const fn with_one_indexed(self, one_indexed: bool) -> Self {
272        Self {
273            one_indexed,
274            ..self
275        }
276    }
277
278    /// Set whether the value is case sensitive when parsing.
279    #[inline]
280    #[must_use = "this returns the result of the operation, without modifying the original"]
281    pub const fn with_case_sensitive(self, case_sensitive: bool) -> Self {
282        Self {
283            case_sensitive,
284            ..self
285        }
286    }
287}
288
289/// The representation used for the week number.
290#[non_exhaustive]
291#[derive(#[automatically_derived]
impl ::core::fmt::Debug for WeekNumberRepr {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                WeekNumberRepr::Iso => "Iso",
                WeekNumberRepr::Sunday => "Sunday",
                WeekNumberRepr::Monday => "Monday",
            })
    }
}Debug, #[automatically_derived]
impl ::core::clone::Clone for WeekNumberRepr {
    #[inline]
    fn clone(&self) -> WeekNumberRepr { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for WeekNumberRepr { }Copy, #[automatically_derived]
impl ::core::cmp::PartialEq for WeekNumberRepr {
    #[inline]
    fn eq(&self, other: &WeekNumberRepr) -> bool {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        __self_discr == __arg1_discr
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for WeekNumberRepr {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_receiver_is_total_eq(&self) {}
}Eq)]
292pub enum WeekNumberRepr {
293    /// Week 1 is the week that contains January 4.
294    Iso,
295    /// Week 1 begins on the first Sunday of the calendar year.
296    Sunday,
297    /// Week 1 begins on the first Monday of the calendar year.
298    Monday,
299}
300
301/// Week within the year.
302#[non_exhaustive]
303#[derive(#[automatically_derived]
impl ::core::fmt::Debug for WeekNumber {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f, "WeekNumber",
            "padding", &self.padding, "repr", &&self.repr)
    }
}Debug, #[automatically_derived]
impl ::core::clone::Clone for WeekNumber {
    #[inline]
    fn clone(&self) -> WeekNumber {
        let _: ::core::clone::AssertParamIsClone<Padding>;
        let _: ::core::clone::AssertParamIsClone<WeekNumberRepr>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for WeekNumber { }Copy, #[automatically_derived]
impl ::core::cmp::PartialEq for WeekNumber {
    #[inline]
    fn eq(&self, other: &WeekNumber) -> bool {
        self.padding == other.padding && self.repr == other.repr
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for WeekNumber {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_receiver_is_total_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<Padding>;
        let _: ::core::cmp::AssertParamIsEq<WeekNumberRepr>;
    }
}Eq)]
304pub struct WeekNumber {
305    /// The padding to obtain the minimum width.
306    pub padding: Padding,
307    /// What kind of representation should be used?
308    pub repr: WeekNumberRepr,
309}
310
311impl WeekNumber {
312    /// Set the padding type.
313    #[inline]
314    #[must_use = "this returns the result of the operation, without modifying the original"]
315    pub const fn with_padding(self, padding: Padding) -> Self {
316        Self { padding, ..self }
317    }
318
319    /// Set the manner in which the week number is represented.
320    #[inline]
321    #[must_use = "this returns the result of the operation, without modifying the original"]
322    pub const fn with_repr(self, repr: WeekNumberRepr) -> Self {
323        Self { repr, ..self }
324    }
325}
326
327/// The representation used for a year value.
328#[non_exhaustive]
329#[derive(#[automatically_derived]
impl ::core::fmt::Debug for YearRepr {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                YearRepr::Full => "Full",
                YearRepr::Century => "Century",
                YearRepr::LastTwo => "LastTwo",
            })
    }
}Debug, #[automatically_derived]
impl ::core::clone::Clone for YearRepr {
    #[inline]
    fn clone(&self) -> YearRepr { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for YearRepr { }Copy, #[automatically_derived]
impl ::core::cmp::PartialEq for YearRepr {
    #[inline]
    fn eq(&self, other: &YearRepr) -> bool {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        __self_discr == __arg1_discr
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for YearRepr {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_receiver_is_total_eq(&self) {}
}Eq)]
330pub enum YearRepr {
331    /// The full value of the year.
332    Full,
333    /// All digits except the last two. Includes the sign, if any.
334    Century,
335    /// Only the last two digits of the year.
336    LastTwo,
337}
338
339/// The range of years that are supported.
340///
341/// This modifier has no effect when the year repr is [`LastTwo`](YearRepr::LastTwo).
342#[non_exhaustive]
343#[derive(#[automatically_derived]
impl ::core::fmt::Debug for YearRange {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                YearRange::Standard => "Standard",
                YearRange::Extended => "Extended",
            })
    }
}Debug, #[automatically_derived]
impl ::core::clone::Clone for YearRange {
    #[inline]
    fn clone(&self) -> YearRange { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for YearRange { }Copy, #[automatically_derived]
impl ::core::cmp::PartialEq for YearRange {
    #[inline]
    fn eq(&self, other: &YearRange) -> bool {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        __self_discr == __arg1_discr
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for YearRange {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_receiver_is_total_eq(&self) {}
}Eq)]
344pub enum YearRange {
345    /// Years between -9999 and 9999 are supported.
346    Standard,
347    /// Years between -999_999 and 999_999 are supported, with the sign being required if the year
348    /// contains more than four digits.
349    ///
350    /// If the `large-dates` feature is not enabled, this variant is equivalent to `Standard`.
351    Extended,
352}
353
354/// Year of the date.
355#[non_exhaustive]
356#[derive(#[automatically_derived]
impl ::core::fmt::Debug for Year {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field5_finish(f, "Year",
            "padding", &self.padding, "repr", &self.repr, "range",
            &self.range, "iso_week_based", &self.iso_week_based,
            "sign_is_mandatory", &&self.sign_is_mandatory)
    }
}Debug, #[automatically_derived]
impl ::core::clone::Clone for Year {
    #[inline]
    fn clone(&self) -> Year {
        let _: ::core::clone::AssertParamIsClone<Padding>;
        let _: ::core::clone::AssertParamIsClone<YearRepr>;
        let _: ::core::clone::AssertParamIsClone<YearRange>;
        let _: ::core::clone::AssertParamIsClone<bool>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for Year { }Copy, #[automatically_derived]
impl ::core::cmp::PartialEq for Year {
    #[inline]
    fn eq(&self, other: &Year) -> bool {
        self.iso_week_based == other.iso_week_based &&
                        self.sign_is_mandatory == other.sign_is_mandatory &&
                    self.padding == other.padding && self.repr == other.repr &&
            self.range == other.range
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for Year {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_receiver_is_total_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<Padding>;
        let _: ::core::cmp::AssertParamIsEq<YearRepr>;
        let _: ::core::cmp::AssertParamIsEq<YearRange>;
        let _: ::core::cmp::AssertParamIsEq<bool>;
    }
}Eq)]
357pub struct Year {
358    /// The padding to obtain the minimum width.
359    pub padding: Padding,
360    /// What kind of representation should be used?
361    pub repr: YearRepr,
362    /// What range of years is supported?
363    pub range: YearRange,
364    /// Whether the value is based on the ISO week number or the Gregorian calendar.
365    pub iso_week_based: bool,
366    /// Whether the `+` sign is present when a positive year contains fewer than five digits.
367    pub sign_is_mandatory: bool,
368}
369
370impl Year {
371    /// Set the padding type.
372    #[inline]
373    #[must_use = "this returns the result of the operation, without modifying the original"]
374    pub const fn with_padding(self, padding: Padding) -> Self {
375        Self { padding, ..self }
376    }
377
378    /// Set the manner in which the year is represented.
379    #[inline]
380    #[must_use = "this returns the result of the operation, without modifying the original"]
381    pub const fn with_repr(self, repr: YearRepr) -> Self {
382        Self { repr, ..self }
383    }
384
385    /// Set the range of years that are supported.
386    #[inline]
387    #[must_use = "this returns the result of the operation, without modifying the original"]
388    pub const fn with_range(self, range: YearRange) -> Self {
389        Self { range, ..self }
390    }
391
392    /// Set whether the year is based on the ISO week number.
393    #[inline]
394    #[must_use = "this returns the result of the operation, without modifying the original"]
395    pub const fn with_iso_week_based(self, iso_week_based: bool) -> Self {
396        Self {
397            iso_week_based,
398            ..self
399        }
400    }
401
402    /// Set whether the `+` sign is mandatory for positive years with fewer than five digits.
403    #[inline]
404    #[must_use = "this returns the result of the operation, without modifying the original"]
405    pub const fn with_sign_is_mandatory(self, sign_is_mandatory: bool) -> Self {
406        Self {
407            sign_is_mandatory,
408            ..self
409        }
410    }
411}
412
413/// Hour of the day.
414#[non_exhaustive]
415#[derive(#[automatically_derived]
impl ::core::fmt::Debug for Hour {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f, "Hour",
            "padding", &self.padding, "is_12_hour_clock",
            &&self.is_12_hour_clock)
    }
}Debug, #[automatically_derived]
impl ::core::clone::Clone for Hour {
    #[inline]
    fn clone(&self) -> Hour {
        let _: ::core::clone::AssertParamIsClone<Padding>;
        let _: ::core::clone::AssertParamIsClone<bool>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for Hour { }Copy, #[automatically_derived]
impl ::core::cmp::PartialEq for Hour {
    #[inline]
    fn eq(&self, other: &Hour) -> bool {
        self.is_12_hour_clock == other.is_12_hour_clock &&
            self.padding == other.padding
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for Hour {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_receiver_is_total_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<Padding>;
        let _: ::core::cmp::AssertParamIsEq<bool>;
    }
}Eq)]
416pub struct Hour {
417    /// The padding to obtain the minimum width.
418    pub padding: Padding,
419    /// Is the hour displayed using a 12 or 24-hour clock?
420    pub is_12_hour_clock: bool,
421}
422
423impl Hour {
424    /// Set the padding type.
425    #[inline]
426    #[must_use = "this returns the result of the operation, without modifying the original"]
427    pub const fn with_padding(self, padding: Padding) -> Self {
428        Self { padding, ..self }
429    }
430
431    /// Set whether the hour uses a 12-hour clock.
432    #[inline]
433    #[must_use = "this returns the result of the operation, without modifying the original"]
434    pub const fn with_is_12_hour_clock(self, is_12_hour_clock: bool) -> Self {
435        Self {
436            is_12_hour_clock,
437            ..self
438        }
439    }
440}
441
442/// Minute within the hour.
443#[non_exhaustive]
444#[derive(#[automatically_derived]
impl ::core::fmt::Debug for Minute {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field1_finish(f, "Minute",
            "padding", &&self.padding)
    }
}Debug, #[automatically_derived]
impl ::core::clone::Clone for Minute {
    #[inline]
    fn clone(&self) -> Minute {
        let _: ::core::clone::AssertParamIsClone<Padding>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for Minute { }Copy, #[automatically_derived]
impl ::core::cmp::PartialEq for Minute {
    #[inline]
    fn eq(&self, other: &Minute) -> bool { self.padding == other.padding }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for Minute {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_receiver_is_total_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<Padding>;
    }
}Eq)]
445pub struct Minute {
446    /// The padding to obtain the minimum width.
447    pub padding: Padding,
448}
449
450impl Minute {
451    /// Set the padding type.
452    #[inline]
453    #[must_use = "this returns the result of the operation, without modifying the original"]
454    pub const fn with_padding(self, padding: Padding) -> Self {
455        Self { padding }
456    }
457}
458
459/// AM/PM part of the time.
460#[non_exhaustive]
461#[derive(#[automatically_derived]
impl ::core::fmt::Debug for Period {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f, "Period",
            "is_uppercase", &self.is_uppercase, "case_sensitive",
            &&self.case_sensitive)
    }
}Debug, #[automatically_derived]
impl ::core::clone::Clone for Period {
    #[inline]
    fn clone(&self) -> Period {
        let _: ::core::clone::AssertParamIsClone<bool>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for Period { }Copy, #[automatically_derived]
impl ::core::cmp::PartialEq for Period {
    #[inline]
    fn eq(&self, other: &Period) -> bool {
        self.is_uppercase == other.is_uppercase &&
            self.case_sensitive == other.case_sensitive
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for Period {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_receiver_is_total_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<bool>;
    }
}Eq)]
462pub struct Period {
463    /// Is the period uppercase or lowercase?
464    pub is_uppercase: bool,
465    /// Is the value case sensitive when parsing?
466    ///
467    /// Note that when `false`, the `is_uppercase` field has no effect on parsing behavior.
468    pub case_sensitive: bool,
469}
470
471impl Period {
472    /// Set whether the period is uppercase.
473    #[inline]
474    #[must_use = "this returns the result of the operation, without modifying the original"]
475    pub const fn with_is_uppercase(self, is_uppercase: bool) -> Self {
476        Self {
477            is_uppercase,
478            ..self
479        }
480    }
481
482    /// Set whether the value is case sensitive when parsing.
483    #[inline]
484    #[must_use = "this returns the result of the operation, without modifying the original"]
485    pub const fn with_case_sensitive(self, case_sensitive: bool) -> Self {
486        Self {
487            case_sensitive,
488            ..self
489        }
490    }
491}
492
493/// Second within the minute.
494#[non_exhaustive]
495#[derive(#[automatically_derived]
impl ::core::fmt::Debug for Second {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field1_finish(f, "Second",
            "padding", &&self.padding)
    }
}Debug, #[automatically_derived]
impl ::core::clone::Clone for Second {
    #[inline]
    fn clone(&self) -> Second {
        let _: ::core::clone::AssertParamIsClone<Padding>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for Second { }Copy, #[automatically_derived]
impl ::core::cmp::PartialEq for Second {
    #[inline]
    fn eq(&self, other: &Second) -> bool { self.padding == other.padding }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for Second {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_receiver_is_total_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<Padding>;
    }
}Eq)]
496pub struct Second {
497    /// The padding to obtain the minimum width.
498    pub padding: Padding,
499}
500
501impl Second {
502    /// Set the padding type.
503    #[inline]
504    #[must_use = "this returns the result of the operation, without modifying the original"]
505    pub const fn with_padding(self, padding: Padding) -> Self {
506        Self { padding }
507    }
508}
509
510/// The number of digits present in a subsecond representation.
511#[non_exhaustive]
512#[derive(#[automatically_derived]
impl ::core::fmt::Debug for SubsecondDigits {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                SubsecondDigits::One => "One",
                SubsecondDigits::Two => "Two",
                SubsecondDigits::Three => "Three",
                SubsecondDigits::Four => "Four",
                SubsecondDigits::Five => "Five",
                SubsecondDigits::Six => "Six",
                SubsecondDigits::Seven => "Seven",
                SubsecondDigits::Eight => "Eight",
                SubsecondDigits::Nine => "Nine",
                SubsecondDigits::OneOrMore => "OneOrMore",
            })
    }
}Debug, #[automatically_derived]
impl ::core::clone::Clone for SubsecondDigits {
    #[inline]
    fn clone(&self) -> SubsecondDigits { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for SubsecondDigits { }Copy, #[automatically_derived]
impl ::core::cmp::PartialEq for SubsecondDigits {
    #[inline]
    fn eq(&self, other: &SubsecondDigits) -> bool {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        __self_discr == __arg1_discr
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for SubsecondDigits {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_receiver_is_total_eq(&self) {}
}Eq)]
513pub enum SubsecondDigits {
514    /// Exactly one digit.
515    One,
516    /// Exactly two digits.
517    Two,
518    /// Exactly three digits.
519    Three,
520    /// Exactly four digits.
521    Four,
522    /// Exactly five digits.
523    Five,
524    /// Exactly six digits.
525    Six,
526    /// Exactly seven digits.
527    Seven,
528    /// Exactly eight digits.
529    Eight,
530    /// Exactly nine digits.
531    Nine,
532    /// Any number of digits (up to nine) that is at least one. When formatting, the minimum digits
533    /// necessary will be used.
534    OneOrMore,
535}
536
537/// Subsecond within the second.
538#[non_exhaustive]
539#[derive(#[automatically_derived]
impl ::core::fmt::Debug for Subsecond {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field1_finish(f, "Subsecond",
            "digits", &&self.digits)
    }
}Debug, #[automatically_derived]
impl ::core::clone::Clone for Subsecond {
    #[inline]
    fn clone(&self) -> Subsecond {
        let _: ::core::clone::AssertParamIsClone<SubsecondDigits>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for Subsecond { }Copy, #[automatically_derived]
impl ::core::cmp::PartialEq for Subsecond {
    #[inline]
    fn eq(&self, other: &Subsecond) -> bool { self.digits == other.digits }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for Subsecond {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_receiver_is_total_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<SubsecondDigits>;
    }
}Eq)]
540pub struct Subsecond {
541    /// How many digits are present in the component?
542    pub digits: SubsecondDigits,
543}
544
545impl Subsecond {
546    /// Set the number of digits present in the subsecond representation.
547    #[inline]
548    #[must_use = "this returns the result of the operation, without modifying the original"]
549    pub const fn with_digits(self, digits: SubsecondDigits) -> Self {
550        Self { digits }
551    }
552}
553
554/// Hour of the UTC offset.
555#[non_exhaustive]
556#[derive(#[automatically_derived]
impl ::core::fmt::Debug for OffsetHour {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f, "OffsetHour",
            "sign_is_mandatory", &self.sign_is_mandatory, "padding",
            &&self.padding)
    }
}Debug, #[automatically_derived]
impl ::core::clone::Clone for OffsetHour {
    #[inline]
    fn clone(&self) -> OffsetHour {
        let _: ::core::clone::AssertParamIsClone<bool>;
        let _: ::core::clone::AssertParamIsClone<Padding>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for OffsetHour { }Copy, #[automatically_derived]
impl ::core::cmp::PartialEq for OffsetHour {
    #[inline]
    fn eq(&self, other: &OffsetHour) -> bool {
        self.sign_is_mandatory == other.sign_is_mandatory &&
            self.padding == other.padding
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for OffsetHour {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_receiver_is_total_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<bool>;
        let _: ::core::cmp::AssertParamIsEq<Padding>;
    }
}Eq)]
557pub struct OffsetHour {
558    /// Whether the `+` sign is present on positive values.
559    pub sign_is_mandatory: bool,
560    /// The padding to obtain the minimum width.
561    pub padding: Padding,
562}
563
564impl OffsetHour {
565    /// Set whether the `+` sign is mandatory for positive values.
566    #[inline]
567    #[must_use = "this returns the result of the operation, without modifying the original"]
568    pub const fn with_sign_is_mandatory(self, sign_is_mandatory: bool) -> Self {
569        Self {
570            sign_is_mandatory,
571            ..self
572        }
573    }
574
575    /// Set the padding type.
576    #[inline]
577    #[must_use = "this returns the result of the operation, without modifying the original"]
578    pub const fn with_padding(self, padding: Padding) -> Self {
579        Self { padding, ..self }
580    }
581}
582
583/// Minute within the hour of the UTC offset.
584#[non_exhaustive]
585#[derive(#[automatically_derived]
impl ::core::fmt::Debug for OffsetMinute {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field1_finish(f, "OffsetMinute",
            "padding", &&self.padding)
    }
}Debug, #[automatically_derived]
impl ::core::clone::Clone for OffsetMinute {
    #[inline]
    fn clone(&self) -> OffsetMinute {
        let _: ::core::clone::AssertParamIsClone<Padding>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for OffsetMinute { }Copy, #[automatically_derived]
impl ::core::cmp::PartialEq for OffsetMinute {
    #[inline]
    fn eq(&self, other: &OffsetMinute) -> bool {
        self.padding == other.padding
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for OffsetMinute {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_receiver_is_total_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<Padding>;
    }
}Eq)]
586pub struct OffsetMinute {
587    /// The padding to obtain the minimum width.
588    pub padding: Padding,
589}
590
591impl OffsetMinute {
592    /// Set the padding type.
593    #[inline]
594    #[must_use = "this returns the result of the operation, without modifying the original"]
595    pub const fn with_padding(self, padding: Padding) -> Self {
596        Self { padding }
597    }
598}
599
600/// Second within the minute of the UTC offset.
601#[non_exhaustive]
602#[derive(#[automatically_derived]
impl ::core::fmt::Debug for OffsetSecond {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field1_finish(f, "OffsetSecond",
            "padding", &&self.padding)
    }
}Debug, #[automatically_derived]
impl ::core::clone::Clone for OffsetSecond {
    #[inline]
    fn clone(&self) -> OffsetSecond {
        let _: ::core::clone::AssertParamIsClone<Padding>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for OffsetSecond { }Copy, #[automatically_derived]
impl ::core::cmp::PartialEq for OffsetSecond {
    #[inline]
    fn eq(&self, other: &OffsetSecond) -> bool {
        self.padding == other.padding
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for OffsetSecond {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_receiver_is_total_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<Padding>;
    }
}Eq)]
603pub struct OffsetSecond {
604    /// The padding to obtain the minimum width.
605    pub padding: Padding,
606}
607
608impl OffsetSecond {
609    /// Set the padding type.
610    #[inline]
611    #[must_use = "this returns the result of the operation, without modifying the original"]
612    pub const fn with_padding(self, padding: Padding) -> Self {
613        Self { padding }
614    }
615}
616
617/// Type of padding to ensure a minimum width.
618#[non_exhaustive]
619#[derive(#[automatically_derived]
impl ::core::fmt::Debug for Padding {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                Padding::Space => "Space",
                Padding::Zero => "Zero",
                Padding::None => "None",
            })
    }
}Debug, #[automatically_derived]
impl ::core::clone::Clone for Padding {
    #[inline]
    fn clone(&self) -> Padding { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for Padding { }Copy, #[automatically_derived]
impl ::core::cmp::PartialEq for Padding {
    #[inline]
    fn eq(&self, other: &Padding) -> bool {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        __self_discr == __arg1_discr
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for Padding {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_receiver_is_total_eq(&self) {}
}Eq)]
620pub enum Padding {
621    /// A space character (` `) should be used as padding.
622    Space,
623    /// A zero character (`0`) should be used as padding.
624    Zero,
625    /// There is no padding. This can result in a width below the otherwise minimum number of
626    /// characters.
627    None,
628}
629
630/// Ignore some number of bytes.
631///
632/// This has no effect when formatting.
633#[non_exhaustive]
634#[derive(#[automatically_derived]
impl ::core::fmt::Debug for Ignore {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field1_finish(f, "Ignore",
            "count", &&self.count)
    }
}Debug, #[automatically_derived]
impl ::core::clone::Clone for Ignore {
    #[inline]
    fn clone(&self) -> Ignore {
        let _: ::core::clone::AssertParamIsClone<NonZero<u16>>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for Ignore { }Copy, #[automatically_derived]
impl ::core::cmp::PartialEq for Ignore {
    #[inline]
    fn eq(&self, other: &Ignore) -> bool { self.count == other.count }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for Ignore {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_receiver_is_total_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<NonZero<u16>>;
    }
}Eq)]
635pub struct Ignore {
636    /// The number of bytes to ignore.
637    pub count: NonZero<u16>,
638}
639
640// Needed as `Default` is deliberately not implemented for `Ignore`. The number of bytes to ignore
641// must be explicitly provided.
642impl Ignore {
643    /// Create an instance of `Ignore` with the provided number of bytes to ignore.
644    #[inline]
645    pub const fn count(count: NonZero<u16>) -> Self {
646        Self { count }
647    }
648
649    /// Set the number of bytes to ignore.
650    #[inline]
651    #[must_use = "this returns the result of the operation, without modifying the original"]
652    pub const fn with_count(self, count: NonZero<u16>) -> Self {
653        Self { count }
654    }
655}
656
657/// The precision of a Unix timestamp.
658#[non_exhaustive]
659#[derive(#[automatically_derived]
impl ::core::fmt::Debug for UnixTimestampPrecision {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                UnixTimestampPrecision::Second => "Second",
                UnixTimestampPrecision::Millisecond => "Millisecond",
                UnixTimestampPrecision::Microsecond => "Microsecond",
                UnixTimestampPrecision::Nanosecond => "Nanosecond",
            })
    }
}Debug, #[automatically_derived]
impl ::core::clone::Clone for UnixTimestampPrecision {
    #[inline]
    fn clone(&self) -> UnixTimestampPrecision { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for UnixTimestampPrecision { }Copy, #[automatically_derived]
impl ::core::cmp::PartialEq for UnixTimestampPrecision {
    #[inline]
    fn eq(&self, other: &UnixTimestampPrecision) -> bool {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        __self_discr == __arg1_discr
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for UnixTimestampPrecision {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_receiver_is_total_eq(&self) {}
}Eq)]
660pub enum UnixTimestampPrecision {
661    /// Seconds since the Unix epoch.
662    Second,
663    /// Milliseconds since the Unix epoch.
664    Millisecond,
665    /// Microseconds since the Unix epoch.
666    Microsecond,
667    /// Nanoseconds since the Unix epoch.
668    Nanosecond,
669}
670
671/// A Unix timestamp.
672#[non_exhaustive]
673#[derive(#[automatically_derived]
impl ::core::fmt::Debug for UnixTimestamp {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f, "UnixTimestamp",
            "precision", &self.precision, "sign_is_mandatory",
            &&self.sign_is_mandatory)
    }
}Debug, #[automatically_derived]
impl ::core::clone::Clone for UnixTimestamp {
    #[inline]
    fn clone(&self) -> UnixTimestamp {
        let _: ::core::clone::AssertParamIsClone<UnixTimestampPrecision>;
        let _: ::core::clone::AssertParamIsClone<bool>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for UnixTimestamp { }Copy, #[automatically_derived]
impl ::core::cmp::PartialEq for UnixTimestamp {
    #[inline]
    fn eq(&self, other: &UnixTimestamp) -> bool {
        self.sign_is_mandatory == other.sign_is_mandatory &&
            self.precision == other.precision
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for UnixTimestamp {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_receiver_is_total_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<UnixTimestampPrecision>;
        let _: ::core::cmp::AssertParamIsEq<bool>;
    }
}Eq)]
674pub struct UnixTimestamp {
675    /// The precision of the timestamp.
676    pub precision: UnixTimestampPrecision,
677    /// Whether the `+` sign must be present for a non-negative timestamp.
678    pub sign_is_mandatory: bool,
679}
680
681impl UnixTimestamp {
682    /// Set the precision of the timestamp.
683    #[inline]
684    #[must_use = "this returns the result of the operation, without modifying the original"]
685    pub const fn with_precision(self, precision: UnixTimestampPrecision) -> Self {
686        Self { precision, ..self }
687    }
688
689    /// Set whether the `+` sign is mandatory for non-negative timestamps.
690    #[inline]
691    #[must_use = "this returns the result of the operation, without modifying the original"]
692    pub const fn with_sign_is_mandatory(self, sign_is_mandatory: bool) -> Self {
693        Self {
694            sign_is_mandatory,
695            ..self
696        }
697    }
698}
699
700/// Whether trailing input after the declared end is permitted.
701#[derive(#[automatically_derived]
impl ::core::fmt::Debug for TrailingInput {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                TrailingInput::Prohibit => "Prohibit",
                TrailingInput::Discard => "Discard",
            })
    }
}Debug, #[automatically_derived]
impl ::core::clone::Clone for TrailingInput {
    #[inline]
    fn clone(&self) -> TrailingInput { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for TrailingInput { }Copy, #[automatically_derived]
impl ::core::cmp::PartialEq for TrailingInput {
    #[inline]
    fn eq(&self, other: &TrailingInput) -> bool {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        __self_discr == __arg1_discr
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for TrailingInput {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_receiver_is_total_eq(&self) {}
}Eq)]
702pub enum TrailingInput {
703    /// Trailing input is not permitted and will cause an error.
704    Prohibit,
705    /// Trailing input is permitted but discarded.
706    Discard,
707}
708
709/// The end of input.
710#[non_exhaustive]
711#[derive(#[automatically_derived]
impl ::core::fmt::Debug for End {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field1_finish(f, "End",
            "trailing_input", &&self.trailing_input)
    }
}Debug, #[automatically_derived]
impl ::core::clone::Clone for End {
    #[inline]
    fn clone(&self) -> End {
        let _: ::core::clone::AssertParamIsClone<TrailingInput>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for End { }Copy, #[automatically_derived]
impl ::core::cmp::PartialEq for End {
    #[inline]
    fn eq(&self, other: &End) -> bool {
        self.trailing_input == other.trailing_input
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for End {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_receiver_is_total_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<TrailingInput>;
    }
}Eq)]
712pub struct End {
713    /// How to handle any input after this component.
714    pub(crate) trailing_input: TrailingInput,
715}
716
717impl End {
718    /// Set how to handle any input after this component.
719    #[inline]
720    #[must_use = "this returns the result of the operation, without modifying the original"]
721    pub const fn with_trailing_input(self, trailing_input: TrailingInput) -> Self {
722        Self {
723            trailing_input,
724            ..self
725        }
726    }
727}