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