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