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