Skip to main content

Rules

Trait Rules 

Source
pub trait Rules:
    Clone
    + Debug
    + UnstableSealed {
    // Required method
    fn year_data(&self, extended_year: i32) -> HijriYearData;

    // Provided methods
    fn ecma_reference_year(
        &self,
        _month_code: (u8, bool),
        _day: u8,
    ) -> Result<i32, EcmaReferenceYearError> { ... }
    fn calendar_algorithm(&self) -> Option<CalendarAlgorithm> { ... }
    fn debug_name(&self) -> &'static str { ... }
}
Expand description

Defines a variant of the Hijri calendar.

This crate includes the UmmAlQura, AstronomicalSimulation, and TabularAlgorithm rules, other rules can be implemented by users.

🚫 This trait is sealed; it should not be implemented by user code. If an API requests an item that implements this trait, please consider using a type from the implementors listed below.

It is still possible to implement this trait in userland (since UnstableSealed is public), do not do so unless you are prepared for things to occasionally break.

Required Methods§

Source

fn year_data(&self, extended_year: i32) -> HijriYearData

Returns data about the given year.

Provided Methods§

Source

fn ecma_reference_year( &self, _month_code: (u8, bool), _day: u8, ) -> Result<i32, EcmaReferenceYearError>

Returns an ECMA reference year that contains the given month-day combination.

If the day is out of range, it will return a year that contains the given month and the maximum day possible for that month. See the spec for the precise algorithm used.

This API only matters when using MissingFieldsStrategy::Ecma to compute a date without providing a year in [Date::try_from_fields()]. The default impl will just error, and custom calendars who do not care about ECMA/Temporal reference years do not need to override this.

Source

fn calendar_algorithm(&self) -> Option<CalendarAlgorithm>

The BCP-47 CalendarAlgorithm for the Hijri calendar using these rules, if defined.

Source

fn debug_name(&self) -> &'static str

The debug name for these rules.

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§