Skip to main content

RecurrenceRuleData

Struct RecurrenceRuleData 

Source
#[non_exhaustive]
pub struct RecurrenceRuleData { pub start: Timestamp, pub frequency: RecurrenceFrequency, pub interval: u16, pub by_weekday: Vec<RecurrenceWeekday>, pub by_n_weekday: Vec<RecurrenceNWeekday>, pub by_month: Vec<RecurrenceMonth>, pub by_month_day: Vec<u8>, }
Expand description

How a scheduled event repeats, as sent to Discord (D-124): the settable fields of a RecurrenceRule.

Discord accepts only some combinations; the constructors build exactly those shapes: daily, daily_on (a known set of weekdays), weekly, every_other_week, monthly (the n-th weekday) and yearly. From<RecurrenceRule> keeps the rule of an existing event.

discord.js counterpart: GuildScheduledEventRecurrenceRuleOptions.

§Examples

use djs_model::{
    guild_scheduled_event::RecurrenceWeekday, rest::RecurrenceRuleData, util::Timestamp,
};

let start = Timestamp::parse("2026-11-17T18:00:00Z")?;
let rule = RecurrenceRuleData::monthly(start, 3, RecurrenceWeekday::Tuesday);
assert_eq!(
    serde_json::to_string(&rule)?,
    r#"{"start":"2026-11-17T18:00:00.000000+00:00","frequency":1,"interval":1,"by_n_weekday":[{"n":3,"day":1}]}"#
);

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§start: Timestamp

When the recurrence starts (the first occurrence).

§frequency: RecurrenceFrequency

How often the event repeats.

§interval: u16

The spacing between occurrences in units of frequency; only weekly events may use 2.

§by_weekday: Vec<RecurrenceWeekday>

The weekdays to repeat on (daily: a known set; weekly: one day).

§by_n_weekday: Vec<RecurrenceNWeekday>

The n-th weekday of the month to repeat on (monthly: one entry).

§by_month: Vec<RecurrenceMonth>

The month to repeat in (yearly: one entry, with by_month_day).

§by_month_day: Vec<u8>

The day of the month to repeat on (yearly: one entry, with by_month).

Implementations§

Source§

impl RecurrenceRuleData

Source

pub const fn daily(start: Timestamp) -> Self

Every day.

discord.js counterpart: GuildScheduledEventRecurrenceRuleOptions with frequency: Daily.

Source

pub fn daily_on( start: Timestamp, days: impl IntoIterator<Item = RecurrenceWeekday>, ) -> Self

Every day of a set of weekdays. Discord accepts these sets only: Monday–Friday, Tuesday–Saturday, Sunday–Thursday, Friday and Saturday, Saturday and Sunday, Sunday and Monday.

discord.js counterpart: GuildScheduledEventRecurrenceRuleOptions with frequency: Daily and byWeekday.

Source

pub fn weekly(start: Timestamp, day: RecurrenceWeekday) -> Self

Every week on day.

discord.js counterpart: GuildScheduledEventRecurrenceRuleOptions with frequency: Weekly.

Source

pub fn every_other_week(start: Timestamp, day: RecurrenceWeekday) -> Self

Every other week on day.

discord.js counterpart: GuildScheduledEventRecurrenceRuleOptions with frequency: Weekly and interval: 2.

Source

pub fn monthly(start: Timestamp, n: u8, day: RecurrenceWeekday) -> Self

Every month on the n-th (1-5) day, e.g. the third Tuesday.

discord.js counterpart: GuildScheduledEventRecurrenceRuleOptions with frequency: Monthly.

Source

pub fn yearly(start: Timestamp, month: RecurrenceMonth, day: u8) -> Self

Every year on day of month.

discord.js counterpart: GuildScheduledEventRecurrenceRuleOptions with frequency: Yearly.

Trait Implementations§

Source§

impl Clone for RecurrenceRuleData

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for RecurrenceRuleData

Source§

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

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

impl Eq for RecurrenceRuleData

Source§

impl From<RecurrenceRule> for RecurrenceRuleData

Source§

fn from(rule: RecurrenceRule) -> Self

Keeps the settable fields of an existing rule (not end, count, by_year_day).

Source§

impl PartialEq for RecurrenceRuleData

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl Serialize for RecurrenceRuleData

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for RecurrenceRuleData

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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,

Source§

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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.