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