objc2_home_kit/generated/
HMService.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 service provided by an accessory.
12    ///
13    ///
14    /// This class represents a service provided by an accessory in the home.
15    /// A service is composed of one or more characteristics that can be
16    /// modified.
17    ///
18    /// See also [Apple's documentation](https://developer.apple.com/documentation/homekit/hmservice?language=objc)
19    #[unsafe(super(NSObject))]
20    #[derive(Debug, PartialEq, Eq, Hash)]
21    pub struct HMService;
22);
23
24unsafe impl Send for HMService {}
25
26unsafe impl Sync for HMService {}
27
28extern_conformance!(
29    unsafe impl NSObjectProtocol for HMService {}
30);
31
32impl HMService {
33    extern_methods!(
34        #[cfg(feature = "HMAccessory")]
35        /// Accessory that provides this service.
36        ///
37        /// This property is not atomic.
38        ///
39        /// # Safety
40        ///
41        /// This might not be thread-safe.
42        #[unsafe(method(accessory))]
43        #[unsafe(method_family = none)]
44        pub unsafe fn accessory(&self) -> Option<Retained<HMAccessory>>;
45
46        /// The type of the service, e.g. HMServiceTypeLightbulb.
47        ///
48        /// This property is not atomic.
49        ///
50        /// # Safety
51        ///
52        /// This might not be thread-safe.
53        #[unsafe(method(serviceType))]
54        #[unsafe(method_family = none)]
55        pub unsafe fn serviceType(&self) -> Retained<NSString>;
56
57        /// The localized description of the service.
58        ///
59        /// This property is not atomic.
60        ///
61        /// # Safety
62        ///
63        /// This might not be thread-safe.
64        #[unsafe(method(localizedDescription))]
65        #[unsafe(method_family = none)]
66        pub unsafe fn localizedDescription(&self) -> Retained<NSString>;
67
68        /// Name for the service.
69        ///
70        ///
71        /// Returns the service's name that is associated with HomeKit. The initial value is the value of
72        /// the name characteristic of the service, if it has one.
73        ///
74        /// This property is not atomic.
75        ///
76        /// # Safety
77        ///
78        /// This might not be thread-safe.
79        #[unsafe(method(name))]
80        #[unsafe(method_family = none)]
81        pub unsafe fn name(&self) -> Retained<NSString>;
82
83        /// For HMServiceTypeOutlet and HMServiceTypeSwitch, this is the type of the associated service.
84        ///
85        ///
86        /// This could be any of the HomeKit Accessory Profile defined services (except HMServiceTypeOutlet
87        /// or HMServiceTypeSwitch) that supports HMCharacteristicTypePowerState characteristic.
88        ///
89        /// This property is not atomic.
90        ///
91        /// # Safety
92        ///
93        /// This might not be thread-safe.
94        #[unsafe(method(associatedServiceType))]
95        #[unsafe(method_family = none)]
96        pub unsafe fn associatedServiceType(&self) -> Option<Retained<NSString>>;
97
98        #[cfg(feature = "HMCharacteristic")]
99        /// Array of HMCharacteristic objects that represents all the characteristics
100        /// provided by the service.
101        ///
102        /// This property is not atomic.
103        ///
104        /// # Safety
105        ///
106        /// This might not be thread-safe.
107        #[unsafe(method(characteristics))]
108        #[unsafe(method_family = none)]
109        pub unsafe fn characteristics(&self) -> Retained<NSArray<HMCharacteristic>>;
110
111        /// A unique identifier for the service.
112        ///
113        /// This property is not atomic.
114        ///
115        /// # Safety
116        ///
117        /// This might not be thread-safe.
118        #[unsafe(method(uniqueIdentifier))]
119        #[unsafe(method_family = none)]
120        pub unsafe fn uniqueIdentifier(&self) -> Retained<NSUUID>;
121
122        /// Indicates if this service supports user interaction or not.
123        ///
124        ///
125        /// Applications should use this property to filter out services that the users
126        /// should not directly interact with, e.g. HMServiceTypeAccessoryInformation.
127        ///
128        /// This property is not atomic.
129        ///
130        /// # Safety
131        ///
132        /// This might not be thread-safe.
133        #[unsafe(method(isUserInteractive))]
134        #[unsafe(method_family = none)]
135        pub unsafe fn isUserInteractive(&self) -> bool;
136
137        /// Indicates if this services is the primary service.
138        ///
139        ///
140        /// Applications should use this property to show the primary service on the accessory.
141        ///
142        /// This property is not atomic.
143        ///
144        /// # Safety
145        ///
146        /// This might not be thread-safe.
147        #[unsafe(method(isPrimaryService))]
148        #[unsafe(method_family = none)]
149        pub unsafe fn isPrimaryService(&self) -> bool;
150
151        /// Array of HMService objects that represents all the services that the service links to.
152        ///
153        ///
154        /// Applications should use this property to show logical grouping of services on the accessory.
155        /// linkedServices will be nil when the service does not link to any other services.
156        ///
157        /// This property is not atomic.
158        ///
159        /// # Safety
160        ///
161        /// This might not be thread-safe.
162        #[unsafe(method(linkedServices))]
163        #[unsafe(method_family = none)]
164        pub unsafe fn linkedServices(&self) -> Option<Retained<NSArray<HMService>>>;
165
166        /// The Matter endpoint identifier that this service is mapped to.
167        ///
168        ///
169        /// This property is nil for HAP accessories, and set to a valid value for Matter devices.
170        ///
171        /// This property is not atomic.
172        ///
173        /// # Safety
174        ///
175        /// This might not be thread-safe.
176        #[unsafe(method(matterEndpointID))]
177        #[unsafe(method_family = none)]
178        pub unsafe fn matterEndpointID(&self) -> Option<Retained<NSNumber>>;
179
180        #[cfg(feature = "block2")]
181        /// This method is used to change the name of the service.
182        ///
183        ///
184        /// Parameter `name`: New name for the service.
185        ///
186        ///
187        /// The new name is stored in HomeKit and not on the accessory.
188        ///
189        ///
190        /// Parameter `completion`: Block that is invoked once the request is processed.
191        /// The NSError provides more information on the status of the request, error
192        /// will be nil on success.
193        #[unsafe(method(updateName:completionHandler:))]
194        #[unsafe(method_family = none)]
195        pub unsafe fn updateName_completionHandler(
196            &self,
197            name: &NSString,
198            completion: &block2::DynBlock<dyn Fn(*mut NSError)>,
199        );
200
201        #[cfg(feature = "block2")]
202        /// This method is used to set up the service type of the device connected to a contact sensor, switch or an outlet.
203        ///
204        ///
205        /// Parameter `serviceType`: Service type of the device connected to a contact sensor/switch/outlet service.
206        ///
207        ///
208        /// This method is only valid for the services of the following types:
209        /// HMServiceTypeOutlet, HMServiceTypeContactSensor and HMServiceTypeSwitch
210        ///
211        /// For services of type HMServiceTypeOutlet and HMServiceTypeSwitch, serviceType can be one of the
212        /// HomeKit Accessory Profile defined services (except HMServiceTypeOutlet or HMServiceTypeSwitch)
213        /// that supports HMCharacteristicTypePowerState characteristic.
214        ///
215        /// For services of type HMServiceTypeContactSensor, serviceType can be one of the following services:
216        /// HMServiceTypeDoor, HMServiceTypeGarageDoorOpener, HMServiceTypeWindow and HMServiceTypeWindowCovering
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(updateAssociatedServiceType:completionHandler:))]
223        #[unsafe(method_family = none)]
224        pub unsafe fn updateAssociatedServiceType_completionHandler(
225            &self,
226            service_type: Option<&NSString>,
227            completion: &block2::DynBlock<dyn Fn(*mut NSError)>,
228        );
229
230        #[deprecated = "HMService objects are created by their parent container objects. Directly creating them is not supported."]
231        #[unsafe(method(init))]
232        #[unsafe(method_family = init)]
233        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
234    );
235}
236
237/// Methods declared on superclass `NSObject`.
238impl HMService {
239    extern_methods!(
240        #[unsafe(method(new))]
241        #[unsafe(method_family = new)]
242        pub unsafe fn new() -> Retained<Self>;
243    );
244}