objc2_event_kit/generated/
EKEvent.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
10/// [Apple's documentation](https://developer.apple.com/documentation/eventkit/ekeventavailability?language=objc)
11// NS_ENUM
12#[repr(transparent)]
13#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
14pub struct EKEventAvailability(pub NSInteger);
15impl EKEventAvailability {
16    #[doc(alias = "EKEventAvailabilityNotSupported")]
17    pub const NotSupported: Self = Self(-1);
18    #[doc(alias = "EKEventAvailabilityBusy")]
19    pub const Busy: Self = Self(0);
20    #[doc(alias = "EKEventAvailabilityFree")]
21    pub const Free: Self = Self(1);
22    #[doc(alias = "EKEventAvailabilityTentative")]
23    pub const Tentative: Self = Self(2);
24    #[doc(alias = "EKEventAvailabilityUnavailable")]
25    pub const Unavailable: Self = Self(3);
26}
27
28unsafe impl Encode for EKEventAvailability {
29    const ENCODING: Encoding = NSInteger::ENCODING;
30}
31
32unsafe impl RefEncode for EKEventAvailability {
33    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
34}
35
36/// [Apple's documentation](https://developer.apple.com/documentation/eventkit/ekeventstatus?language=objc)
37// NS_ENUM
38#[repr(transparent)]
39#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
40pub struct EKEventStatus(pub NSInteger);
41impl EKEventStatus {
42    #[doc(alias = "EKEventStatusNone")]
43    pub const None: Self = Self(0);
44    #[doc(alias = "EKEventStatusConfirmed")]
45    pub const Confirmed: Self = Self(1);
46    #[doc(alias = "EKEventStatusTentative")]
47    pub const Tentative: Self = Self(2);
48    #[doc(alias = "EKEventStatusCanceled")]
49    pub const Canceled: Self = Self(3);
50}
51
52unsafe impl Encode for EKEventStatus {
53    const ENCODING: Encoding = NSInteger::ENCODING;
54}
55
56unsafe impl RefEncode for EKEventStatus {
57    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
58}
59
60extern_class!(
61    /// The EKEvent class represents an occurrence of an event.
62    ///
63    /// See also [Apple's documentation](https://developer.apple.com/documentation/eventkit/ekevent?language=objc)
64    #[unsafe(super(EKCalendarItem, EKObject, NSObject))]
65    #[derive(Debug, PartialEq, Eq, Hash)]
66    #[cfg(all(feature = "EKCalendarItem", feature = "EKObject"))]
67    pub struct EKEvent;
68);
69
70#[cfg(all(feature = "EKCalendarItem", feature = "EKObject"))]
71extern_conformance!(
72    unsafe impl NSObjectProtocol for EKEvent {}
73);
74
75#[cfg(all(feature = "EKCalendarItem", feature = "EKObject"))]
76impl EKEvent {
77    extern_methods!(
78        #[cfg(feature = "EKEventStore")]
79        /// Creates a new autoreleased event object.
80        #[unsafe(method(eventWithEventStore:))]
81        #[unsafe(method_family = none)]
82        pub unsafe fn eventWithEventStore(event_store: &EKEventStore) -> Retained<EKEvent>;
83
84        /// A unique identifier for this event.
85        ///
86        /// This identifier can be used to look the event up using [EKEventStore eventWithIdentifier:].
87        /// You can use this not only to simply fetch the event, but also to validate the event
88        /// has not been deleted out from under you when you get an external change notification
89        /// via the EKEventStore database changed notification. If eventWithIdentifier: returns nil,
90        /// the event was deleted.
91        ///
92        /// Please note that if you change the calendar of an event, this ID will likely change. It is
93        /// currently also possible for the ID to change due to a sync operation. For example, if
94        /// a user moved an event on a different client to another calendar, we'd see it as a
95        /// completely new event here.
96        ///
97        /// This may be nil for events that have not been saved.
98        #[unsafe(method(eventIdentifier))]
99        #[unsafe(method_family = none)]
100        pub unsafe fn eventIdentifier(&self) -> Option<Retained<NSString>>;
101
102        /// Indicates this event is an 'all day' event.
103        #[unsafe(method(isAllDay))]
104        #[unsafe(method_family = none)]
105        pub unsafe fn isAllDay(&self) -> bool;
106
107        /// Setter for [`isAllDay`][Self::isAllDay].
108        #[unsafe(method(setAllDay:))]
109        #[unsafe(method_family = none)]
110        pub unsafe fn setAllDay(&self, all_day: bool);
111
112        /// The start date for the event.
113        ///
114        /// This property represents the start date for this event. Floating events (such
115        /// as all-day events) are currently always returned in the default time zone.
116        /// ([NSTimeZone defaultTimeZone])
117        ///
118        /// This will be nil for new events until you set it.
119        #[unsafe(method(startDate))]
120        #[unsafe(method_family = none)]
121        pub unsafe fn startDate(&self) -> Retained<NSDate>;
122
123        /// Setter for [`startDate`][Self::startDate].
124        ///
125        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
126        #[unsafe(method(setStartDate:))]
127        #[unsafe(method_family = none)]
128        pub unsafe fn setStartDate(&self, start_date: Option<&NSDate>);
129
130        /// The end date for the event.
131        ///
132        /// This will be nil for new events until you set it.
133        #[unsafe(method(endDate))]
134        #[unsafe(method_family = none)]
135        pub unsafe fn endDate(&self) -> Retained<NSDate>;
136
137        /// Setter for [`endDate`][Self::endDate].
138        ///
139        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
140        #[unsafe(method(setEndDate:))]
141        #[unsafe(method_family = none)]
142        pub unsafe fn setEndDate(&self, end_date: Option<&NSDate>);
143
144        #[cfg(feature = "EKStructuredLocation")]
145        /// Allows you to set a structured location (a location with a potential geo-coordinate) on an
146        /// event. The getter for EKEvent’s location property just returns the structured location’s title.
147        /// The setter for EKEvent’s location property is equivalent to
148        /// [event setStructuredLocation:[EKStructuredLocation locationWithTitle:…]].
149        #[unsafe(method(structuredLocation))]
150        #[unsafe(method_family = none)]
151        pub unsafe fn structuredLocation(&self) -> Option<Retained<EKStructuredLocation>>;
152
153        #[cfg(feature = "EKStructuredLocation")]
154        /// Setter for [`structuredLocation`][Self::structuredLocation].
155        ///
156        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
157        #[unsafe(method(setStructuredLocation:))]
158        #[unsafe(method_family = none)]
159        pub unsafe fn setStructuredLocation(
160            &self,
161            structured_location: Option<&EKStructuredLocation>,
162        );
163
164        /// Comparison function you can pass to sort NSArrays of EKEvents by start date.
165        #[unsafe(method(compareStartDateWithEvent:))]
166        #[unsafe(method_family = none)]
167        pub unsafe fn compareStartDateWithEvent(&self, other: &EKEvent) -> NSComparisonResult;
168
169        #[cfg(feature = "EKParticipant")]
170        /// The organizer of this event, or nil.
171        #[unsafe(method(organizer))]
172        #[unsafe(method_family = none)]
173        pub unsafe fn organizer(&self) -> Option<Retained<EKParticipant>>;
174
175        /// The availability setting for this event.
176        ///
177        /// The availability setting is used by CalDAV and Exchange servers to indicate
178        /// how the time should be treated for scheduling. If the calendar the event is
179        /// currently in does not support event availability, EKEventAvailabilityNotSupported
180        /// is returned.
181        #[unsafe(method(availability))]
182        #[unsafe(method_family = none)]
183        pub unsafe fn availability(&self) -> EKEventAvailability;
184
185        /// Setter for [`availability`][Self::availability].
186        #[unsafe(method(setAvailability:))]
187        #[unsafe(method_family = none)]
188        pub unsafe fn setAvailability(&self, availability: EKEventAvailability);
189
190        /// The status of the event.
191        ///
192        /// While the status offers four different values in the EKEventStatus enumeration,
193        /// in practice, the only actionable and reliable status is canceled. Any other status
194        /// should be considered informational at best. You cannot set this property. If you
195        /// wish to cancel an event, you should simply remove it using removeEvent:.
196        #[unsafe(method(status))]
197        #[unsafe(method_family = none)]
198        pub unsafe fn status(&self) -> EKEventStatus;
199
200        /// Represents whether this event is detached from a recurring series.
201        ///
202        /// If this EKEvent is an instance of a repeating event, and an attribute of this
203        /// EKEvent has been changed from the default value generated by the repeating event,
204        /// isDetached will return YES. If the EKEvent is unchanged from its default state, or
205        /// is not a repeating event, isDetached returns NO.
206        #[unsafe(method(isDetached))]
207        #[unsafe(method_family = none)]
208        pub unsafe fn isDetached(&self) -> bool;
209
210        /// The occurrence date of an event if it is part of a recurring series.
211        ///
212        /// This is only set if the event is part of a recurring series. It returns
213        /// the date on which this event was originally scheduled to occur. For occurrences
214        /// that are unmodified from the recurring series, this is the same as the start date.
215        /// This value will remain the same even if the event has been detached and its start
216        /// date has changed. Floating events (such as all-day events) are currently returned
217        /// in the default time zone. ([NSTimeZone defaultTimeZone])
218        ///
219        /// This will be nil for new events until you set startDate.
220        #[unsafe(method(occurrenceDate))]
221        #[unsafe(method_family = none)]
222        pub unsafe fn occurrenceDate(&self) -> Option<Retained<NSDate>>;
223
224        /// Refreshes an event object to ensure it's still valid.
225        ///
226        /// When the database changes, your application is sent an EKEventStoreChangedNotification
227        /// note. You should generally consider all EKEvent instances to be invalid as soon as
228        /// you receive the notification. However, for events you truly care to keep around, you
229        /// can call this method. It ensures the record is still valid by ensuring the event and
230        /// start date are still valid. It also attempts to refresh all properties except those
231        /// you might have modified. If this method returns NO, the record has been deleted or is
232        /// otherwise invalid. You should not continue to use it. If it returns YES, all is still
233        /// well, and the record is ready for continued use. You should only call this method on
234        /// events that are more critical to keep around if possible, such as an event that is
235        /// being actively edited, as this call is fairly heavyweight. Do not use it to refresh
236        /// the entire selected range of events you might have had selected. It is mostly pointless
237        /// anyway, as recurrence information may have changed.
238        #[unsafe(method(refresh))]
239        #[unsafe(method_family = none)]
240        pub unsafe fn refresh(&self) -> bool;
241
242        /// Specifies the contact identifier of the person this event was created for.
243        ///
244        /// This property is only valid for events in the built-in Birthdays calendar. It specifies
245        /// the contact identifier (for use with the Contacts framework) of the person this event was
246        /// created for. For any other type of event, this property returns nil.
247        #[unsafe(method(birthdayContactIdentifier))]
248        #[unsafe(method_family = none)]
249        pub unsafe fn birthdayContactIdentifier(&self) -> Option<Retained<NSString>>;
250
251        /// Specifies the address book ID of the person this event was created for.
252        ///
253        /// This property is only valid for events in the built-in Birthdays calendar. It specifies
254        /// the Address Book ID of the person this event was created for. For any other type of event,
255        /// this property returns -1.
256        #[unsafe(method(birthdayPersonID))]
257        #[unsafe(method_family = none)]
258        pub unsafe fn birthdayPersonID(&self) -> NSInteger;
259
260        /// Specifies the address book unique ID of the person this event was created for.
261        ///
262        /// This property is only valid for events in the built-in Birthdays calendar. It specifies
263        /// the Address Book unique ID of the person this event was created for. For any other type of event,
264        /// this property returns nil.
265        #[deprecated = "Use birthdayContactIdentifier instead"]
266        #[unsafe(method(birthdayPersonUniqueID))]
267        #[unsafe(method_family = none)]
268        pub unsafe fn birthdayPersonUniqueID(&self) -> Option<Retained<NSString>>;
269    );
270}
271
272/// Methods declared on superclass `NSObject`.
273#[cfg(all(feature = "EKCalendarItem", feature = "EKObject"))]
274impl EKEvent {
275    extern_methods!(
276        #[unsafe(method(init))]
277        #[unsafe(method_family = init)]
278        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
279
280        #[unsafe(method(new))]
281        #[unsafe(method_family = new)]
282        pub unsafe fn new() -> Retained<Self>;
283    );
284}