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
//! 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!(
/// Represent a characteristic on a service of an accessory.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/homekit/hmcharacteristic?language=objc)
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct HMCharacteristic;
);
unsafe impl Send for HMCharacteristic {}
unsafe impl Sync for HMCharacteristic {}
extern_conformance!(
unsafe impl NSObjectProtocol for HMCharacteristic {}
);
impl HMCharacteristic {
extern_methods!(
/// The type of the characteristic, e.g. HMCharacteristicTypePowerState.
///
/// This property is not atomic.
///
/// # Safety
///
/// This might not be thread-safe.
#[unsafe(method(characteristicType))]
#[unsafe(method_family = none)]
pub unsafe fn characteristicType(&self) -> Retained<NSString>;
/// The localized description of the characteristic.
///
/// 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>;
#[cfg(feature = "HMService")]
/// Service that contains this characteristic.
///
/// This property is not atomic.
///
/// # Safety
///
/// This might not be thread-safe.
#[unsafe(method(service))]
#[unsafe(method_family = none)]
pub unsafe fn service(&self) -> Option<Retained<HMService>>;
/// Array that describes the properties of the characteristic.
///
///
/// This value corresponds to the properties associated with this characteristic.
/// The contents of the array are one or more HMCharacteristicProperty constants.
///
/// This property is not atomic.
///
/// # Safety
///
/// This might not be thread-safe.
#[unsafe(method(properties))]
#[unsafe(method_family = none)]
pub unsafe fn properties(&self) -> Retained<NSArray<NSString>>;
#[cfg(feature = "HMCharacteristicMetadata")]
/// Meta data associated with the characteristic.
///
/// This property is not atomic.
///
/// # Safety
///
/// This might not be thread-safe.
#[unsafe(method(metadata))]
#[unsafe(method_family = none)]
pub unsafe fn metadata(&self) -> Option<Retained<HMCharacteristicMetadata>>;
/// The value of the characteristic.
///
///
/// The value is a cached value that may have been updated as a result of prior
/// interaction with the accessory.
///
/// This property is not atomic.
///
/// # Safety
///
/// This might not be thread-safe.
#[unsafe(method(value))]
#[unsafe(method_family = none)]
pub unsafe fn value(&self) -> Option<Retained<AnyObject>>;
/// Specifies whether the characteristic has been enabled to send notifications.
///
///
/// This property is reset to NO if the reachability of the accessory is NO.
///
/// This property is not atomic.
///
/// # Safety
///
/// This might not be thread-safe.
#[unsafe(method(isNotificationEnabled))]
#[unsafe(method_family = none)]
pub unsafe fn isNotificationEnabled(&self) -> bool;
/// A unique identifier for the characteristic.
///
/// 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>;
#[cfg(feature = "block2")]
/// Modifies the value of the characteristic.
///
///
/// Parameter `value`: The value to be written.
///
///
/// 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.
///
///
/// The value being written is validated against the metadata, format and permissions.
/// The value written may be bounded by metadata for characteristics with int and
/// float format. If validation fails, the error provided to the completion handler
/// indicates the type of failure.
///
/// # Safety
///
/// `value` should be of the correct type.
#[unsafe(method(writeValue:completionHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn writeValue_completionHandler(
&self,
value: Option<&AnyObject>,
completion: &block2::DynBlock<dyn Fn(*mut NSError)>,
);
#[cfg(feature = "block2")]
/// Reads the value of the characteristic. The updated value can be read from the 'value' property of the characteristic.
///
///
/// 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(readValueWithCompletionHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn readValueWithCompletionHandler(
&self,
completion: &block2::DynBlock<dyn Fn(*mut NSError)>,
);
#[cfg(feature = "block2")]
/// Enables/disables notifications or indications for the value of a specified characteristic.
///
///
/// Parameter `enable`: A Boolean value indicating whether you wish to receive notifications or
/// indications whenever the characteristic’s value changes.
///
///
/// 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(enableNotification:completionHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn enableNotification_completionHandler(
&self,
enable: bool,
completion: &block2::DynBlock<dyn Fn(*mut NSError)>,
);
#[cfg(feature = "block2")]
/// Sets/clears authorization data used when writing to the characteristic.
///
///
/// Parameter `data`: New authorization data to use. Specify nil to remove authorization data.
///
///
/// 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(updateAuthorizationData:completionHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn updateAuthorizationData_completionHandler(
&self,
data: Option<&NSData>,
completion: &block2::DynBlock<dyn Fn(*mut NSError)>,
);
#[deprecated = "HMCharacteristic 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 HMCharacteristic {
extern_methods!(
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub unsafe fn new() -> Retained<Self>;
);
}