Skip to main content

Calendar

Trait Calendar 

Source
pub trait Calendar: Sized {
    type Wire;

    const DAYS: bool = false;

    // Required methods
    fn from_calendar(
        wire: Self::Wire,
        cx: CalendarContext,
        field: FieldOptions,
    ) -> Result<Self, CalendarError>;
    fn to_calendar(
        &self,
        cx: CalendarContext,
        field: FieldOptions,
    ) -> Self::Wire;
    fn shift_days(&mut self, days: f64);

    // Provided method
    fn shift_start_dates(&mut self, _days: i64) -> Result<(), CalendarError> { ... }
}
Expand description

A type with day fields and a wire form that may hold dates. #[calendar] implements it for a struct.

Provided Associated Constants§

Source

const DAYS: bool = false

Whether the type holds days itself (f64, or an Option or Vec of one), so the field options inclusive, duration, signed and week apply to it.

Required Associated Types§

Source

type Wire

The same type with Day for each day.

Required Methods§

Source

fn from_calendar( wire: Self::Wire, cx: CalendarContext, field: FieldOptions, ) -> Result<Self, CalendarError>

field holds the options of the field this value is in, which only a type with Calendar::DAYS reads. A struct passes each of its fields their own options, and one with its own start date or week system puts those in cx.

§Errors

A date with no start date, or a field’s own conversion error.

Source

fn to_calendar(&self, cx: CalendarContext, field: FieldOptions) -> Self::Wire

Whole days as dates when there is a start date.

Source

fn shift_days(&mut self, days: f64)

Moves every point in time days later; durations and start dates stay.

Provided Methods§

Source

fn shift_start_dates(&mut self, _days: i64) -> Result<(), CalendarError>

Moves every start date, including nested roots’, days later. Paired with shift_days(-days) it moves day 0 and keeps every date.

§Errors

A start date moved outside years 0 to 9999; earlier ones have then already moved.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl Calendar for f64

Source§

const DAYS: bool = true

Source§

type Wire = Day

Source§

fn from_calendar( wire: Day, cx: CalendarContext, field: FieldOptions, ) -> Result<Self, CalendarError>

Source§

fn to_calendar(&self, cx: CalendarContext, field: FieldOptions) -> Day

Source§

fn shift_days(&mut self, days: f64)

Source§

impl<T: Calendar> Calendar for Option<T>

Source§

const DAYS: bool = T::DAYS

Source§

type Wire = Option<<T as Calendar>::Wire>

Source§

fn from_calendar( wire: Self::Wire, cx: CalendarContext, field: FieldOptions, ) -> Result<Self, CalendarError>

Source§

fn to_calendar(&self, cx: CalendarContext, field: FieldOptions) -> Self::Wire

Source§

fn shift_days(&mut self, days: f64)

Source§

fn shift_start_dates(&mut self, days: i64) -> Result<(), CalendarError>

Source§

impl<T: Calendar> Calendar for Vec<T>

Source§

const DAYS: bool = T::DAYS

Source§

type Wire = Vec<<T as Calendar>::Wire>

Source§

fn from_calendar( wire: Self::Wire, cx: CalendarContext, field: FieldOptions, ) -> Result<Self, CalendarError>

Source§

fn to_calendar(&self, cx: CalendarContext, field: FieldOptions) -> Self::Wire

Source§

fn shift_days(&mut self, days: f64)

Source§

fn shift_start_dates(&mut self, days: i64) -> Result<(), CalendarError>

Implementors§