1//! Various modifiers for components.
23use core::num::NonZero;
45/// 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}
1920/// 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;)*) => {$(
25impl $type {
26if_pub! {
27 $($pub)?
28$(#[$doc])*;
29#[inline]
30pub const fn default() -> Self {
31$default
32}
33 }
34 }
3536 $(#[$doc])*
37impl Default for $type {
38#[inline]
39fn default() -> Self {
40$default
41}
42 }
43 )*};
44}
4546// 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.
52MonthRepr => 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.
64WeekdayRepr => 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.
74WeekNumberRepr => 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.
82YearRepr => Self::Full;
83/// Creates a modifier that indicates the value uses the [`Extended`](Self::Extended) range.
84YearRange => 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).
113SubsecondDigits => 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).
128Padding => Self::Zero;
129/// Creates a modifier that indicates the value represents the [number of seconds](Self::Second)
130 /// since the Unix epoch.
131UnixTimestampPrecision => 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`.
140TrailingInput => 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}145146/// 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.
151pub padding: Padding,
152}
153154impl Day {
155/// Set the padding type.
156#[inline]
157 #[must_use = "this returns the result of the operation, without modifying the original"]
158pub const fn with_padding(self, padding: Padding) -> Self {
159Self { padding }
160 }
161}
162163/// 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).
168Numerical,
169/// The long form of the month name (e.g. "January").
170Long,
171/// The short form of the month name (e.g. "Jan").
172Short,
173}
174175/// 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.
180pub padding: Padding,
181/// What form of representation should be used?
182pub repr: MonthRepr,
183/// Is the value case sensitive when parsing?
184pub case_sensitive: bool,
185}
186187impl Month {
188/// Set the padding type.
189#[inline]
190 #[must_use = "this returns the result of the operation, without modifying the original"]
191pub const fn with_padding(self, padding: Padding) -> Self {
192Self { padding, ..self }
193 }
194195/// 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"]
198pub const fn with_repr(self, repr: MonthRepr) -> Self {
199Self { repr, ..self }
200 }
201202/// 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"]
205pub const fn with_case_sensitive(self, case_sensitive: bool) -> Self {
206Self {
207case_sensitive,
208 ..self209 }
210 }
211}
212213/// 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.
218pub padding: Padding,
219}
220221impl Ordinal {
222/// Set the padding type.
223#[inline]
224 #[must_use = "this returns the result of the operation, without modifying the original"]
225pub const fn with_padding(self, padding: Padding) -> Self {
226Self { padding }
227 }
228}
229230/// 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").
235Short,
236/// The long form of the weekday (e.g. "Monday").
237Long,
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.
241Sunday,
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.
245Monday,
246}
247248/// 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?
253pub repr: WeekdayRepr,
254/// When using a numerical representation, should it be zero or one-indexed?
255pub one_indexed: bool,
256/// Is the value case sensitive when parsing?
257pub case_sensitive: bool,
258}
259260impl 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"]
264pub const fn with_repr(self, repr: WeekdayRepr) -> Self {
265Self { repr, ..self }
266 }
267268/// 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"]
271pub const fn with_one_indexed(self, one_indexed: bool) -> Self {
272Self {
273one_indexed,
274 ..self275 }
276 }
277278/// 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"]
281pub const fn with_case_sensitive(self, case_sensitive: bool) -> Self {
282Self {
283case_sensitive,
284 ..self285 }
286 }
287}
288289/// 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.
294Iso,
295/// Week 1 begins on the first Sunday of the calendar year.
296Sunday,
297/// Week 1 begins on the first Monday of the calendar year.
298Monday,
299}
300301/// 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.
306pub padding: Padding,
307/// What kind of representation should be used?
308pub repr: WeekNumberRepr,
309}
310311impl WeekNumber {
312/// Set the padding type.
313#[inline]
314 #[must_use = "this returns the result of the operation, without modifying the original"]
315pub const fn with_padding(self, padding: Padding) -> Self {
316Self { padding, ..self }
317 }
318319/// 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"]
322pub const fn with_repr(self, repr: WeekNumberRepr) -> Self {
323Self { repr, ..self }
324 }
325}
326327/// 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.
332Full,
333/// All digits except the last two. Includes the sign, if any.
334Century,
335/// Only the last two digits of the year.
336LastTwo,
337}
338339/// 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.
346Standard,
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`.
351Extended,
352}
353354/// 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.
359pub padding: Padding,
360/// What kind of representation should be used?
361pub repr: YearRepr,
362/// What range of years is supported?
363pub range: YearRange,
364/// Whether the value is based on the ISO week number or the Gregorian calendar.
365pub iso_week_based: bool,
366/// Whether the `+` sign is present when a positive year contains fewer than five digits.
367pub sign_is_mandatory: bool,
368}
369370impl Year {
371/// Set the padding type.
372#[inline]
373 #[must_use = "this returns the result of the operation, without modifying the original"]
374pub const fn with_padding(self, padding: Padding) -> Self {
375Self { padding, ..self }
376 }
377378/// 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"]
381pub const fn with_repr(self, repr: YearRepr) -> Self {
382Self { repr, ..self }
383 }
384385/// Set the range of years that are supported.
386#[inline]
387 #[must_use = "this returns the result of the operation, without modifying the original"]
388pub const fn with_range(self, range: YearRange) -> Self {
389Self { range, ..self }
390 }
391392/// 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"]
395pub const fn with_iso_week_based(self, iso_week_based: bool) -> Self {
396Self {
397iso_week_based,
398 ..self399 }
400 }
401402/// 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"]
405pub const fn with_sign_is_mandatory(self, sign_is_mandatory: bool) -> Self {
406Self {
407sign_is_mandatory,
408 ..self409 }
410 }
411}
412413/// 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.
418pub padding: Padding,
419/// Is the hour displayed using a 12 or 24-hour clock?
420pub is_12_hour_clock: bool,
421}
422423impl Hour {
424/// Set the padding type.
425#[inline]
426 #[must_use = "this returns the result of the operation, without modifying the original"]
427pub const fn with_padding(self, padding: Padding) -> Self {
428Self { padding, ..self }
429 }
430431/// 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"]
434pub const fn with_is_12_hour_clock(self, is_12_hour_clock: bool) -> Self {
435Self {
436is_12_hour_clock,
437 ..self438 }
439 }
440}
441442/// 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.
447pub padding: Padding,
448}
449450impl Minute {
451/// Set the padding type.
452#[inline]
453 #[must_use = "this returns the result of the operation, without modifying the original"]
454pub const fn with_padding(self, padding: Padding) -> Self {
455Self { padding }
456 }
457}
458459/// 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?
464pub 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.
468pub case_sensitive: bool,
469}
470471impl Period {
472/// Set whether the period is uppercase.
473#[inline]
474 #[must_use = "this returns the result of the operation, without modifying the original"]
475pub const fn with_is_uppercase(self, is_uppercase: bool) -> Self {
476Self {
477is_uppercase,
478 ..self479 }
480 }
481482/// 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"]
485pub const fn with_case_sensitive(self, case_sensitive: bool) -> Self {
486Self {
487case_sensitive,
488 ..self489 }
490 }
491}
492493/// 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.
498pub padding: Padding,
499}
500501impl Second {
502/// Set the padding type.
503#[inline]
504 #[must_use = "this returns the result of the operation, without modifying the original"]
505pub const fn with_padding(self, padding: Padding) -> Self {
506Self { padding }
507 }
508}
509510/// 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.
515One,
516/// Exactly two digits.
517Two,
518/// Exactly three digits.
519Three,
520/// Exactly four digits.
521Four,
522/// Exactly five digits.
523Five,
524/// Exactly six digits.
525Six,
526/// Exactly seven digits.
527Seven,
528/// Exactly eight digits.
529Eight,
530/// Exactly nine digits.
531Nine,
532/// Any number of digits (up to nine) that is at least one. When formatting, the minimum digits
533 /// necessary will be used.
534OneOrMore,
535}
536537/// 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?
542pub digits: SubsecondDigits,
543}
544545impl 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"]
549pub const fn with_digits(self, digits: SubsecondDigits) -> Self {
550Self { digits }
551 }
552}
553554/// 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.
559pub sign_is_mandatory: bool,
560/// The padding to obtain the minimum width.
561pub padding: Padding,
562}
563564impl 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"]
568pub const fn with_sign_is_mandatory(self, sign_is_mandatory: bool) -> Self {
569Self {
570sign_is_mandatory,
571 ..self572 }
573 }
574575/// Set the padding type.
576#[inline]
577 #[must_use = "this returns the result of the operation, without modifying the original"]
578pub const fn with_padding(self, padding: Padding) -> Self {
579Self { padding, ..self }
580 }
581}
582583/// 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.
588pub padding: Padding,
589}
590591impl OffsetMinute {
592/// Set the padding type.
593#[inline]
594 #[must_use = "this returns the result of the operation, without modifying the original"]
595pub const fn with_padding(self, padding: Padding) -> Self {
596Self { padding }
597 }
598}
599600/// 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.
605pub padding: Padding,
606}
607608impl OffsetSecond {
609/// Set the padding type.
610#[inline]
611 #[must_use = "this returns the result of the operation, without modifying the original"]
612pub const fn with_padding(self, padding: Padding) -> Self {
613Self { padding }
614 }
615}
616617/// 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.
622Space,
623/// A zero character (`0`) should be used as padding.
624Zero,
625/// There is no padding. This can result in a width below the otherwise minimum number of
626 /// characters.
627None,
628}
629630/// 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.
637pub count: NonZero<u16>,
638}
639640// 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]
645pub const fn count(count: NonZero<u16>) -> Self {
646Self { count }
647 }
648649/// Set the number of bytes to ignore.
650#[inline]
651 #[must_use = "this returns the result of the operation, without modifying the original"]
652pub const fn with_count(self, count: NonZero<u16>) -> Self {
653Self { count }
654 }
655}
656657/// 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.
662Second,
663/// Milliseconds since the Unix epoch.
664Millisecond,
665/// Microseconds since the Unix epoch.
666Microsecond,
667/// Nanoseconds since the Unix epoch.
668Nanosecond,
669}
670671/// 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.
676pub precision: UnixTimestampPrecision,
677/// Whether the `+` sign must be present for a non-negative timestamp.
678pub sign_is_mandatory: bool,
679}
680681impl UnixTimestamp {
682/// Set the precision of the timestamp.
683#[inline]
684 #[must_use = "this returns the result of the operation, without modifying the original"]
685pub const fn with_precision(self, precision: UnixTimestampPrecision) -> Self {
686Self { precision, ..self }
687 }
688689/// 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"]
692pub const fn with_sign_is_mandatory(self, sign_is_mandatory: bool) -> Self {
693Self {
694sign_is_mandatory,
695 ..self696 }
697 }
698}
699700/// 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.
704Prohibit,
705/// Trailing input is permitted but discarded.
706Discard,
707}
708709/// 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.
714pub(crate) trailing_input: TrailingInput,
715}
716717impl 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"]
721pub const fn with_trailing_input(self, trailing_input: TrailingInput) -> Self {
722Self {
723trailing_input,
724 ..self725 }
726 }
727}