#[non_exhaustive]pub enum ReportingPeriod {
Quarter {
year: PeriodYear,
quarter: QuarterOfYear,
},
Year {
year: PeriodYear,
},
Date(PeriodDate),
Other(OtherPeriod),
}Expand description
Reporting or fiscal period label with structured variants and extensible fallback.
ReportingPeriod models labels reported by issuers, analysts, or providers:
2023Q4, FY2023, 2023-12-31, and provider-specific ranges are labels,
not calendar boundary claims. A fiscal 2023Q4 may not overlap calendar Q4.
Use CalendarPeriod when you need date boundary helpers.
Canonical/serde rules:
- Emission uses a single canonical form per variant (UPPERCASE ASCII where applicable)
- Parser accepts a superset of tokens (aliases, case-insensitive where appropriate)
Other(s)serializes to its canonicalcode()string (no escape prefix)Displayoutput matches the canonical form for structured variants and the rawsforOther(s)- Serde round-trips preserve identity for canonical variants; unknown tokens normalize to
Other(UPPERCASE)
Canonical outputs:
- Quarters:
YYYYQ#(e.g.,2023Q4) - Years:
YYYY(e.g.,2023) - Dates:
YYYY-MM-DD(ISO 8601) Otherstores and emitscanonicalize-style tokens
Display and serde always emit the canonical forms listed above. The parser
accepts common provider variants (e.g., FY2023, 2023-Q4, 12/31/2023) and
normalizes to the single canonical emission for round-trip stability.
ReportingPeriod intentionally does not implement Ord or date-boundary
helpers: cross-granularity ordering needs caller-chosen semantics (fiscal
calendar, exact date, provider-specific Other, etc.).
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Quarter
Quarterly period with year and quarter number
Year
Annual period with year
Fields
year: PeriodYearThe year of the annual period
Date(PeriodDate)
Specific date
Tuple Fields
0: PeriodDateValidated calendar date
Other(OtherPeriod)
Unknown or provider-specific period format
Implementations§
Source§impl ReportingPeriod
impl ReportingPeriod
Sourcepub fn quarterly(year: i32, quarter: u8) -> Result<ReportingPeriod, DomainError>
pub fn quarterly(year: i32, quarter: u8) -> Result<ReportingPeriod, DomainError>
Builds a validated quarterly period.
§Errors
Returns DomainError::InvalidPeriodYear or
DomainError::InvalidPeriodQuarter when either component is outside
its accepted range.
Sourcepub fn annual(year: i32) -> Result<ReportingPeriod, DomainError>
pub fn annual(year: i32) -> Result<ReportingPeriod, DomainError>
Builds a validated annual period.
§Errors
Returns DomainError::InvalidPeriodYear when year is outside
0..=9999.
Sourcepub fn date(date: NaiveDate) -> Result<ReportingPeriod, DomainError>
pub fn date(date: NaiveDate) -> Result<ReportingPeriod, DomainError>
Builds a validated date period.
§Errors
Returns DomainError::InvalidPeriodYear when date.year() is
outside 0..=9999.
Sourcepub fn other(input: &str) -> Result<ReportingPeriod, DomainError>
pub fn other(input: &str) -> Result<ReportingPeriod, DomainError>
Builds an unknown period token, rejecting tokens modeled by ReportingPeriod.
§Errors
Returns an error if input is empty, cannot be canonicalized, parses to
a modeled ReportingPeriod variant, or matches a supported structured
period shape with invalid components.
Partial modeled-looking provider labels that do not match a supported
structured parser, such as FY, may still be accepted as
ReportingPeriod::Other.
Sourcepub const fn period_year(&self) -> Option<PeriodYear>
pub const fn period_year(&self) -> Option<PeriodYear>
Returns the validated year component for this period, if applicable.
Sourcepub const fn quarter_of_year(&self) -> Option<QuarterOfYear>
pub const fn quarter_of_year(&self) -> Option<QuarterOfYear>
Returns the validated quarter component for quarterly periods.
Sourcepub const fn is_quarterly(&self) -> bool
pub const fn is_quarterly(&self) -> bool
Returns true if this is a quarterly period
Trait Implementations§
Source§impl Clone for ReportingPeriod
impl Clone for ReportingPeriod
Source§fn clone(&self) -> ReportingPeriod
fn clone(&self) -> ReportingPeriod
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ReportingPeriod
impl Debug for ReportingPeriod
Source§impl<'de> Deserialize<'de> for ReportingPeriod
impl<'de> Deserialize<'de> for ReportingPeriod
Source§fn deserialize<D>(
deserializer: D,
) -> Result<ReportingPeriod, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<ReportingPeriod, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl Display for ReportingPeriod
impl Display for ReportingPeriod
impl Eq for ReportingPeriod
Source§impl From<CalendarPeriod> for ReportingPeriod
impl From<CalendarPeriod> for ReportingPeriod
Source§fn from(period: CalendarPeriod) -> ReportingPeriod
fn from(period: CalendarPeriod) -> ReportingPeriod
Source§impl FromStr for ReportingPeriod
impl FromStr for ReportingPeriod
Source§fn from_str(
s: &str,
) -> Result<ReportingPeriod, <ReportingPeriod as FromStr>::Err>
fn from_str( s: &str, ) -> Result<ReportingPeriod, <ReportingPeriod as FromStr>::Err>
Invariant: the canonical form of a ReportingPeriod::Other produced here is
guaranteed not to parse as any structured variant on a subsequent
deserialize. Without this, inputs like "-2023Q4" (rejected by the
structured parsers because of the leading -) would canonicalize to
"2023Q4" and serialize back to a string that re-parses as
ReportingPeriod::Quarter, breaking round-trip identity.
To maintain the invariant without accepting malformed aliases, we
re-run the structured parsers on the canonicalized form before
returning Other. If any parser recognizes the canonical form, we
return InvalidPeriodFormat; otherwise a malformed input such as
"-2023Q4" would silently become ReportingPeriod::Quarter.
Source§type Err = DomainError
type Err = DomainError
Source§impl Hash for ReportingPeriod
impl Hash for ReportingPeriod
Source§impl PartialEq for ReportingPeriod
impl PartialEq for ReportingPeriod
Source§impl Serialize for ReportingPeriod
impl Serialize for ReportingPeriod
Source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
impl StructuralPartialEq for ReportingPeriod
Source§impl TryFrom<String> for ReportingPeriod
impl TryFrom<String> for ReportingPeriod
Source§type Error = DomainError
type Error = DomainError
Source§fn try_from(
s: String,
) -> Result<ReportingPeriod, <ReportingPeriod as TryFrom<String>>::Error>
fn try_from( s: String, ) -> Result<ReportingPeriod, <ReportingPeriod as TryFrom<String>>::Error>
Auto Trait Implementations§
impl Freeze for ReportingPeriod
impl RefUnwindSafe for ReportingPeriod
impl Send for ReportingPeriod
impl Sync for ReportingPeriod
impl Unpin for ReportingPeriod
impl UnsafeUnpin for ReportingPeriod
impl UnwindSafe for ReportingPeriod
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Key for Twhere
T: Clone,
impl<T> Key for Twhere
T: Clone,
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString. Read moreSource§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.