objc2_home_kit/generated/HMAccessory.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 /// Represent an accessory in the home.
12 ///
13 ///
14 /// This class represents an accessory in the home. There is a one to
15 /// one relationship between a physical accessory and an object of this
16 /// class. An accessory is composed of one or more services.
17 ///
18 /// See also [Apple's documentation](https://developer.apple.com/documentation/homekit/hmaccessory?language=objc)
19 #[unsafe(super(NSObject))]
20 #[derive(Debug, PartialEq, Eq, Hash)]
21 pub struct HMAccessory;
22);
23
24unsafe impl Send for HMAccessory {}
25
26unsafe impl Sync for HMAccessory {}
27
28unsafe impl NSObjectProtocol for HMAccessory {}
29
30impl HMAccessory {
31 extern_methods!(
32 /// The name of the accessory.
33 ///
34 ///
35 /// Returns the accessory's name that is associated with HomeKit. The initial value is the name
36 /// provided by the accessory information service of the accessory.
37 #[unsafe(method(name))]
38 #[unsafe(method_family = none)]
39 pub unsafe fn name(&self) -> Retained<NSString>;
40
41 /// A unique identifier for the accessory.
42 ///
43 ///
44 /// Use uniqueIdentifier to obtain the identifier for this object.
45 #[deprecated = "No longer supported."]
46 #[unsafe(method(identifier))]
47 #[unsafe(method_family = none)]
48 pub unsafe fn identifier(&self) -> Retained<NSUUID>;
49
50 /// A unique identifier for the accessory.
51 #[unsafe(method(uniqueIdentifier))]
52 #[unsafe(method_family = none)]
53 pub unsafe fn uniqueIdentifier(&self) -> Retained<NSUUID>;
54
55 /// Delegate object that receives updates on the state of the accessory.
56 #[unsafe(method(delegate))]
57 #[unsafe(method_family = none)]
58 pub unsafe fn delegate(&self) -> Option<Retained<ProtocolObject<dyn HMAccessoryDelegate>>>;
59
60 /// This is a [weak property][objc2::topics::weak_property].
61 /// Setter for [`delegate`][Self::delegate].
62 #[unsafe(method(setDelegate:))]
63 #[unsafe(method_family = none)]
64 pub unsafe fn setDelegate(
65 &self,
66 delegate: Option<&ProtocolObject<dyn HMAccessoryDelegate>>,
67 );
68
69 /// TRUE if the accessory is currently reachable, FALSE otherwise.
70 #[unsafe(method(isReachable))]
71 #[unsafe(method_family = none)]
72 pub unsafe fn isReachable(&self) -> bool;
73
74 /// This property indicates whether this accessory is behind a bridge. If it is TRUE,
75 /// the accessory cannot be removed from the home directly. Only the bridge that owns
76 /// this accessory can be removed and removing the bridge will remove this accessory
77 /// from the home.
78 #[unsafe(method(isBridged))]
79 #[unsafe(method_family = none)]
80 pub unsafe fn isBridged(&self) -> bool;
81
82 /// If this accessory is a bridge, this property is an array of NSUUID objects that,
83 /// each of which represents the 'uniqueIdentifier' of the accessory vended by the bridge.
84 ///
85 ///
86 /// Use uniqueIdentifiersForBridgedAccessories to obtain the identifiers for the
87 /// bridged accessories.
88 #[deprecated = "No longer supported."]
89 #[unsafe(method(identifiersForBridgedAccessories))]
90 #[unsafe(method_family = none)]
91 pub unsafe fn identifiersForBridgedAccessories(&self) -> Option<Retained<NSArray<NSUUID>>>;
92
93 /// If this accessory is a bridge, this property is an array of NSUUID objects that,
94 /// each of which represents the 'uniqueIdentifier' of the accessory vended by the bridge.
95 ///
96 ///
97 /// An accessory can be standalone, a bridge, or hosted behind a bridge.
98 /// - A standalone accessory would have its 'bridged' property set to FALSE and
99 /// its 'uniqueIdentifiersForBridgedAccessories' property set to nil.
100 /// - An accessory that is a bridge would have its 'bridged' property set to FALSE,
101 /// but have a non-empty 'uniqueIdentifiersForBridgedAccessories' property.
102 /// - An accessory behind a bridge would have its 'bridged' property set to TRUE and
103 /// its 'uniqueIdentifiersForBridgedAccessories' property set to nil.
104 #[unsafe(method(uniqueIdentifiersForBridgedAccessories))]
105 #[unsafe(method_family = none)]
106 pub unsafe fn uniqueIdentifiersForBridgedAccessories(
107 &self,
108 ) -> Option<Retained<NSArray<NSUUID>>>;
109
110 #[cfg(feature = "HMAccessoryCategory")]
111 /// Category information for the accessory.
112 #[unsafe(method(category))]
113 #[unsafe(method_family = none)]
114 pub unsafe fn category(&self) -> Retained<HMAccessoryCategory>;
115
116 #[cfg(feature = "HMRoom")]
117 /// Room containing the accessory.
118 #[unsafe(method(room))]
119 #[unsafe(method_family = none)]
120 pub unsafe fn room(&self) -> Option<Retained<HMRoom>>;
121
122 #[cfg(feature = "HMService")]
123 /// Array of HMService objects that represent all the services provided by the accessory.
124 #[unsafe(method(services))]
125 #[unsafe(method_family = none)]
126 pub unsafe fn services(&self) -> Retained<NSArray<HMService>>;
127
128 #[cfg(feature = "HMAccessoryProfile")]
129 /// Accessory profiles of the receiver.
130 #[unsafe(method(profiles))]
131 #[unsafe(method_family = none)]
132 pub unsafe fn profiles(&self) -> Retained<NSArray<HMAccessoryProfile>>;
133
134 /// TRUE if the accessory is blocked, FALSE otherwise.
135 #[unsafe(method(isBlocked))]
136 #[unsafe(method_family = none)]
137 pub unsafe fn isBlocked(&self) -> bool;
138
139 /// Model of the accessory.
140 #[unsafe(method(model))]
141 #[unsafe(method_family = none)]
142 pub unsafe fn model(&self) -> Option<Retained<NSString>>;
143
144 /// Manufacturer of the accessory.
145 #[unsafe(method(manufacturer))]
146 #[unsafe(method_family = none)]
147 pub unsafe fn manufacturer(&self) -> Option<Retained<NSString>>;
148
149 /// Accessory's firmware version.
150 #[unsafe(method(firmwareVersion))]
151 #[unsafe(method_family = none)]
152 pub unsafe fn firmwareVersion(&self) -> Option<Retained<NSString>>;
153
154 /// Indicates if the accessory supports the identify action.
155 #[unsafe(method(supportsIdentify))]
156 #[unsafe(method_family = none)]
157 pub unsafe fn supportsIdentify(&self) -> bool;
158
159 /// The node identifier used to identify the device on Appleās Matter fabric.
160 #[unsafe(method(matterNodeID))]
161 #[unsafe(method_family = none)]
162 pub unsafe fn matterNodeID(&self) -> Option<Retained<NSNumber>>;
163
164 #[cfg(feature = "block2")]
165 /// This method is used to change the name of the accessory.
166 ///
167 ///
168 /// Parameter `name`: New name for the accessory.
169 ///
170 ///
171 /// The new name is stored in HomeKit and not on the accessory.
172 ///
173 ///
174 /// Parameter `completion`: Block that is invoked once the request is processed.
175 /// The NSError provides more information on the status of the request, error
176 /// will be nil on success.
177 #[unsafe(method(updateName:completionHandler:))]
178 #[unsafe(method_family = none)]
179 pub unsafe fn updateName_completionHandler(
180 &self,
181 name: &NSString,
182 completion: &block2::Block<dyn Fn(*mut NSError)>,
183 );
184
185 #[cfg(feature = "block2")]
186 /// This method is used to have an accessory identify itself.
187 ///
188 ///
189 /// Parameter `completion`: Block that is invoked once the request is processed.
190 /// The NSError provides more information on the status of the request, error
191 /// will be nil on success.
192 #[unsafe(method(identifyWithCompletionHandler:))]
193 #[unsafe(method_family = none)]
194 pub unsafe fn identifyWithCompletionHandler(
195 &self,
196 completion: &block2::Block<dyn Fn(*mut NSError)>,
197 );
198
199 #[deprecated = "HMAccessory objects are created by their parent container objects. Directly creating them is not supported."]
200 #[unsafe(method(init))]
201 #[unsafe(method_family = init)]
202 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
203 );
204}
205
206/// Methods declared on superclass `NSObject`.
207impl HMAccessory {
208 extern_methods!(
209 #[unsafe(method(new))]
210 #[unsafe(method_family = new)]
211 pub unsafe fn new() -> Retained<Self>;
212 );
213}
214
215extern_protocol!(
216 /// This defines the protocol for a delegate to receive updates about
217 /// different aspects of an accessory
218 ///
219 /// See also [Apple's documentation](https://developer.apple.com/documentation/homekit/hmaccessorydelegate?language=objc)
220 pub unsafe trait HMAccessoryDelegate: NSObjectProtocol {
221 /// Informs the delegate when the name of the accessory is modified.
222 ///
223 ///
224 /// Parameter `accessory`: Sender of the message.
225 #[optional]
226 #[unsafe(method(accessoryDidUpdateName:))]
227 #[unsafe(method_family = none)]
228 unsafe fn accessoryDidUpdateName(&self, accessory: &HMAccessory);
229
230 #[cfg(feature = "HMService")]
231 /// Informs the delegate when the name of a service is modified.
232 ///
233 ///
234 /// Parameter `accessory`: Sender of the message.
235 ///
236 ///
237 /// Parameter `service`: Service whose name was modified.
238 #[optional]
239 #[unsafe(method(accessory:didUpdateNameForService:))]
240 #[unsafe(method_family = none)]
241 unsafe fn accessory_didUpdateNameForService(
242 &self,
243 accessory: &HMAccessory,
244 service: &HMService,
245 );
246
247 #[cfg(feature = "HMService")]
248 /// Informs the delegate when the associated service type of a service is modified.
249 ///
250 ///
251 /// Parameter `accessory`: Sender of the message.
252 ///
253 ///
254 /// Parameter `service`: Service whose associated service type was modified.
255 #[optional]
256 #[unsafe(method(accessory:didUpdateAssociatedServiceTypeForService:))]
257 #[unsafe(method_family = none)]
258 unsafe fn accessory_didUpdateAssociatedServiceTypeForService(
259 &self,
260 accessory: &HMAccessory,
261 service: &HMService,
262 );
263
264 /// Informs the delegate when the services on the accessory have been dynamically updated.
265 /// The services discovered are accessible via the 'services' property of the accessory.
266 ///
267 ///
268 /// Parameter `accessory`: Sender of the message.
269 #[optional]
270 #[unsafe(method(accessoryDidUpdateServices:))]
271 #[unsafe(method_family = none)]
272 unsafe fn accessoryDidUpdateServices(&self, accessory: &HMAccessory);
273
274 #[cfg(feature = "HMAccessoryProfile")]
275 /// Informs the delegate when a profile is added to an accessory.
276 ///
277 ///
278 /// Parameter `accessory`: Sender of the message.
279 ///
280 /// Parameter `profile`: The added profile.
281 #[optional]
282 #[unsafe(method(accessory:didAddProfile:))]
283 #[unsafe(method_family = none)]
284 unsafe fn accessory_didAddProfile(
285 &self,
286 accessory: &HMAccessory,
287 profile: &HMAccessoryProfile,
288 );
289
290 #[cfg(feature = "HMAccessoryProfile")]
291 /// Informs the delegate when a profile is removed from an accessory.
292 ///
293 ///
294 /// Parameter `accessory`: Sender of the message.
295 ///
296 /// Parameter `profile`: The removed profile.
297 #[optional]
298 #[unsafe(method(accessory:didRemoveProfile:))]
299 #[unsafe(method_family = none)]
300 unsafe fn accessory_didRemoveProfile(
301 &self,
302 accessory: &HMAccessory,
303 profile: &HMAccessoryProfile,
304 );
305
306 /// Informs the delegate when the reachability of the accessory changes.
307 ///
308 ///
309 /// Parameter `accessory`: Sender of the message.
310 #[optional]
311 #[unsafe(method(accessoryDidUpdateReachability:))]
312 #[unsafe(method_family = none)]
313 unsafe fn accessoryDidUpdateReachability(&self, accessory: &HMAccessory);
314
315 #[cfg(all(feature = "HMCharacteristic", feature = "HMService"))]
316 /// Informs the delegate of a change in value of a characteristic.
317 ///
318 ///
319 /// Parameter `accessory`: Sender of this message
320 ///
321 ///
322 /// Parameter `service`: HMService that contains the characteristic whose value was modified.
323 ///
324 ///
325 /// Parameter `characteristic`: The characteristic whose value was changed.
326 #[optional]
327 #[unsafe(method(accessory:service:didUpdateValueForCharacteristic:))]
328 #[unsafe(method_family = none)]
329 unsafe fn accessory_service_didUpdateValueForCharacteristic(
330 &self,
331 accessory: &HMAccessory,
332 service: &HMService,
333 characteristic: &HMCharacteristic,
334 );
335
336 /// Informs the delegate when firmwareVersion has been changed for an accessory.
337 ///
338 ///
339 /// Parameter `accessory`: Sender of the message.
340 ///
341 ///
342 /// Parameter `firmwareVersion`: The newly updated firmwareVersion.
343 #[optional]
344 #[unsafe(method(accessory:didUpdateFirmwareVersion:))]
345 #[unsafe(method_family = none)]
346 unsafe fn accessory_didUpdateFirmwareVersion(
347 &self,
348 accessory: &HMAccessory,
349 firmware_version: &NSString,
350 );
351 }
352);