pub struct RRule<Stage = Validated> { /* private fields */ }
Expand description
Represents a complete RRULE property based on the iCalendar specification
It has two stages, based on the attached type, Validated
or Unvalidated
.
Unvalidated
, which is the raw string representation of the RRULEValidated
, which is when theRRule
has been parsed and validated, based on the start date
Implementations§
source§impl RRule<Unvalidated>
impl RRule<Unvalidated>
sourcepub fn new(freq: Frequency) -> Self
pub fn new(freq: Frequency) -> Self
Creates a new unvalidated RRule
with default values and the given frequency.
sourcepub fn freq(self, freq: Frequency) -> Self
pub fn freq(self, freq: Frequency) -> Self
The FREQ rule part identifies the type of recurrence rule.
sourcepub fn count(self, count: u32) -> Self
pub fn count(self, count: u32) -> Self
If given, this determines how many occurrences will be generated.
sourcepub fn until(self, until: DateTime<Tz>) -> Self
pub fn until(self, until: DateTime<Tz>) -> Self
If given, this must be a datetime instance specifying the upper-bound limit of the recurrence.
sourcepub fn week_start(self, week_start: Weekday) -> Self
pub fn week_start(self, week_start: Weekday) -> Self
The week start day. This will affect recurrences based on weekly periods.
The default week start is Weekday::Mon
.
sourcepub fn by_set_pos(self, by_set_pos: Vec<i32>) -> Self
pub fn by_set_pos(self, by_set_pos: Vec<i32>) -> Self
If given, it must be either an integer, or a sequence of integers, positive or negative.
Each given integer will specify an occurrence number, corresponding to the nth occurrence
of the rule inside the frequency period. For example, a by_set_pos
of -1 if combined with
a MONTHLY frequency, and a by_weekday
of (MO, TU, WE, TH, FR), will result in the last
work day of every month.
sourcepub fn by_month(self, by_month: &[Month]) -> Self
pub fn by_month(self, by_month: &[Month]) -> Self
When given, these variables will define the months to apply the recurrence to.
sourcepub fn by_month_day(self, by_month_day: Vec<i8>) -> Self
pub fn by_month_day(self, by_month_day: Vec<i8>) -> Self
If given, it must be either an integer, or a sequence of integers, meaning the month days to apply the recurrence to.
sourcepub fn by_year_day(self, by_year_day: Vec<i16>) -> Self
pub fn by_year_day(self, by_year_day: Vec<i16>) -> Self
If given, it must be either an integer, or a sequence of integers, meaning the year days to apply the recurrence to.
sourcepub fn by_week_no(self, by_week_no: Vec<i8>) -> Self
pub fn by_week_no(self, by_week_no: Vec<i8>) -> Self
If given, it must be either an integer, or a sequence of integers, meaning the week numbers to apply the recurrence to. Week numbers have the meaning described in ISO8601, that is, the first week of the year is that it contains at least four days of the new year.
sourcepub fn by_weekday(self, by_weekday: Vec<NWeekday>) -> Self
pub fn by_weekday(self, by_weekday: Vec<NWeekday>) -> Self
When given, these variables will define the weekdays where the recurrence will be applied.
sourcepub fn by_hour(self, by_hour: Vec<u8>) -> Self
pub fn by_hour(self, by_hour: Vec<u8>) -> Self
If given, it must be either an integer, or a sequence of integers, meaning the hours to apply the recurrence to.
sourcepub fn by_minute(self, by_minute: Vec<u8>) -> Self
pub fn by_minute(self, by_minute: Vec<u8>) -> Self
If given, it must be either an integer, or a sequence of integers, meaning the minutes to apply the recurrence to.
sourcepub fn by_second(self, by_second: Vec<u8>) -> Self
pub fn by_second(self, by_second: Vec<u8>) -> Self
If given, it must be either an integer, or a sequence of integers, meaning the seconds to apply the recurrence to.
source§impl<S> RRule<S>
impl<S> RRule<S>
sourcepub fn get_interval(&self) -> u16
pub fn get_interval(&self) -> u16
Get the interval of the recurrence.
sourcepub fn get_week_start(&self) -> Weekday
pub fn get_week_start(&self) -> Weekday
Get the by_set_pos
of the recurrence.
sourcepub fn get_by_set_pos(&self) -> &[i32]
pub fn get_by_set_pos(&self) -> &[i32]
Get the by_month
of the recurrence.
sourcepub fn get_by_month(&self) -> &[u8] ⓘ
pub fn get_by_month(&self) -> &[u8] ⓘ
Get the by_month
of the recurrence.
sourcepub fn get_by_month_day(&self) -> &[i8]
pub fn get_by_month_day(&self) -> &[i8]
Get the by_month_day
of the recurrence.
sourcepub fn get_by_year_day(&self) -> &[i16]
pub fn get_by_year_day(&self) -> &[i16]
Get the by_year_day
of the recurrence.
sourcepub fn get_by_week_no(&self) -> &[i8]
pub fn get_by_week_no(&self) -> &[i8]
Get the by_hour
of the recurrence.
sourcepub fn get_by_weekday(&self) -> &[NWeekday]
pub fn get_by_weekday(&self) -> &[NWeekday]
Get the by_hour
of the recurrence.
sourcepub fn get_by_hour(&self) -> &[u8] ⓘ
pub fn get_by_hour(&self) -> &[u8] ⓘ
Get the by_hour
of the recurrence.
sourcepub fn get_by_minute(&self) -> &[u8] ⓘ
pub fn get_by_minute(&self) -> &[u8] ⓘ
Get the by_minute
of the recurrence.
sourcepub fn get_by_second(&self) -> &[u8] ⓘ
pub fn get_by_second(&self) -> &[u8] ⓘ
Get the by_second
of the recurrence.
Trait Implementations§
source§impl Default for RRule<Unvalidated>
impl Default for RRule<Unvalidated>
source§impl<S> Display for RRule<S>
impl<S> Display for RRule<S>
source§fn fmt(&self, f: &mut Formatter<'_>) -> Result
fn fmt(&self, f: &mut Formatter<'_>) -> Result
Generates a string based on the iCalendar RRULE spec.
It doesn’t prepend “RRULE:” to the string.
When you call this function on RRule<Unvalidated>
, it can generate an invalid string, like ‘FREQ=YEARLY;INTERVAL=-1’
But it is supposed to always generate a valid string on RRule<Validated>
.
So if you want a valid string, it’s smarter to always use rrule.validate(ds_start)?.to_string()
.