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