objc2_home_kit/generated/HMCharacteristic.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 a characteristic on a service of an accessory.
12 ///
13 /// See also [Apple's documentation](https://developer.apple.com/documentation/homekit/hmcharacteristic?language=objc)
14 #[unsafe(super(NSObject))]
15 #[derive(Debug, PartialEq, Eq, Hash)]
16 pub struct HMCharacteristic;
17);
18
19unsafe impl Send for HMCharacteristic {}
20
21unsafe impl Sync for HMCharacteristic {}
22
23extern_conformance!(
24 unsafe impl NSObjectProtocol for HMCharacteristic {}
25);
26
27impl HMCharacteristic {
28 extern_methods!(
29 /// The type of the characteristic, e.g. HMCharacteristicTypePowerState.
30 ///
31 /// This property is not atomic.
32 ///
33 /// # Safety
34 ///
35 /// This might not be thread-safe.
36 #[unsafe(method(characteristicType))]
37 #[unsafe(method_family = none)]
38 pub unsafe fn characteristicType(&self) -> Retained<NSString>;
39
40 /// The localized description of the characteristic.
41 ///
42 /// This property is not atomic.
43 ///
44 /// # Safety
45 ///
46 /// This might not be thread-safe.
47 #[unsafe(method(localizedDescription))]
48 #[unsafe(method_family = none)]
49 pub unsafe fn localizedDescription(&self) -> Retained<NSString>;
50
51 #[cfg(feature = "HMService")]
52 /// Service that contains this characteristic.
53 ///
54 /// This property is not atomic.
55 ///
56 /// # Safety
57 ///
58 /// This might not be thread-safe.
59 #[unsafe(method(service))]
60 #[unsafe(method_family = none)]
61 pub unsafe fn service(&self) -> Option<Retained<HMService>>;
62
63 /// Array that describes the properties of the characteristic.
64 ///
65 ///
66 /// This value corresponds to the properties associated with this characteristic.
67 /// The contents of the array are one or more HMCharacteristicProperty constants.
68 ///
69 /// This property is not atomic.
70 ///
71 /// # Safety
72 ///
73 /// This might not be thread-safe.
74 #[unsafe(method(properties))]
75 #[unsafe(method_family = none)]
76 pub unsafe fn properties(&self) -> Retained<NSArray<NSString>>;
77
78 #[cfg(feature = "HMCharacteristicMetadata")]
79 /// Meta data associated with the characteristic.
80 ///
81 /// This property is not atomic.
82 ///
83 /// # Safety
84 ///
85 /// This might not be thread-safe.
86 #[unsafe(method(metadata))]
87 #[unsafe(method_family = none)]
88 pub unsafe fn metadata(&self) -> Option<Retained<HMCharacteristicMetadata>>;
89
90 /// The value of the characteristic.
91 ///
92 ///
93 /// The value is a cached value that may have been updated as a result of prior
94 /// interaction with the accessory.
95 ///
96 /// This property is not atomic.
97 ///
98 /// # Safety
99 ///
100 /// This might not be thread-safe.
101 #[unsafe(method(value))]
102 #[unsafe(method_family = none)]
103 pub unsafe fn value(&self) -> Option<Retained<AnyObject>>;
104
105 /// Specifies whether the characteristic has been enabled to send notifications.
106 ///
107 ///
108 /// This property is reset to NO if the reachability of the accessory is NO.
109 ///
110 /// This property is not atomic.
111 ///
112 /// # Safety
113 ///
114 /// This might not be thread-safe.
115 #[unsafe(method(isNotificationEnabled))]
116 #[unsafe(method_family = none)]
117 pub unsafe fn isNotificationEnabled(&self) -> bool;
118
119 /// A unique identifier for the characteristic.
120 ///
121 /// This property is not atomic.
122 ///
123 /// # Safety
124 ///
125 /// This might not be thread-safe.
126 #[unsafe(method(uniqueIdentifier))]
127 #[unsafe(method_family = none)]
128 pub unsafe fn uniqueIdentifier(&self) -> Retained<NSUUID>;
129
130 #[cfg(feature = "block2")]
131 /// Modifies the value of the characteristic.
132 ///
133 ///
134 /// Parameter `value`: The value to be written.
135 ///
136 ///
137 /// Parameter `completion`: Block that is invoked once the request is processed.
138 /// The NSError provides more information on the status of the request, error
139 /// will be nil on success.
140 ///
141 ///
142 /// The value being written is validated against the metadata, format and permissions.
143 /// The value written may be bounded by metadata for characteristics with int and
144 /// float format. If validation fails, the error provided to the completion handler
145 /// indicates the type of failure.
146 ///
147 /// # Safety
148 ///
149 /// `value` should be of the correct type.
150 #[unsafe(method(writeValue:completionHandler:))]
151 #[unsafe(method_family = none)]
152 pub unsafe fn writeValue_completionHandler(
153 &self,
154 value: Option<&AnyObject>,
155 completion: &block2::DynBlock<dyn Fn(*mut NSError)>,
156 );
157
158 #[cfg(feature = "block2")]
159 /// Reads the value of the characteristic. The updated value can be read from the 'value' property of the characteristic.
160 ///
161 ///
162 /// Parameter `completion`: Block that is invoked once the request is processed.
163 /// The NSError provides more information on the status of the request, error
164 /// will be nil on success.
165 #[unsafe(method(readValueWithCompletionHandler:))]
166 #[unsafe(method_family = none)]
167 pub unsafe fn readValueWithCompletionHandler(
168 &self,
169 completion: &block2::DynBlock<dyn Fn(*mut NSError)>,
170 );
171
172 #[cfg(feature = "block2")]
173 /// Enables/disables notifications or indications for the value of a specified characteristic.
174 ///
175 ///
176 /// Parameter `enable`: A Boolean value indicating whether you wish to receive notifications or
177 /// indications whenever the characteristic’s value changes.
178 ///
179 ///
180 /// Parameter `completion`: Block that is invoked once the request is processed.
181 /// The NSError provides more information on the status of the request, error
182 /// will be nil on success.
183 #[unsafe(method(enableNotification:completionHandler:))]
184 #[unsafe(method_family = none)]
185 pub unsafe fn enableNotification_completionHandler(
186 &self,
187 enable: bool,
188 completion: &block2::DynBlock<dyn Fn(*mut NSError)>,
189 );
190
191 #[cfg(feature = "block2")]
192 /// Sets/clears authorization data used when writing to the characteristic.
193 ///
194 ///
195 /// Parameter `data`: New authorization data to use. Specify nil to remove authorization data.
196 ///
197 ///
198 /// Parameter `completion`: Block that is invoked once the request is processed.
199 /// The NSError provides more information on the status of the request, error
200 /// will be nil on success.
201 #[unsafe(method(updateAuthorizationData:completionHandler:))]
202 #[unsafe(method_family = none)]
203 pub unsafe fn updateAuthorizationData_completionHandler(
204 &self,
205 data: Option<&NSData>,
206 completion: &block2::DynBlock<dyn Fn(*mut NSError)>,
207 );
208
209 #[deprecated = "HMCharacteristic objects are created by their parent container objects. Directly creating them is not supported."]
210 #[unsafe(method(init))]
211 #[unsafe(method_family = init)]
212 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
213 );
214}
215
216/// Methods declared on superclass `NSObject`.
217impl HMCharacteristic {
218 extern_methods!(
219 #[unsafe(method(new))]
220 #[unsafe(method_family = new)]
221 pub unsafe fn new() -> Retained<Self>;
222 );
223}