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 ///
129 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
130 #[unsafe(method(setRecurrenceEnd:))]
131 #[unsafe(method_family = none)]
132 pub unsafe fn setRecurrenceEnd(&self, recurrence_end: Option<&EKRecurrenceEnd>);
133
134 #[cfg(feature = "EKTypes")]
135 /// This property designates the unit of time used to describe the recurrence pattern.
136 #[unsafe(method(frequency))]
137 #[unsafe(method_family = none)]
138 pub unsafe fn frequency(&self) -> EKRecurrenceFrequency;
139
140 /// The interval of a EKRecurrenceRule is an integer value which specifies how often the recurrence rule repeats
141 /// over the unit of time described by the EKRecurrenceFrequency. For example, if the EKRecurrenceFrequency is
142 /// EKRecurrenceWeekly, then an interval of 1 means the pattern is repeated every week. A value of 2
143 /// indicates it is repeated every other week, 3 means every third week, and so on. The value must be a
144 /// positive integer; 0 is not a valid value, and nil will be returned if the client attempts to initialize a
145 /// rule with a negative or zero interval.
146 #[unsafe(method(interval))]
147 #[unsafe(method_family = none)]
148 pub unsafe fn interval(&self) -> NSInteger;
149
150 /// Recurrence patterns can specify which day of the week should be treated as the first day. Possible values for this
151 /// property are integers 0 and 1-7, which correspond to days of the week with Sunday = 1. Zero indicates that the
152 /// property is not set for this recurrence. The first day of the week only affects the way the recurrence is expanded
153 /// for weekly recurrence patterns with an interval greater than 1. For those types of recurrence patterns, the
154 /// Calendar framework will set firstDayOfTheWeek to be 2 (Monday). In all other cases, this property will be set
155 /// to zero. The iCalendar spec stipulates that the default value is Monday if this property is not set.
156 #[unsafe(method(firstDayOfTheWeek))]
157 #[unsafe(method_family = none)]
158 pub unsafe fn firstDayOfTheWeek(&self) -> NSInteger;
159
160 #[cfg(feature = "EKRecurrenceDayOfWeek")]
161 /// This property is valid for rules whose EKRecurrenceFrequency is EKRecurrenceFrequencyWeekly, EKRecurrenceFrequencyMonthly, or
162 /// EKRecurrenceFrequencyYearly. This property can be accessed as an array containing one or more EKRecurrenceDayOfWeek objects
163 /// corresponding to the days of the week the event recurs. For all other EKRecurrenceRules, this property is nil.
164 /// This property corresponds to BYDAY in the iCalendar specification.
165 #[unsafe(method(daysOfTheWeek))]
166 #[unsafe(method_family = none)]
167 pub unsafe fn daysOfTheWeek(&self) -> Option<Retained<NSArray<EKRecurrenceDayOfWeek>>>;
168
169 /// This property is valid for rules whose EKRecurrenceFrequency is EKRecurrenceFrequencyMonthly, and that were initialized
170 /// 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
171 /// accessed as an array containing one or more NSNumbers corresponding to the days of the month the event recurs.
172 /// For all other EKRecurrenceRules, this property is nil. This property corresponds to BYMONTHDAY in the iCalendar
173 /// specification.
174 #[unsafe(method(daysOfTheMonth))]
175 #[unsafe(method_family = none)]
176 pub unsafe fn daysOfTheMonth(&self) -> Option<Retained<NSArray<NSNumber>>>;
177
178 /// This property is valid for rules whose EKRecurrenceFrequency is EKRecurrenceFrequencyYearly. This property can be accessed
179 /// as an array containing one or more NSNumbers corresponding to the days of the year the event recurs. For all other
180 /// EKRecurrenceRules, this property is nil. This property corresponds to BYYEARDAY in the iCalendar specification. It should
181 /// contain values between 1 to 366 or -366 to -1.
182 #[unsafe(method(daysOfTheYear))]
183 #[unsafe(method_family = none)]
184 pub unsafe fn daysOfTheYear(&self) -> Option<Retained<NSArray<NSNumber>>>;
185
186 /// This property is valid for rules whose EKRecurrenceFrequency is EKRecurrenceFrequencyYearly. This property can be accessed
187 /// as an array containing one or more NSNumbers corresponding to the weeks of the year the event recurs. For all other
188 /// EKRecurrenceRules, this property is nil. This property corresponds to BYWEEK in the iCalendar specification. It should
189 /// contain integers from 1 to 53 or -1 to -53.
190 #[unsafe(method(weeksOfTheYear))]
191 #[unsafe(method_family = none)]
192 pub unsafe fn weeksOfTheYear(&self) -> Option<Retained<NSArray<NSNumber>>>;
193
194 /// This property is valid for rules whose EKRecurrenceFrequency is EKRecurrenceFrequencyYearly. This property can be accessed
195 /// as an array containing one or more NSNumbers corresponding to the months of the year the event recurs. For all other
196 /// EKRecurrenceRules, this property is nil. This property corresponds to BYMONTH in the iCalendar specification.
197 #[unsafe(method(monthsOfTheYear))]
198 #[unsafe(method_family = none)]
199 pub unsafe fn monthsOfTheYear(&self) -> Option<Retained<NSArray<NSNumber>>>;
200
201 /// This property is valid for rules which have a valid daysOfTheWeek, daysOfTheMonth, weeksOfTheYear, or monthsOfTheYear property.
202 /// It allows you to specify a set of ordinal numbers to help choose which objects out of the set of selected events should be
203 /// included. For example, setting the daysOfTheWeek to Monday-Friday and including a value of -1 in the array would indicate
204 /// the last weekday in the recurrence range (month, year, etc). This value corresponds to the iCalendar BYSETPOS property.
205 #[unsafe(method(setPositions))]
206 #[unsafe(method_family = none)]
207 pub unsafe fn setPositions(&self) -> Option<Retained<NSArray<NSNumber>>>;
208 );
209}
210
211/// Methods declared on superclass `NSObject`.
212#[cfg(feature = "EKObject")]
213impl EKRecurrenceRule {
214 extern_methods!(
215 #[unsafe(method(init))]
216 #[unsafe(method_family = init)]
217 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
218
219 #[unsafe(method(new))]
220 #[unsafe(method_family = new)]
221 pub unsafe fn new() -> Retained<Self>;
222 );
223}