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