Skip to main content

ComponentProvider

Trait ComponentProvider 

Source
pub(crate) trait ComponentProvider {
    type State: Default;

    const SUPPLIES_DATE: bool = false;
    const SUPPLIES_TIME: bool = false;
    const SUPPLIES_OFFSET: bool = false;
    const SUPPLIES_TIMESTAMP: bool = false;
Show 23 methods // Provided methods fn day(&self, state: &mut Self::State) -> u8 { ... } fn month(&self, state: &mut Self::State) -> Month { ... } fn ordinal(&self, state: &mut Self::State) -> u16 { ... } fn weekday(&self, state: &mut Self::State) -> Weekday { ... } fn iso_week_number(&self, state: &mut Self::State) -> u8 { ... } fn monday_based_week(&self, state: &mut Self::State) -> u8 { ... } fn sunday_based_week(&self, state: &mut Self::State) -> u8 { ... } fn calendar_year(&self, state: &mut Self::State) -> i32 { ... } fn iso_year(&self, state: &mut Self::State) -> i32 { ... } fn hour(&self, state: &mut Self::State) -> u8 { ... } fn minute(&self, state: &mut Self::State) -> u8 { ... } fn period(&self, state: &mut Self::State) -> Period { ... } fn second(&self, state: &mut Self::State) -> u8 { ... } fn nanosecond(&self, state: &mut Self::State) -> u32 { ... } fn offset_is_negative(&self, state: &mut Self::State) -> bool { ... } fn offset_is_utc(&self, state: &mut Self::State) -> bool { ... } fn offset_hour(&self, state: &mut Self::State) -> i8 { ... } fn offset_minute(&self, state: &mut Self::State) -> i8 { ... } fn offset_second(&self, state: &mut Self::State) -> i8 { ... } fn unix_timestamp_seconds(&self, state: &mut Self::State) -> i64 { ... } fn unix_timestamp_milliseconds(&self, state: &mut Self::State) -> i64 { ... } fn unix_timestamp_microseconds(&self, state: &mut Self::State) -> i128 { ... } fn unix_timestamp_nanoseconds(&self, state: &mut Self::State) -> i128 { ... }
}
Available on crate feature formatting only.
Expand description

A type with the ability to provide date, time, offset, and/or timestamp components on demand.

Note that while all methods have a default body, implementations are expected to override the body for all components that they provide. The default implementation exists solely for convenience, avoiding the need to specify unprovided components.

Provided Associated Constants§

Source

const SUPPLIES_DATE: bool = false

Whether the type can provide date components, indicating that date-related methods can be called.

Source

const SUPPLIES_TIME: bool = false

Whether the type can provide time components, indicating that time-related methods can be called.

Source

const SUPPLIES_OFFSET: bool = false

Whether the type can provide offset components, indicating that offset-related methods can be called.

Source

const SUPPLIES_TIMESTAMP: bool = false

Whether the type can provide timestamp components, indicating that timestamp-related methods can be called.

Required Associated Types§

Source

type State: Default

The state type used by the provider, allowing for caching of computed values.

Provided Methods§

Source

fn day(&self, state: &mut Self::State) -> u8

Obtain the day of the month.

Source

fn month(&self, state: &mut Self::State) -> Month

Obtain the month of the year.

Source

fn ordinal(&self, state: &mut Self::State) -> u16

Obtain the ordinal day of the year.

Source

fn weekday(&self, state: &mut Self::State) -> Weekday

Obtain the day of the week.

Source

fn iso_week_number(&self, state: &mut Self::State) -> u8

Obtain the ISO week number.

Source

fn monday_based_week(&self, state: &mut Self::State) -> u8

Obtain the Monday-based week number.

Source

fn sunday_based_week(&self, state: &mut Self::State) -> u8

Obtain the Sunday-based week number.

Source

fn calendar_year(&self, state: &mut Self::State) -> i32

Obtain the calendar year.

Source

fn iso_year(&self, state: &mut Self::State) -> i32

Obtain the ISO week-based year.

Source

fn hour(&self, state: &mut Self::State) -> u8

Obtain the hour within the day.

Source

fn minute(&self, state: &mut Self::State) -> u8

Obtain the minute within the hour.

Source

fn period(&self, state: &mut Self::State) -> Period

Obtain the period of the day (AM/PM).

Source

fn second(&self, state: &mut Self::State) -> u8

Obtain the second within the minute.

Source

fn nanosecond(&self, state: &mut Self::State) -> u32

Obtain the nanosecond within the second.

Source

fn offset_is_negative(&self, state: &mut Self::State) -> bool

Obtain whether the offset is negative.

Source

fn offset_is_utc(&self, state: &mut Self::State) -> bool

Obtain whether the offset is UTC.

Source

fn offset_hour(&self, state: &mut Self::State) -> i8

Obtain the hour component of the UTC offset.

Source

fn offset_minute(&self, state: &mut Self::State) -> i8

Obtain the minute component of the UTC offset.

Source

fn offset_second(&self, state: &mut Self::State) -> i8

Obtain the second component of the UTC offset.

Source

fn unix_timestamp_seconds(&self, state: &mut Self::State) -> i64

Obtain the Unix timestamp in seconds.

Source

fn unix_timestamp_milliseconds(&self, state: &mut Self::State) -> i64

Obtain the Unix timestamp in milliseconds.

Source

fn unix_timestamp_microseconds(&self, state: &mut Self::State) -> i128

Obtain the Unix timestamp in microseconds.

Source

fn unix_timestamp_nanoseconds(&self, state: &mut Self::State) -> i128

Obtain the Unix timestamp in nanoseconds.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§