pub struct Parsed {Show 23 fields
year: OptionRangedI32<{ MIN_YEAR }, { MAX_YEAR }>,
year_last_two: OptionRangedU8<0, 99>,
iso_year: OptionRangedI32<{ MIN_YEAR }, { MAX_YEAR }>,
iso_year_last_two: OptionRangedU8<0, 99>,
month: Option<Month>,
sunday_week_number: OptionRangedU8<0, 53>,
monday_week_number: OptionRangedU8<0, 53>,
iso_week_number: OptionRangedU8<1, 53>,
weekday: Option<Weekday>,
ordinal: OptionRangedU16<1, 366>,
day: OptionRangedU8<1, 31>,
hour_24: OptionRangedU8<0, { _ }>,
hour_12: OptionRangedU8<1, 12>,
hour_12_is_pm: Option<bool>,
minute: OptionRangedU8<0, { _ }>,
second: OptionRangedU8<0, { _ }>,
subsecond: OptionRangedU32<0, { _ }>,
offset_hour: OptionRangedI8<-23, 23>,
offset_minute: OptionRangedI8<{ _ }, { _ }>,
offset_second: OptionRangedI8<{ _ }, { _ }>,
unix_timestamp_nanos: OptionRangedI128<{ _ }, { _ }>,
offset_is_negative: Option<bool>,
pub(super) leap_second_allowed: bool,
}
Expand description
All information parsed.
This information is directly used to construct the final values.
Most users will not need think about this struct in any way. It is public to allow for manual control over values, in the instance that the default parser is insufficient.
Fields§
§year: OptionRangedI32<{ MIN_YEAR }, { MAX_YEAR }>
Calendar year.
year_last_two: OptionRangedU8<0, 99>
The last two digits of the calendar year.
iso_year: OptionRangedI32<{ MIN_YEAR }, { MAX_YEAR }>
Year of the ISO week date.
iso_year_last_two: OptionRangedU8<0, 99>
The last two digits of the ISO week year.
month: Option<Month>
Month of the year.
sunday_week_number: OptionRangedU8<0, 53>
Week of the year, where week one begins on the first Sunday of the calendar year.
monday_week_number: OptionRangedU8<0, 53>
Week of the year, where week one begins on the first Monday of the calendar year.
iso_week_number: OptionRangedU8<1, 53>
Week of the year, where week one is the Monday-to-Sunday period containing January 4.
weekday: Option<Weekday>
Day of the week.
ordinal: OptionRangedU16<1, 366>
Day of the year.
day: OptionRangedU8<1, 31>
Day of the month.
hour_24: OptionRangedU8<0, { _ }>
Hour within the day.
hour_12: OptionRangedU8<1, 12>
Hour within the 12-hour period (midnight to noon or vice versa). This is typically used in
conjunction with AM/PM, which is indicated by the hour_12_is_pm
field.
hour_12_is_pm: Option<bool>
Whether the hour_12
field indicates a time that “PM”.
minute: OptionRangedU8<0, { _ }>
Minute within the hour.
second: OptionRangedU8<0, { _ }>
Second within the minute.
subsecond: OptionRangedU32<0, { _ }>
Nanosecond within the second.
offset_hour: OptionRangedI8<-23, 23>
Whole hours of the UTC offset.
offset_minute: OptionRangedI8<{ _ }, { _ }>
Minutes within the hour of the UTC offset.
offset_second: OptionRangedI8<{ _ }, { _ }>
Seconds within the minute of the UTC offset.
unix_timestamp_nanos: OptionRangedI128<{ _ }, { _ }>
The Unix timestamp in nanoseconds.
offset_is_negative: Option<bool>
Indicates whether the UtcOffset
is negative. This information is obtained when parsing
the offset hour, but may not otherwise be stored due to “-0” being equivalent to “0”.
leap_second_allowed: bool
Indicates whether a leap second is permitted to be parsed. This is required by some well-known formats.
Implementations§
source§impl Parsed
impl Parsed
sourcepub fn parse_item<'a>(
&mut self,
input: &'a [u8],
item: &impl AnyFormatItem,
) -> Result<&'a [u8], ParseFromDescription>
pub fn parse_item<'a>( &mut self, input: &'a [u8], item: &impl AnyFormatItem, ) -> Result<&'a [u8], ParseFromDescription>
Parse a single BorrowedFormatItem
or OwnedFormatItem
, mutating the struct. The
remaining input is returned as the Ok
value.
If a BorrowedFormatItem::Optional
or OwnedFormatItem::Optional
is passed, parsing
will not fail; the input will be returned as-is if the expected format is not present.
sourcepub fn parse_items<'a>(
&mut self,
input: &'a [u8],
items: &[impl AnyFormatItem],
) -> Result<&'a [u8], ParseFromDescription>
pub fn parse_items<'a>( &mut self, input: &'a [u8], items: &[impl AnyFormatItem], ) -> Result<&'a [u8], ParseFromDescription>
Parse a sequence of BorrowedFormatItem
s or OwnedFormatItem
s, mutating the struct.
The remaining input is returned as the Ok
value.
This method will fail if any of the contained BorrowedFormatItem
s or
OwnedFormatItem
s fail to parse. self
will not be mutated in this instance.
sourcepub fn parse_literal<'a>(
input: &'a [u8],
literal: &[u8],
) -> Result<&'a [u8], ParseFromDescription>
pub fn parse_literal<'a>( input: &'a [u8], literal: &[u8], ) -> Result<&'a [u8], ParseFromDescription>
Parse a literal byte sequence. The remaining input is returned as the Ok
value.
sourcepub fn parse_component<'a>(
&mut self,
input: &'a [u8],
component: Component,
) -> Result<&'a [u8], ParseFromDescription>
pub fn parse_component<'a>( &mut self, input: &'a [u8], component: Component, ) -> Result<&'a [u8], ParseFromDescription>
Parse a single component, mutating the struct. The remaining input is returned as the Ok
value.
source§impl Parsed
impl Parsed
Getter methods
sourcepub const fn year_last_two(&self) -> Option<u8>
pub const fn year_last_two(&self) -> Option<u8>
Obtain the year_last_two
component.
sourcepub const fn iso_year_last_two(&self) -> Option<u8>
pub const fn iso_year_last_two(&self) -> Option<u8>
Obtain the iso_year_last_two
component.
sourcepub const fn sunday_week_number(&self) -> Option<u8>
pub const fn sunday_week_number(&self) -> Option<u8>
Obtain the sunday_week_number
component.
sourcepub const fn monday_week_number(&self) -> Option<u8>
pub const fn monday_week_number(&self) -> Option<u8>
Obtain the monday_week_number
component.
sourcepub const fn iso_week_number(&self) -> Option<NonZeroU8>
pub const fn iso_week_number(&self) -> Option<NonZeroU8>
Obtain the iso_week_number
component.
sourcepub const fn ordinal(&self) -> Option<NonZeroU16>
pub const fn ordinal(&self) -> Option<NonZeroU16>
Obtain the ordinal
component.
sourcepub const fn hour_12_is_pm(&self) -> Option<bool>
pub const fn hour_12_is_pm(&self) -> Option<bool>
Obtain the hour_12_is_pm
component.
sourcepub const fn offset_hour(&self) -> Option<i8>
pub const fn offset_hour(&self) -> Option<i8>
Obtain the offset_hour
component.
sourcepub const fn offset_minute_signed(&self) -> Option<i8>
pub const fn offset_minute_signed(&self) -> Option<i8>
Obtain the offset_minute
component.
sourcepub const fn offset_second_signed(&self) -> Option<i8>
pub const fn offset_second_signed(&self) -> Option<i8>
Obtain the offset_second
component.
sourcepub const fn unix_timestamp_nanos(&self) -> Option<i128>
pub const fn unix_timestamp_nanos(&self) -> Option<i128>
Obtain the unix_timestamp_nanos
component.
source§impl Parsed
impl Parsed
Setter methods
All setters return Option<()>
, which is Some
if the value was set, and None
if not. The
setters may fail if the value is invalid, though behavior is not guaranteed.
sourcepub fn set_year_last_two(&mut self, value: u8) -> Option<()>
pub fn set_year_last_two(&mut self, value: u8) -> Option<()>
Set the set_year_last_two
component.
sourcepub fn set_iso_year(&mut self, value: i32) -> Option<()>
pub fn set_iso_year(&mut self, value: i32) -> Option<()>
Set the set_iso_year
component.
sourcepub fn set_iso_year_last_two(&mut self, value: u8) -> Option<()>
pub fn set_iso_year_last_two(&mut self, value: u8) -> Option<()>
Set the set_iso_year_last_two
component.
sourcepub fn set_sunday_week_number(&mut self, value: u8) -> Option<()>
pub fn set_sunday_week_number(&mut self, value: u8) -> Option<()>
Set the set_sunday_week_number
component.
sourcepub fn set_monday_week_number(&mut self, value: u8) -> Option<()>
pub fn set_monday_week_number(&mut self, value: u8) -> Option<()>
Set the set_monday_week_number
component.
sourcepub fn set_iso_week_number(&mut self, value: NonZeroU8) -> Option<()>
pub fn set_iso_week_number(&mut self, value: NonZeroU8) -> Option<()>
Set the set_iso_week_number
component.
sourcepub fn set_weekday(&mut self, value: Weekday) -> Option<()>
pub fn set_weekday(&mut self, value: Weekday) -> Option<()>
Set the set_weekday
component.
sourcepub fn set_ordinal(&mut self, value: NonZeroU16) -> Option<()>
pub fn set_ordinal(&mut self, value: NonZeroU16) -> Option<()>
Set the set_ordinal
component.
sourcepub fn set_hour_24(&mut self, value: u8) -> Option<()>
pub fn set_hour_24(&mut self, value: u8) -> Option<()>
Set the set_hour_24
component.
sourcepub fn set_hour_12(&mut self, value: NonZeroU8) -> Option<()>
pub fn set_hour_12(&mut self, value: NonZeroU8) -> Option<()>
Set the set_hour_12
component.
sourcepub fn set_hour_12_is_pm(&mut self, value: bool) -> Option<()>
pub fn set_hour_12_is_pm(&mut self, value: bool) -> Option<()>
Set the set_hour_12_is_pm
component.
sourcepub fn set_minute(&mut self, value: u8) -> Option<()>
pub fn set_minute(&mut self, value: u8) -> Option<()>
Set the set_minute
component.
sourcepub fn set_second(&mut self, value: u8) -> Option<()>
pub fn set_second(&mut self, value: u8) -> Option<()>
Set the set_second
component.
sourcepub fn set_subsecond(&mut self, value: u32) -> Option<()>
pub fn set_subsecond(&mut self, value: u32) -> Option<()>
Set the set_subsecond
component.
sourcepub fn set_offset_hour(&mut self, value: i8) -> Option<()>
pub fn set_offset_hour(&mut self, value: i8) -> Option<()>
Set the set_offset_hour
component.
sourcepub fn set_offset_minute_signed(&mut self, value: i8) -> Option<()>
pub fn set_offset_minute_signed(&mut self, value: i8) -> Option<()>
Set the set_offset_minute_signed
component.
sourcepub fn set_offset_second_signed(&mut self, value: i8) -> Option<()>
pub fn set_offset_second_signed(&mut self, value: i8) -> Option<()>
Set the set_offset_second_signed
component.
sourcepub fn set_unix_timestamp_nanos(&mut self, value: i128) -> Option<()>
pub fn set_unix_timestamp_nanos(&mut self, value: i128) -> Option<()>
Set the set_unix_timestamp_nanos
component.
source§impl Parsed
impl Parsed
Builder methods
All builder methods return Option<Self>
, which is Some
if the value was set, and None
if
not. The builder methods may fail if the value is invalid, though behavior is not guaranteed.
sourcepub const fn with_year(self, value: i32) -> Option<Self>
pub const fn with_year(self, value: i32) -> Option<Self>
Set the year
component and return self
.
sourcepub const fn with_year_last_two(self, value: u8) -> Option<Self>
pub const fn with_year_last_two(self, value: u8) -> Option<Self>
Set the year_last_two
component and return self
.
sourcepub const fn with_iso_year(self, value: i32) -> Option<Self>
pub const fn with_iso_year(self, value: i32) -> Option<Self>
Set the iso_year
component and return self
.
sourcepub const fn with_iso_year_last_two(self, value: u8) -> Option<Self>
pub const fn with_iso_year_last_two(self, value: u8) -> Option<Self>
Set the iso_year_last_two
component and return self
.
sourcepub const fn with_month(self, value: Month) -> Option<Self>
pub const fn with_month(self, value: Month) -> Option<Self>
Set the month
component and return self
.
sourcepub const fn with_sunday_week_number(self, value: u8) -> Option<Self>
pub const fn with_sunday_week_number(self, value: u8) -> Option<Self>
Set the sunday_week_number
component and return self
.
sourcepub const fn with_monday_week_number(self, value: u8) -> Option<Self>
pub const fn with_monday_week_number(self, value: u8) -> Option<Self>
Set the monday_week_number
component and return self
.
sourcepub const fn with_iso_week_number(self, value: NonZeroU8) -> Option<Self>
pub const fn with_iso_week_number(self, value: NonZeroU8) -> Option<Self>
Set the iso_week_number
component and return self
.
sourcepub const fn with_weekday(self, value: Weekday) -> Option<Self>
pub const fn with_weekday(self, value: Weekday) -> Option<Self>
Set the weekday
component and return self
.
sourcepub const fn with_ordinal(self, value: NonZeroU16) -> Option<Self>
pub const fn with_ordinal(self, value: NonZeroU16) -> Option<Self>
Set the ordinal
component and return self
.
sourcepub const fn with_day(self, value: NonZeroU8) -> Option<Self>
pub const fn with_day(self, value: NonZeroU8) -> Option<Self>
Set the day
component and return self
.
sourcepub const fn with_hour_24(self, value: u8) -> Option<Self>
pub const fn with_hour_24(self, value: u8) -> Option<Self>
Set the hour_24
component and return self
.
sourcepub const fn with_hour_12(self, value: NonZeroU8) -> Option<Self>
pub const fn with_hour_12(self, value: NonZeroU8) -> Option<Self>
Set the hour_12
component and return self
.
sourcepub const fn with_hour_12_is_pm(self, value: bool) -> Option<Self>
pub const fn with_hour_12_is_pm(self, value: bool) -> Option<Self>
Set the hour_12_is_pm
component and return self
.
sourcepub const fn with_minute(self, value: u8) -> Option<Self>
pub const fn with_minute(self, value: u8) -> Option<Self>
Set the minute
component and return self
.
sourcepub const fn with_second(self, value: u8) -> Option<Self>
pub const fn with_second(self, value: u8) -> Option<Self>
Set the second
component and return self
.
sourcepub const fn with_subsecond(self, value: u32) -> Option<Self>
pub const fn with_subsecond(self, value: u32) -> Option<Self>
Set the subsecond
component and return self
.
sourcepub const fn with_offset_hour(self, value: i8) -> Option<Self>
pub const fn with_offset_hour(self, value: i8) -> Option<Self>
Set the offset_hour
component and return self
.
sourcepub const fn with_offset_minute_signed(self, value: i8) -> Option<Self>
pub const fn with_offset_minute_signed(self, value: i8) -> Option<Self>
Set the offset_minute
component and return self
.
sourcepub const fn with_offset_second_signed(self, value: i8) -> Option<Self>
pub const fn with_offset_second_signed(self, value: i8) -> Option<Self>
Set the offset_second
component and return self
.
sourcepub const fn with_unix_timestamp_nanos(self, value: i128) -> Option<Self>
pub const fn with_unix_timestamp_nanos(self, value: i128) -> Option<Self>
Set the unix_timestamp_nanos
component and return self
.