objc2_home_kit/generated/
HMEventTrigger.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 "C" {
11    /// Specifies the key path for a characteristic in a NSPredicate
12    ///
13    /// See also [Apple's documentation](https://developer.apple.com/documentation/homekit/hmcharacteristickeypath?language=objc)
14    pub static HMCharacteristicKeyPath: &'static NSString;
15}
16
17extern "C" {
18    /// Specifies the key path for a characteristic value in a NSPredicate
19    ///
20    /// See also [Apple's documentation](https://developer.apple.com/documentation/homekit/hmcharacteristicvaluekeypath?language=objc)
21    pub static HMCharacteristicValueKeyPath: &'static NSString;
22}
23
24extern "C" {
25    /// Specifies the key path for a presence event in a NSPredicate
26    ///
27    /// See also [Apple's documentation](https://developer.apple.com/documentation/homekit/hmpresencekeypath?language=objc)
28    pub static HMPresenceKeyPath: &'static NSString;
29}
30
31extern_class!(
32    /// Triggers based on events.
33    ///
34    ///
35    /// This class represents a trigger that is based on events.
36    ///
37    /// See also [Apple's documentation](https://developer.apple.com/documentation/homekit/hmeventtrigger?language=objc)
38    #[unsafe(super(HMTrigger, NSObject))]
39    #[derive(Debug, PartialEq, Eq, Hash)]
40    #[cfg(feature = "HMTrigger")]
41    pub struct HMEventTrigger;
42);
43
44#[cfg(feature = "HMTrigger")]
45unsafe impl Send for HMEventTrigger {}
46
47#[cfg(feature = "HMTrigger")]
48unsafe impl Sync for HMEventTrigger {}
49
50#[cfg(feature = "HMTrigger")]
51extern_conformance!(
52    unsafe impl NSObjectProtocol for HMEventTrigger {}
53);
54
55#[cfg(feature = "HMTrigger")]
56impl HMEventTrigger {
57    extern_methods!(
58        #[unsafe(method(init))]
59        #[unsafe(method_family = init)]
60        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
61
62        #[cfg(feature = "HMEvent")]
63        /// Initializes a new event trigger object.
64        ///
65        ///
66        /// Parameter `name`: Name of the event trigger.
67        ///
68        ///
69        /// Parameter `events`: Array of events that can trigger the evaluation of the trigger. Note: The trigger will
70        /// be evaluated if any one of the events is true.
71        ///
72        ///
73        /// Parameter `predicate`: The predicate to evaluate before executing any of the actions sets associated to this
74        /// event.
75        ///
76        ///
77        /// Returns: Instance object representing the event trigger.
78        #[unsafe(method(initWithName:events:predicate:))]
79        #[unsafe(method_family = init)]
80        pub unsafe fn initWithName_events_predicate(
81            this: Allocated<Self>,
82            name: &NSString,
83            events: &NSArray<HMEvent>,
84            predicate: Option<&NSPredicate>,
85        ) -> Retained<Self>;
86
87        #[cfg(feature = "HMEvent")]
88        /// Initializes a new event trigger object.
89        ///
90        ///
91        /// Parameter `name`: Name of the event trigger.
92        ///
93        ///
94        /// Parameter `events`: Array of events that can trigger the evaluation of the trigger. Note: The trigger will
95        /// be evaluated if any one of the events is true.
96        ///
97        ///
98        /// Parameter `endEvents`: Array of end events that can trigger the restoration to the state before the scene was run.
99        ///
100        ///
101        /// Parameter `recurrences`: Specifies the days of the week when the trigger is to be evaluated. Only the 'weekday' property
102        /// is honored in NSDateComponents.
103        ///
104        ///
105        /// Parameter `predicate`: The predicate to evaluate before executing any of the actions sets associated to this
106        /// event.
107        ///
108        ///
109        /// Returns: Instance object representing the event trigger.
110        #[unsafe(method(initWithName:events:endEvents:recurrences:predicate:))]
111        #[unsafe(method_family = init)]
112        pub unsafe fn initWithName_events_endEvents_recurrences_predicate(
113            this: Allocated<Self>,
114            name: &NSString,
115            events: &NSArray<HMEvent>,
116            end_events: Option<&NSArray<HMEvent>>,
117            recurrences: Option<&NSArray<NSDateComponents>>,
118            predicate: Option<&NSPredicate>,
119        ) -> Retained<Self>;
120
121        #[cfg(feature = "HMEvent")]
122        /// The events associated with the trigger.
123        ///
124        /// This property is not atomic.
125        ///
126        /// # Safety
127        ///
128        /// This might not be thread-safe.
129        #[unsafe(method(events))]
130        #[unsafe(method_family = none)]
131        pub unsafe fn events(&self) -> Retained<NSArray<HMEvent>>;
132
133        #[cfg(feature = "HMEvent")]
134        /// The events that correspond to executing the restore of the scene before the trigger was executed.
135        /// E.g. Execute the scene for 10 mins and restore original state is achieved by specifying a corresponding
136        /// HMDurationEvent in the list of endEvents.
137        ///
138        /// This property is not atomic.
139        ///
140        /// # Safety
141        ///
142        /// This might not be thread-safe.
143        #[unsafe(method(endEvents))]
144        #[unsafe(method_family = none)]
145        pub unsafe fn endEvents(&self) -> Retained<NSArray<HMEvent>>;
146
147        /// The predicate to evaluate before executing the action sets associated with the trigger.
148        ///
149        /// This property is not atomic.
150        ///
151        /// # Safety
152        ///
153        /// This might not be thread-safe.
154        #[unsafe(method(predicate))]
155        #[unsafe(method_family = none)]
156        pub unsafe fn predicate(&self) -> Option<Retained<NSPredicate>>;
157
158        /// recurrences Specifies the recurrences for when the trigger is evaluated. This only supports days of the week.
159        ///
160        /// This property is not atomic.
161        ///
162        /// # Safety
163        ///
164        /// This might not be thread-safe.
165        #[unsafe(method(recurrences))]
166        #[unsafe(method_family = none)]
167        pub unsafe fn recurrences(&self) -> Option<Retained<NSArray<NSDateComponents>>>;
168
169        /// Specifies whether this trigger is executed only once after which the trigger is disabled.
170        ///
171        /// This property is not atomic.
172        ///
173        /// # Safety
174        ///
175        /// This might not be thread-safe.
176        #[unsafe(method(executeOnce))]
177        #[unsafe(method_family = none)]
178        pub unsafe fn executeOnce(&self) -> bool;
179
180        #[cfg(feature = "HMEventTriggerActivationState")]
181        /// Specifies the current activation state of the trigger.
182        ///
183        /// This property is not atomic.
184        ///
185        /// # Safety
186        ///
187        /// This might not be thread-safe.
188        #[unsafe(method(triggerActivationState))]
189        #[unsafe(method_family = none)]
190        pub unsafe fn triggerActivationState(&self) -> HMEventTriggerActivationState;
191
192        #[cfg(all(feature = "HMEvent", feature = "block2"))]
193        /// Adds a new event to the event trigger.
194        ///
195        ///
196        /// Parameter `event`: Event to add to the event trigger.
197        ///
198        ///
199        /// Parameter `completion`: Block that is invoked once the request is processed.
200        /// The NSError provides more information on the status of the request, error
201        /// will be nil on success.
202        #[deprecated = "Use updateEvents:completionHandler: instead"]
203        #[unsafe(method(addEvent:completionHandler:))]
204        #[unsafe(method_family = none)]
205        pub unsafe fn addEvent_completionHandler(
206            &self,
207            event: &HMEvent,
208            completion: &block2::DynBlock<dyn Fn(*mut NSError)>,
209        );
210
211        #[cfg(all(feature = "HMEvent", feature = "block2"))]
212        /// Removes the specified event from the event trigger.
213        ///
214        ///
215        /// Parameter `event`: Event to remove from the event trigger.
216        ///
217        ///
218        /// Parameter `completion`: Block that is invoked once the request is processed.
219        /// The NSError provides more information on the status of the request, error
220        /// will be nil on success.
221        #[deprecated = "Use updateEvents:completionHandler: instead"]
222        #[unsafe(method(removeEvent:completionHandler:))]
223        #[unsafe(method_family = none)]
224        pub unsafe fn removeEvent_completionHandler(
225            &self,
226            event: &HMEvent,
227            completion: &block2::DynBlock<dyn Fn(*mut NSError)>,
228        );
229
230        #[cfg(all(feature = "HMEvent", feature = "block2"))]
231        /// Updates the set of events in the event trigger.
232        ///
233        ///
234        /// Parameter `events`: Events to update in the event trigger
235        ///
236        ///
237        /// Parameter `completion`: Block that is invoked once the request is processed.
238        /// The NSError provides more information on the status of the request, error
239        /// will be nil on success.
240        #[unsafe(method(updateEvents:completionHandler:))]
241        #[unsafe(method_family = none)]
242        pub unsafe fn updateEvents_completionHandler(
243            &self,
244            events: &NSArray<HMEvent>,
245            completion: &block2::DynBlock<dyn Fn(*mut NSError)>,
246        );
247
248        #[cfg(all(feature = "HMEvent", feature = "block2"))]
249        /// Updates the set of events in the event trigger.
250        ///
251        ///
252        /// Parameter `endEvents`: Events to update in the event trigger
253        ///
254        ///
255        /// Parameter `completion`: Block that is invoked once the request is processed.
256        /// The NSError provides more information on the status of the request, error
257        /// will be nil on success.
258        #[unsafe(method(updateEndEvents:completionHandler:))]
259        #[unsafe(method_family = none)]
260        pub unsafe fn updateEndEvents_completionHandler(
261            &self,
262            end_events: &NSArray<HMEvent>,
263            completion: &block2::DynBlock<dyn Fn(*mut NSError)>,
264        );
265
266        #[cfg(feature = "block2")]
267        /// This method replaces the predicate used to evaluate execution of the action sets associated with the trigger.
268        ///
269        ///
270        /// Parameter `predicate`: The new predicate for the event trigger.
271        ///
272        ///
273        /// Parameter `completion`: Block that is invoked once the request is processed.
274        /// The NSError provides more information on the status of the request,
275        /// error will be nil on success.
276        #[unsafe(method(updatePredicate:completionHandler:))]
277        #[unsafe(method_family = none)]
278        pub unsafe fn updatePredicate_completionHandler(
279            &self,
280            predicate: Option<&NSPredicate>,
281            completion: &block2::DynBlock<dyn Fn(*mut NSError)>,
282        );
283
284        #[cfg(feature = "block2")]
285        /// This method replaces the recurrences which secifies the days of the week when the trigger is to be evaluated.
286        ///
287        ///
288        /// Parameter `recurrences`: The new recurrences for the event trigger.
289        ///
290        ///
291        /// Parameter `completion`: Block that is invoked once the request is processed.
292        /// The NSError provides more information on the status of the request,
293        /// error will be nil on success.
294        #[unsafe(method(updateRecurrences:completionHandler:))]
295        #[unsafe(method_family = none)]
296        pub unsafe fn updateRecurrences_completionHandler(
297            &self,
298            recurrences: Option<&NSArray<NSDateComponents>>,
299            completion: &block2::DynBlock<dyn Fn(*mut NSError)>,
300        );
301
302        #[cfg(feature = "block2")]
303        /// This method is used to update whether the event trigger repeats or not.
304        ///
305        ///
306        /// Parameter `executeOnce`: Specifies whether the event trigger is repeated or not.
307        ///
308        ///
309        /// Parameter `completion`: Block that is invoked once the request is processed.
310        /// The NSError provides more information on the status of the request, error
311        /// will be nil on success.
312        #[unsafe(method(updateExecuteOnce:completionHandler:))]
313        #[unsafe(method_family = none)]
314        pub unsafe fn updateExecuteOnce_completionHandler(
315            &self,
316            execute_once: bool,
317            completion: &block2::DynBlock<dyn Fn(*mut NSError)>,
318        );
319    );
320}
321
322/// Methods declared on superclass `NSObject`.
323#[cfg(feature = "HMTrigger")]
324impl HMEventTrigger {
325    extern_methods!(
326        #[unsafe(method(new))]
327        #[unsafe(method_family = new)]
328        pub unsafe fn new() -> Retained<Self>;
329    );
330}
331
332/// NSPredicate.
333#[cfg(feature = "HMTrigger")]
334impl HMEventTrigger {
335    extern_methods!(
336        /// Creates a predicate that will evaluate whether the event occurred before a significant event.
337        ///
338        ///
339        /// Parameter `significantEvent`: The significant event to compare against.
340        /// The valid values are: HMSignificantEventSunrise and HMSignificantEventSunset.
341        ///
342        ///
343        /// Parameter `offset`: An offset from the time of the signficant event. To specify an offset before the significant event, the
344        /// properties of the NSDateComponents must be negative value. e.g. To specify 30 mins before sunset, the
345        /// 'minute' property must be set to -30.
346        ///
347        ///
348        /// Returns: Predicate object representing a condition to evaluate before executing the action set.
349        #[deprecated = "Use predicateForEvaluatingTriggerOccurringBeforeSignificantEvent: instead"]
350        #[unsafe(method(predicateForEvaluatingTriggerOccurringBeforeSignificantEvent:applyingOffset:))]
351        #[unsafe(method_family = none)]
352        pub unsafe fn predicateForEvaluatingTriggerOccurringBeforeSignificantEvent_applyingOffset(
353            significant_event: &NSString,
354            offset: Option<&NSDateComponents>,
355        ) -> Retained<NSPredicate>;
356
357        #[cfg(all(
358            feature = "HMEvent",
359            feature = "HMSignificantTimeEvent",
360            feature = "HMTimeEvent"
361        ))]
362        /// Creates a predicate that will evaluate whether the event occurred before a significant event.
363        ///
364        ///
365        /// Parameter `significantEvent`: The significant event to compare against.
366        ///
367        ///
368        /// Returns: Predicate object representing a condition to evaluate before executing the action set.
369        #[unsafe(method(predicateForEvaluatingTriggerOccurringBeforeSignificantEvent:))]
370        #[unsafe(method_family = none)]
371        pub unsafe fn predicateForEvaluatingTriggerOccurringBeforeSignificantEvent(
372            significant_event: &HMSignificantTimeEvent,
373        ) -> Retained<NSPredicate>;
374
375        /// Creates a predicate that will evaluate whether the event occurred after a significant event.
376        ///
377        ///
378        /// Parameter `significantEvent`: The significant event to compare against.
379        /// The valid values are: HMSignificantEventSunrise and HMSignificantEventSunset.
380        ///
381        ///
382        /// Parameter `offset`: An offset from the time of the signficant event. To specify an offset after the significant event, the
383        /// properties of the NSDateComponents must be positive value. e.g. To specify 30 mins after sunset, the
384        /// 'minute' property must be set to 30.
385        ///
386        ///
387        /// Returns: Predicate object representing a condition to evaluate before executing the action set.
388        #[deprecated = "Use predicateForEvaluatingTriggerOccurringAfterSignificantEvent: instead"]
389        #[unsafe(method(predicateForEvaluatingTriggerOccurringAfterSignificantEvent:applyingOffset:))]
390        #[unsafe(method_family = none)]
391        pub unsafe fn predicateForEvaluatingTriggerOccurringAfterSignificantEvent_applyingOffset(
392            significant_event: &NSString,
393            offset: Option<&NSDateComponents>,
394        ) -> Retained<NSPredicate>;
395
396        #[cfg(all(
397            feature = "HMEvent",
398            feature = "HMSignificantTimeEvent",
399            feature = "HMTimeEvent"
400        ))]
401        /// Creates a predicate that will evaluate whether the event occurred after a significant event.
402        ///
403        ///
404        /// Parameter `significantEvent`: The significant event to compare against.
405        ///
406        ///
407        /// Returns: Predicate object representing a condition to evaluate before executing the action set.
408        #[unsafe(method(predicateForEvaluatingTriggerOccurringAfterSignificantEvent:))]
409        #[unsafe(method_family = none)]
410        pub unsafe fn predicateForEvaluatingTriggerOccurringAfterSignificantEvent(
411            significant_event: &HMSignificantTimeEvent,
412        ) -> Retained<NSPredicate>;
413
414        #[cfg(all(
415            feature = "HMEvent",
416            feature = "HMSignificantTimeEvent",
417            feature = "HMTimeEvent"
418        ))]
419        /// Creates a predicate that will evaluate whether the event occurred between two significant events.
420        ///
421        ///
422        /// Parameter `firstSignificantEvent`: The first significant event.
423        ///
424        ///
425        /// Parameter `secondSignificantEvent`: The second significant event.
426        ///
427        ///
428        /// Returns: Predicate object representing a condition to evaluate before executing the action set.
429        #[unsafe(method(predicateForEvaluatingTriggerOccurringBetweenSignificantEvent:secondSignificantEvent:))]
430        #[unsafe(method_family = none)]
431        pub unsafe fn predicateForEvaluatingTriggerOccurringBetweenSignificantEvent_secondSignificantEvent(
432            first_significant_event: &HMSignificantTimeEvent,
433            second_significant_event: &HMSignificantTimeEvent,
434        ) -> Retained<NSPredicate>;
435
436        /// Creates a predicate that will evaluate whether the event occurred before the time specified.
437        ///
438        ///
439        /// Parameter `dateComponents`: Date components representing the time to compare against when the event occurs.
440        ///
441        ///
442        /// Returns: Predicate object representing a condition to evaluate before executing the action set.
443        #[unsafe(method(predicateForEvaluatingTriggerOccurringBeforeDateWithComponents:))]
444        #[unsafe(method_family = none)]
445        pub unsafe fn predicateForEvaluatingTriggerOccurringBeforeDateWithComponents(
446            date_components: &NSDateComponents,
447        ) -> Retained<NSPredicate>;
448
449        /// Creates a predicate that will evaluate whether the event occurred at the time specified.
450        ///
451        ///
452        /// Parameter `dateComponents`: Date components representing the time to compare against when the event occurs.
453        ///
454        ///
455        /// Returns: Predicate object representing a condition to evaluate before executing the action set.
456        #[unsafe(method(predicateForEvaluatingTriggerOccurringOnDateWithComponents:))]
457        #[unsafe(method_family = none)]
458        pub unsafe fn predicateForEvaluatingTriggerOccurringOnDateWithComponents(
459            date_components: &NSDateComponents,
460        ) -> Retained<NSPredicate>;
461
462        /// Creates a predicate that will evaluate whether the event occurred at or after the time specified.
463        ///
464        ///
465        /// Parameter `dateComponents`: Date components representing the time to compare against when the event occurs.
466        ///
467        ///
468        /// Returns: Predicate object representing a condition to evaluate before executing the action set.
469        #[unsafe(method(predicateForEvaluatingTriggerOccurringAfterDateWithComponents:))]
470        #[unsafe(method_family = none)]
471        pub unsafe fn predicateForEvaluatingTriggerOccurringAfterDateWithComponents(
472            date_components: &NSDateComponents,
473        ) -> Retained<NSPredicate>;
474
475        /// Creates a predicate that will evaluate whether the event occurred between two times.
476        ///
477        ///
478        /// Parameter `firstDateComponents`: The first date component.
479        ///
480        ///
481        /// Parameter `secondDateWithComponents`: The second date component.
482        ///
483        ///
484        /// Returns: Predicate object representing a condition to evaluate before executing the action set.
485        #[unsafe(method(predicateForEvaluatingTriggerOccurringBetweenDateWithComponents:secondDateWithComponents:))]
486        #[unsafe(method_family = none)]
487        pub unsafe fn predicateForEvaluatingTriggerOccurringBetweenDateWithComponents_secondDateWithComponents(
488            first_date_components: &NSDateComponents,
489            second_date_with_components: &NSDateComponents,
490        ) -> Retained<NSPredicate>;
491
492        #[cfg(feature = "HMCharacteristic")]
493        /// Creates a predicate that will evaluate whether a characteristic value is related to the specified value.
494        ///
495        ///
496        /// Parameter `characteristic`: The characteristic that is evaluated as part of the predicate.
497        ///
498        ///
499        /// Parameter `operatorType`: The relation between the characteristic and the target value.
500        /// This can be either Less Than, Greater Than, Less Than or Equal, Greater Than or Equal, Equal, or Not Equal.
501        /// Anything else will cause an exception to be thrown.
502        ///
503        ///
504        /// Parameter `value`: The value of the characteristic to compare when evaluating the predicate.
505        ///
506        ///
507        /// Returns: Predicate object representing a condition to evaluate before executing the action set.
508        ///
509        /// # Safety
510        ///
511        /// `value` should be of the correct type.
512        #[unsafe(method(predicateForEvaluatingTriggerWithCharacteristic:relatedBy:toValue:))]
513        #[unsafe(method_family = none)]
514        pub unsafe fn predicateForEvaluatingTriggerWithCharacteristic_relatedBy_toValue(
515            characteristic: &HMCharacteristic,
516            operator_type: NSPredicateOperatorType,
517            value: &AnyObject,
518        ) -> Retained<NSPredicate>;
519
520        #[cfg(all(feature = "HMEvent", feature = "HMPresenceEvent"))]
521        /// Creates a predicate that will evaluate based on the presence event.
522        ///
523        ///
524        /// Parameter `presenceEvent`: The presenceEvent that is evaluated as part of the predicate.
525        ///
526        ///
527        /// Returns: Predicate object representing a condition to evaluate before executing the action set.
528        #[unsafe(method(predicateForEvaluatingTriggerWithPresence:))]
529        #[unsafe(method_family = none)]
530        pub unsafe fn predicateForEvaluatingTriggerWithPresence(
531            presence_event: &HMPresenceEvent,
532        ) -> Retained<NSPredicate>;
533    );
534}