objc2_home_kit/generated/HMTrigger.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_class!(
11 /// Represents a trigger event.
12 ///
13 ///
14 /// This class describes a trigger which is an event that can
15 /// be used to execute one or more action sets when the event fires.
16 ///
17 /// See also [Apple's documentation](https://developer.apple.com/documentation/homekit/hmtrigger?language=objc)
18 #[unsafe(super(NSObject))]
19 #[derive(Debug, PartialEq, Eq, Hash)]
20 pub struct HMTrigger;
21);
22
23unsafe impl Send for HMTrigger {}
24
25unsafe impl Sync for HMTrigger {}
26
27extern_conformance!(
28 unsafe impl NSObjectProtocol for HMTrigger {}
29);
30
31impl HMTrigger {
32 extern_methods!(
33 #[unsafe(method(init))]
34 #[unsafe(method_family = init)]
35 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
36
37 /// Name of the trigger.
38 ///
39 /// This property is not atomic.
40 ///
41 /// # Safety
42 ///
43 /// This might not be thread-safe.
44 #[unsafe(method(name))]
45 #[unsafe(method_family = none)]
46 pub unsafe fn name(&self) -> Retained<NSString>;
47
48 /// State of the trigger.
49 ///
50 ///
51 /// TRUE if the trigger is enable, FALSE otherwise.
52 ///
53 /// This property is not atomic.
54 ///
55 /// # Safety
56 ///
57 /// This might not be thread-safe.
58 #[unsafe(method(isEnabled))]
59 #[unsafe(method_family = none)]
60 pub unsafe fn isEnabled(&self) -> bool;
61
62 #[cfg(feature = "HMActionSet")]
63 /// Array of HMActionSet objects that represent all the action sets associated
64 /// with this trigger.
65 ///
66 /// This property is not atomic.
67 ///
68 /// # Safety
69 ///
70 /// This might not be thread-safe.
71 #[unsafe(method(actionSets))]
72 #[unsafe(method_family = none)]
73 pub unsafe fn actionSets(&self) -> Retained<NSArray<HMActionSet>>;
74
75 /// The date that this trigger was most recently fired.
76 ///
77 /// This property is not atomic.
78 ///
79 /// # Safety
80 ///
81 /// This might not be thread-safe.
82 #[deprecated = "No longer supported"]
83 #[unsafe(method(lastFireDate))]
84 #[unsafe(method_family = none)]
85 pub unsafe fn lastFireDate(&self) -> Option<Retained<NSDate>>;
86
87 /// A unique identifier for the trigger.
88 ///
89 /// This property is not atomic.
90 ///
91 /// # Safety
92 ///
93 /// This might not be thread-safe.
94 #[unsafe(method(uniqueIdentifier))]
95 #[unsafe(method_family = none)]
96 pub unsafe fn uniqueIdentifier(&self) -> Retained<NSUUID>;
97
98 #[cfg(feature = "block2")]
99 /// This method is used to change the name of the trigger.
100 ///
101 ///
102 /// Parameter `name`: New name for the trigger.
103 ///
104 ///
105 /// Parameter `completion`: Block that is invoked once the request is processed.
106 /// The NSError provides more information on the status of the request.
107 #[unsafe(method(updateName:completionHandler:))]
108 #[unsafe(method_family = none)]
109 pub unsafe fn updateName_completionHandler(
110 &self,
111 name: &NSString,
112 completion: &block2::DynBlock<dyn Fn(*mut NSError)>,
113 );
114
115 #[cfg(all(feature = "HMActionSet", feature = "block2"))]
116 /// Registers an action set to be executed when the trigger is fired.
117 ///
118 ///
119 /// Parameter `actionSet`: HMActionSet to execute when the trigger fires. The order of execution of the
120 /// action set is not guaranteed.
121 ///
122 ///
123 /// Parameter `completion`: Block that is invoked once the request is processed.
124 /// The NSError provides more information on the status of the request.
125 #[unsafe(method(addActionSet:completionHandler:))]
126 #[unsafe(method_family = none)]
127 pub unsafe fn addActionSet_completionHandler(
128 &self,
129 action_set: &HMActionSet,
130 completion: &block2::DynBlock<dyn Fn(*mut NSError)>,
131 );
132
133 #[cfg(all(feature = "HMActionSet", feature = "block2"))]
134 /// De-registers an action set from the trigger.
135 ///
136 ///
137 /// Parameter `actionSet`: The HMActionSet to disassociate from the trigger.
138 ///
139 ///
140 /// Parameter `completion`: Block that is invoked once the request is processed.
141 /// The NSError provides more information on the status of the request.
142 #[unsafe(method(removeActionSet:completionHandler:))]
143 #[unsafe(method_family = none)]
144 pub unsafe fn removeActionSet_completionHandler(
145 &self,
146 action_set: &HMActionSet,
147 completion: &block2::DynBlock<dyn Fn(*mut NSError)>,
148 );
149
150 #[cfg(feature = "block2")]
151 /// Enables or disables the trigger.
152 ///
153 /// In order for the trigger to be enabled the following criteria must be met:
154 /// 1. The trigger must be added to a home.
155 /// 2. The trigger must have at least one action set associated with it.
156 /// 3. Each action set added to the trigger must have at least one action.
157 /// 4. For HMTimerTrigger: The next fire date of the timer trigger must be less
158 /// than 5 weeks in the future. The fire date of a one-shot timer trigger
159 /// must be in the future.
160 ///
161 ///
162 /// Parameter `enable`: Setting this to TRUE will enable the trigger, FALSE will disable it.
163 ///
164 ///
165 /// Parameter `completion`: Block that is invoked once the request is processed.
166 /// The NSError provides more information on the status of the request.
167 #[unsafe(method(enable:completionHandler:))]
168 #[unsafe(method_family = none)]
169 pub unsafe fn enable_completionHandler(
170 &self,
171 enable: bool,
172 completion: &block2::DynBlock<dyn Fn(*mut NSError)>,
173 );
174 );
175}
176
177/// Methods declared on superclass `NSObject`.
178impl HMTrigger {
179 extern_methods!(
180 #[unsafe(method(new))]
181 #[unsafe(method_family = new)]
182 pub unsafe fn new() -> Retained<Self>;
183 );
184}