objc2_event_kit/generated/
EKRecurrenceRule.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10extern_class!(
11    /// Represents how an event repeats.
12    ///
13    /// This class describes the recurrence pattern for a repeating event. The recurrence rules that
14    /// can be expressed are not restricted to the recurrence patterns that can be set in Calendar's UI.
15    ///
16    /// It is currently not possible to directly modify a EKRecurrenceRule or any of its properties.
17    /// This functionality is achieved by creating a new EKRecurrenceRule, and setting an event to use the new rule.
18    /// When a new recurrence rule is set on an EKEvent, that change is not saved until the client
19    /// has passed the modified event to EKEventStore's saveEvent: method.
20    ///
21    /// See also [Apple's documentation](https://developer.apple.com/documentation/eventkit/ekrecurrencerule?language=objc)
22    #[unsafe(super(EKObject, NSObject))]
23    #[derive(Debug, PartialEq, Eq, Hash)]
24    #[cfg(feature = "EKObject")]
25    pub struct EKRecurrenceRule;
26);
27
28#[cfg(feature = "EKObject")]
29extern_conformance!(
30    unsafe impl NSCopying for EKRecurrenceRule {}
31);
32
33#[cfg(feature = "EKObject")]
34unsafe impl CopyingHelper for EKRecurrenceRule {
35    type Result = Self;
36}
37
38#[cfg(feature = "EKObject")]
39extern_conformance!(
40    unsafe impl NSObjectProtocol for EKRecurrenceRule {}
41);
42
43#[cfg(feature = "EKObject")]
44impl EKRecurrenceRule {
45    extern_methods!(
46        #[cfg(all(feature = "EKRecurrenceEnd", feature = "EKTypes"))]
47        /// Simple initializer to create a recurrence.
48        ///
49        /// This is used to create a simple recurrence with a specific type, interval and end. If interval is
50        /// 0, an exception is raised. The end parameter can be nil.
51        #[unsafe(method(initRecurrenceWithFrequency:interval:end:))]
52        #[unsafe(method_family = init)]
53        pub unsafe fn initRecurrenceWithFrequency_interval_end(
54            this: Allocated<Self>,
55            r#type: EKRecurrenceFrequency,
56            interval: NSInteger,
57            end: Option<&EKRecurrenceEnd>,
58        ) -> Retained<Self>;
59
60        #[cfg(all(
61            feature = "EKRecurrenceDayOfWeek",
62            feature = "EKRecurrenceEnd",
63            feature = "EKTypes"
64        ))]
65        /// The designated initializer.
66        ///
67        /// This can be used to build any kind of recurrence rule. But be aware that certain combinations make
68        /// no sense and will be ignored. For example, if you pass daysOfTheWeek for a daily recurrence, they
69        /// will be ignored.
70        ///
71        /// Parameter `type`: The type of recurrence
72        ///
73        /// Parameter `interval`: The interval. Passing zero will raise an exception.
74        ///
75        /// Parameter `daysOfTheWeek`: An array of EKRecurrenceDayOfWeek objects. Valid for all recurrence types except daily. Ignored otherwise.
76        /// Corresponds to the BYDAY value in the iCalendar specification.
77        ///
78        /// Parameter `daysOfTheMonth`: An array of NSNumbers ([+/-] 1 to 31). Negative numbers infer counting from the end of the month.
79        /// For example, -1 means the last day of the month. Valid only for monthly recurrences. Ignored otherwise.
80        /// Corresponds to the BYMONTHDAY value in the iCalendar specification.
81        ///
82        /// Parameter `monthsOfTheYear`: An array of NSNumbers (1 to 12). Valid only for yearly recurrences. Ignored otherwise. Corresponds to
83        /// the BYMONTH value in the iCalendar specification.
84        ///
85        /// Parameter `weeksOfTheYear`: An array of NSNumbers ([+/1] 1 to 53). Negative numbers infer counting from the end of the year.
86        /// For example, -1 means the last week of the year. Valid only for yearly recurrences. Ignored otherwise.
87        /// Corresponds to the BYWEEKNO value in the iCalendar specification.
88        ///
89        /// Parameter `daysOfTheYear`: An array of NSNumbers ([+/1] 1 to 366). Negative numbers infer counting from the end of the year.
90        /// For example, -1 means the last day of the year. Valid only for yearly recurrences. Ignored otherwise.
91        /// Corresponds to the BYYEARDAY value in the iCalendar specification.
92        ///
93        /// Parameter `setPositions`: An array of NSNumbers ([+/1] 1 to 366). Used at the end of recurrence computation to filter the list
94        /// to the positions specified. Negative numbers indicate starting at the end, i.e. -1 indicates taking the
95        /// last result of the set. Valid when daysOfTheWeek, daysOfTheMonth, monthsOfTheYear, weeksOfTheYear, or
96        /// daysOfTheYear is passed. Ignored otherwise. Corresponds to the BYSETPOS value in the iCalendar specification.
97        ///
98        /// Parameter `end`: The recurrence end, or nil.
99        #[unsafe(method(initRecurrenceWithFrequency:interval:daysOfTheWeek:daysOfTheMonth:monthsOfTheYear:weeksOfTheYear:daysOfTheYear:setPositions:end:))]
100        #[unsafe(method_family = init)]
101        pub unsafe fn initRecurrenceWithFrequency_interval_daysOfTheWeek_daysOfTheMonth_monthsOfTheYear_weeksOfTheYear_daysOfTheYear_setPositions_end(
102            this: Allocated<Self>,
103            r#type: EKRecurrenceFrequency,
104            interval: NSInteger,
105            days: Option<&NSArray<EKRecurrenceDayOfWeek>>,
106            month_days: Option<&NSArray<NSNumber>>,
107            months: Option<&NSArray<NSNumber>>,
108            weeks_of_the_year: Option<&NSArray<NSNumber>>,
109            days_of_the_year: Option<&NSArray<NSNumber>>,
110            set_positions: Option<&NSArray<NSNumber>>,
111            end: Option<&EKRecurrenceEnd>,
112        ) -> Retained<Self>;
113
114        /// Calendar used by this recurrence rule.
115        #[unsafe(method(calendarIdentifier))]
116        #[unsafe(method_family = none)]
117        pub unsafe fn calendarIdentifier(&self) -> Retained<NSString>;
118
119        #[cfg(feature = "EKRecurrenceEnd")]
120        /// This property defines when the the repeating event is scheduled to end. The end date can be specified by a number of
121        /// occurrences, or with an end date.
122        #[unsafe(method(recurrenceEnd))]
123        #[unsafe(method_family = none)]
124        pub unsafe fn recurrenceEnd(&self) -> Option<Retained<EKRecurrenceEnd>>;
125
126        #[cfg(feature = "EKRecurrenceEnd")]
127        /// Setter for [`recurrenceEnd`][Self::recurrenceEnd].
128        #[unsafe(method(setRecurrenceEnd:))]
129        #[unsafe(method_family = none)]
130        pub unsafe fn setRecurrenceEnd(&self, recurrence_end: Option<&EKRecurrenceEnd>);
131
132        #[cfg(feature = "EKTypes")]
133        /// This property designates the unit of time used to describe the recurrence pattern.
134        #[unsafe(method(frequency))]
135        #[unsafe(method_family = none)]
136        pub unsafe fn frequency(&self) -> EKRecurrenceFrequency;
137
138        /// The interval of a EKRecurrenceRule is an integer value which specifies how often the recurrence rule repeats
139        /// over the unit of time described by the EKRecurrenceFrequency. For example, if the EKRecurrenceFrequency is
140        /// EKRecurrenceWeekly, then an interval of 1 means the pattern is repeated every week. A value of 2
141        /// indicates it is repeated every other week, 3 means every third week, and so on. The value must be a
142        /// positive integer; 0 is not a valid value, and nil will be returned if the client attempts to initialize a
143        /// rule with a negative or zero interval.
144        #[unsafe(method(interval))]
145        #[unsafe(method_family = none)]
146        pub unsafe fn interval(&self) -> NSInteger;
147
148        /// Recurrence patterns can specify which day of the week should be treated as the first day. Possible values for this
149        /// property are integers 0 and 1-7, which correspond to days of the week with Sunday = 1. Zero indicates that the
150        /// property is not set for this recurrence. The first day of the week only affects the way the recurrence is expanded
151        /// for weekly recurrence patterns with an interval greater than 1. For those types of recurrence patterns, the
152        /// Calendar framework will set firstDayOfTheWeek to be 2 (Monday). In all other cases, this property will be set
153        /// to zero. The iCalendar spec stipulates that the default value is Monday if this property is not set.
154        #[unsafe(method(firstDayOfTheWeek))]
155        #[unsafe(method_family = none)]
156        pub unsafe fn firstDayOfTheWeek(&self) -> NSInteger;
157
158        #[cfg(feature = "EKRecurrenceDayOfWeek")]
159        /// This property is valid for rules whose EKRecurrenceFrequency is EKRecurrenceFrequencyWeekly, EKRecurrenceFrequencyMonthly, or
160        /// EKRecurrenceFrequencyYearly. This property can be accessed as an array containing one or more EKRecurrenceDayOfWeek objects
161        /// corresponding to the days of the week the event recurs. For all other EKRecurrenceRules, this property is nil.
162        /// This property corresponds to BYDAY in the iCalendar specification.
163        #[unsafe(method(daysOfTheWeek))]
164        #[unsafe(method_family = none)]
165        pub unsafe fn daysOfTheWeek(&self) -> Option<Retained<NSArray<EKRecurrenceDayOfWeek>>>;
166
167        /// This property is valid for rules whose EKRecurrenceFrequency is EKRecurrenceFrequencyMonthly, and that were initialized
168        /// with one or more specific days of the month (not with a day of the week and week of the month). This property can be
169        /// accessed as an array containing one or more NSNumbers corresponding to the days of the month the event recurs.
170        /// For all other EKRecurrenceRules, this property is nil. This property corresponds to BYMONTHDAY in the iCalendar
171        /// specification.
172        #[unsafe(method(daysOfTheMonth))]
173        #[unsafe(method_family = none)]
174        pub unsafe fn daysOfTheMonth(&self) -> Option<Retained<NSArray<NSNumber>>>;
175
176        /// This property is valid for rules whose EKRecurrenceFrequency is EKRecurrenceFrequencyYearly. This property can be accessed
177        /// as an array containing one or more NSNumbers corresponding to the days of the year the event recurs. For all other
178        /// EKRecurrenceRules, this property is nil. This property corresponds to BYYEARDAY in the iCalendar specification. It should
179        /// contain values between 1 to 366 or -366 to -1.
180        #[unsafe(method(daysOfTheYear))]
181        #[unsafe(method_family = none)]
182        pub unsafe fn daysOfTheYear(&self) -> Option<Retained<NSArray<NSNumber>>>;
183
184        /// This property is valid for rules whose EKRecurrenceFrequency is EKRecurrenceFrequencyYearly. This property can be accessed
185        /// as an array containing one or more NSNumbers corresponding to the weeks of the year the event recurs. For all other
186        /// EKRecurrenceRules, this property is nil. This property corresponds to BYWEEK in the iCalendar specification. It should
187        /// contain integers from 1 to 53 or -1 to -53.
188        #[unsafe(method(weeksOfTheYear))]
189        #[unsafe(method_family = none)]
190        pub unsafe fn weeksOfTheYear(&self) -> Option<Retained<NSArray<NSNumber>>>;
191
192        /// This property is valid for rules whose EKRecurrenceFrequency is EKRecurrenceFrequencyYearly. This property can be accessed
193        /// as an array containing one or more NSNumbers corresponding to the months of the year the event recurs. For all other
194        /// EKRecurrenceRules, this property is nil. This property corresponds to BYMONTH in the iCalendar specification.
195        #[unsafe(method(monthsOfTheYear))]
196        #[unsafe(method_family = none)]
197        pub unsafe fn monthsOfTheYear(&self) -> Option<Retained<NSArray<NSNumber>>>;
198
199        /// This property is valid for rules which have a valid daysOfTheWeek, daysOfTheMonth, weeksOfTheYear, or monthsOfTheYear property.
200        /// It allows you to specify a set of ordinal numbers to help choose which objects out of the set of selected events should be
201        /// included. For example, setting the daysOfTheWeek to Monday-Friday and including a value of -1 in the array would indicate
202        /// the last weekday in the recurrence range (month, year, etc). This value corresponds to the iCalendar BYSETPOS property.
203        #[unsafe(method(setPositions))]
204        #[unsafe(method_family = none)]
205        pub unsafe fn setPositions(&self) -> Option<Retained<NSArray<NSNumber>>>;
206    );
207}
208
209/// Methods declared on superclass `NSObject`.
210#[cfg(feature = "EKObject")]
211impl EKRecurrenceRule {
212    extern_methods!(
213        #[unsafe(method(init))]
214        #[unsafe(method_family = init)]
215        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
216
217        #[unsafe(method(new))]
218        #[unsafe(method_family = new)]
219        pub unsafe fn new() -> Retained<Self>;
220    );
221}