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
23unsafe impl NSObjectProtocol for HMCharacteristic {}
24
25impl HMCharacteristic {
26 extern_methods!(
27 /// The type of the characteristic, e.g. HMCharacteristicTypePowerState.
28 #[unsafe(method(characteristicType))]
29 #[unsafe(method_family = none)]
30 pub unsafe fn characteristicType(&self) -> Retained<NSString>;
31
32 /// The localized description of the characteristic.
33 #[unsafe(method(localizedDescription))]
34 #[unsafe(method_family = none)]
35 pub unsafe fn localizedDescription(&self) -> Retained<NSString>;
36
37 #[cfg(feature = "HMService")]
38 /// Service that contains this characteristic.
39 #[unsafe(method(service))]
40 #[unsafe(method_family = none)]
41 pub unsafe fn service(&self) -> Option<Retained<HMService>>;
42
43 /// Array that describes the properties of the characteristic.
44 ///
45 ///
46 /// This value corresponds to the properties associated with this characteristic.
47 /// The contents of the array are one or more HMCharacteristicProperty constants.
48 #[unsafe(method(properties))]
49 #[unsafe(method_family = none)]
50 pub unsafe fn properties(&self) -> Retained<NSArray<NSString>>;
51
52 #[cfg(feature = "HMCharacteristicMetadata")]
53 /// Meta data associated with the characteristic.
54 #[unsafe(method(metadata))]
55 #[unsafe(method_family = none)]
56 pub unsafe fn metadata(&self) -> Option<Retained<HMCharacteristicMetadata>>;
57
58 /// The value of the characteristic.
59 ///
60 ///
61 /// The value is a cached value that may have been updated as a result of prior
62 /// interaction with the accessory.
63 #[unsafe(method(value))]
64 #[unsafe(method_family = none)]
65 pub unsafe fn value(&self) -> Option<Retained<AnyObject>>;
66
67 /// Specifies whether the characteristic has been enabled to send notifications.
68 ///
69 ///
70 /// This property is reset to NO if the reachability of the accessory is NO.
71 #[unsafe(method(isNotificationEnabled))]
72 #[unsafe(method_family = none)]
73 pub unsafe fn isNotificationEnabled(&self) -> bool;
74
75 /// A unique identifier for the characteristic.
76 #[unsafe(method(uniqueIdentifier))]
77 #[unsafe(method_family = none)]
78 pub unsafe fn uniqueIdentifier(&self) -> Retained<NSUUID>;
79
80 #[cfg(feature = "block2")]
81 /// Modifies the value of the characteristic.
82 ///
83 ///
84 /// Parameter `value`: The value to be written.
85 ///
86 ///
87 /// Parameter `completion`: Block that is invoked once the request is processed.
88 /// The NSError provides more information on the status of the request, error
89 /// will be nil on success.
90 ///
91 ///
92 /// The value being written is validated against the metadata, format and permissions.
93 /// The value written may be bounded by metadata for characteristics with int and
94 /// float format. If validation fails, the error provided to the completion handler
95 /// indicates the type of failure.
96 #[unsafe(method(writeValue:completionHandler:))]
97 #[unsafe(method_family = none)]
98 pub unsafe fn writeValue_completionHandler(
99 &self,
100 value: Option<&AnyObject>,
101 completion: &block2::Block<dyn Fn(*mut NSError)>,
102 );
103
104 #[cfg(feature = "block2")]
105 /// Reads the value of the characteristic. The updated value can be read from the 'value' property of the characteristic.
106 ///
107 ///
108 /// Parameter `completion`: Block that is invoked once the request is processed.
109 /// The NSError provides more information on the status of the request, error
110 /// will be nil on success.
111 #[unsafe(method(readValueWithCompletionHandler:))]
112 #[unsafe(method_family = none)]
113 pub unsafe fn readValueWithCompletionHandler(
114 &self,
115 completion: &block2::Block<dyn Fn(*mut NSError)>,
116 );
117
118 #[cfg(feature = "block2")]
119 /// Enables/disables notifications or indications for the value of a specified characteristic.
120 ///
121 ///
122 /// Parameter `enable`: A Boolean value indicating whether you wish to receive notifications or
123 /// indications whenever the characteristic’s value changes.
124 ///
125 ///
126 /// Parameter `completion`: Block that is invoked once the request is processed.
127 /// The NSError provides more information on the status of the request, error
128 /// will be nil on success.
129 #[unsafe(method(enableNotification:completionHandler:))]
130 #[unsafe(method_family = none)]
131 pub unsafe fn enableNotification_completionHandler(
132 &self,
133 enable: bool,
134 completion: &block2::Block<dyn Fn(*mut NSError)>,
135 );
136
137 #[cfg(feature = "block2")]
138 /// Sets/clears authorization data used when writing to the characteristic.
139 ///
140 ///
141 /// Parameter `data`: New authorization data to use. Specify nil to remove authorization data.
142 ///
143 ///
144 /// Parameter `completion`: Block that is invoked once the request is processed.
145 /// The NSError provides more information on the status of the request, error
146 /// will be nil on success.
147 #[unsafe(method(updateAuthorizationData:completionHandler:))]
148 #[unsafe(method_family = none)]
149 pub unsafe fn updateAuthorizationData_completionHandler(
150 &self,
151 data: Option<&NSData>,
152 completion: &block2::Block<dyn Fn(*mut NSError)>,
153 );
154
155 #[deprecated = "HMCharacteristic objects are created by their parent container objects. Directly creating them is not supported."]
156 #[unsafe(method(init))]
157 #[unsafe(method_family = init)]
158 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
159 );
160}
161
162/// Methods declared on superclass `NSObject`.
163impl HMCharacteristic {
164 extern_methods!(
165 #[unsafe(method(new))]
166 #[unsafe(method_family = new)]
167 pub unsafe fn new() -> Retained<Self>;
168 );
169}