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