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§
Required Associated Types§
Required Methods§
Sourcefn from_calendar(
wire: Self::Wire,
cx: CalendarContext,
field: FieldOptions,
) -> Result<Self, CalendarError>
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.
Sourcefn to_calendar(&self, cx: CalendarContext, field: FieldOptions) -> Self::Wire
fn to_calendar(&self, cx: CalendarContext, field: FieldOptions) -> Self::Wire
Whole days as dates when there is a start date.
Sourcefn shift_days(&mut self, days: f64)
fn shift_days(&mut self, days: f64)
Moves every point in time days later; durations and start dates
stay.
Provided Methods§
Sourcefn shift_start_dates(&mut self, _days: i64) -> Result<(), CalendarError>
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".