Struct rrule::RRule

source ·
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 RRULE
  • Validated, which is when the RRule has been parsed and validated, based on the start date

Implementations§

source§

impl RRule<Unvalidated>

source

pub fn new(freq: Frequency) -> Self

Creates a new unvalidated RRule with default values and the given frequency.

source

pub fn freq(self, freq: Frequency) -> Self

The FREQ rule part identifies the type of recurrence rule.

source

pub fn interval(self, interval: u16) -> Self

The interval between each freq iteration.

source

pub fn count(self, count: u32) -> Self

If given, this determines how many occurrences will be generated.

source

pub fn until(self, until: DateTime<Tz>) -> Self

If given, this must be a datetime instance specifying the upper-bound limit of the recurrence.

source

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.

source

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.

source

pub fn by_month(self, by_month: &[Month]) -> Self

When given, these variables will define the months to apply the recurrence to.

source

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.

source

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.

source

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.

source

pub fn by_weekday(self, by_weekday: Vec<NWeekday>) -> Self

When given, these variables will define the weekdays where the recurrence will be applied.

source

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.

source

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.

source

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

pub fn validate( self, dt_start: DateTime<Tz> ) -> Result<RRule<Validated>, RRuleError>

Validates the RRule with the given dt_start.

§Errors

If the properties aren’t valid, it will return RRuleError.

source

pub fn build(self, dt_start: DateTime<Tz>) -> Result<RRuleSet, RRuleError>

Validates the RRule with the given dt_start and creates an RRuleSet struct.

§Errors

Returns RRuleError::ValidationError in case the rrule is invalid.

source§

impl<S> RRule<S>

source

pub fn get_freq(&self) -> Frequency

Get the frequency of the recurrence.

source

pub fn get_interval(&self) -> u16

Get the interval of the recurrence.

source

pub fn get_count(&self) -> Option<u32>

Get the count of the recurrence.

source

pub fn get_until(&self) -> Option<&DateTime<Tz>>

Get the until of the recurrence.

source

pub fn get_week_start(&self) -> Weekday

Get the by_set_pos of the recurrence.

source

pub fn get_by_set_pos(&self) -> &[i32]

Get the by_month of the recurrence.

source

pub fn get_by_month(&self) -> &[u8]

Get the by_month of the recurrence.

source

pub fn get_by_month_day(&self) -> &[i8]

Get the by_month_day of the recurrence.

source

pub fn get_by_year_day(&self) -> &[i16]

Get the by_year_day of the recurrence.

source

pub fn get_by_week_no(&self) -> &[i8]

Get the by_hour of the recurrence.

source

pub fn get_by_weekday(&self) -> &[NWeekday]

Get the by_hour of the recurrence.

source

pub fn get_by_hour(&self) -> &[u8]

Get the by_hour of the recurrence.

source

pub fn get_by_minute(&self) -> &[u8]

Get the by_minute of the recurrence.

source

pub fn get_by_second(&self) -> &[u8]

Get the by_second of the recurrence.

Trait Implementations§

source§

impl<Stage: Clone> Clone for RRule<Stage>

source§

fn clone(&self) -> RRule<Stage>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<Stage: Debug> Debug for RRule<Stage>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for RRule<Unvalidated>

source§

fn default() -> Self

Creates a new unvalidated RRule with default values and Yearly frequency.

source§

impl<S> Display for RRule<S>

source§

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().

source§

impl FromStr for RRule<Unvalidated>

§

type Err = RRuleError

The associated error which can be returned from parsing.
source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
source§

impl<Stage: PartialEq> PartialEq for RRule<Stage>

source§

fn eq(&self, other: &RRule<Stage>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<Stage: Eq> Eq for RRule<Stage>

source§

impl<Stage> StructuralPartialEq for RRule<Stage>

Auto Trait Implementations§

§

impl<Stage> Freeze for RRule<Stage>

§

impl<Stage> RefUnwindSafe for RRule<Stage>
where Stage: RefUnwindSafe,

§

impl<Stage> Send for RRule<Stage>
where Stage: Send,

§

impl<Stage> Sync for RRule<Stage>
where Stage: Sync,

§

impl<Stage> Unpin for RRule<Stage>
where Stage: Unpin,

§

impl<Stage> UnwindSafe for RRule<Stage>
where Stage: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.