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