objc2_home_kit/generated/
HMCharacteristicEvent.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    /// This class represents an event that is evaluated based on the value of a characteristic
12    /// set to a particular value.
13    ///
14    /// See also [Apple's documentation](https://developer.apple.com/documentation/homekit/hmcharacteristicevent?language=objc)
15    #[unsafe(super(HMEvent, NSObject))]
16    #[derive(Debug, PartialEq, Eq, Hash)]
17    #[cfg(feature = "HMEvent")]
18    pub struct HMCharacteristicEvent<TriggerValueType: ?Sized = AnyObject>;
19);
20
21#[cfg(feature = "HMEvent")]
22impl<TriggerValueType: ?Sized + Message + NSCopying> HMCharacteristicEvent<TriggerValueType> {
23    /// Unchecked conversion of the generic parameter.
24    ///
25    /// # Safety
26    ///
27    /// The generic must be valid to reinterpret as the given type.
28    #[inline]
29    pub unsafe fn cast_unchecked<NewTriggerValueType: ?Sized + Message + NSCopying>(
30        &self,
31    ) -> &HMCharacteristicEvent<NewTriggerValueType> {
32        unsafe { &*((self as *const Self).cast()) }
33    }
34}
35
36#[cfg(feature = "HMEvent")]
37extern_conformance!(
38    unsafe impl<TriggerValueType: ?Sized + NSCopying> NSCopying
39        for HMCharacteristicEvent<TriggerValueType>
40    {
41    }
42);
43
44#[cfg(feature = "HMEvent")]
45unsafe impl<TriggerValueType: ?Sized + Message + NSCopying> CopyingHelper
46    for HMCharacteristicEvent<TriggerValueType>
47{
48    type Result = Self;
49}
50
51#[cfg(feature = "HMEvent")]
52extern_conformance!(
53    unsafe impl<TriggerValueType: ?Sized + NSCopying> NSMutableCopying
54        for HMCharacteristicEvent<TriggerValueType>
55    {
56    }
57);
58
59#[cfg(feature = "HMEvent")]
60unsafe impl<TriggerValueType: ?Sized + Message + NSCopying> MutableCopyingHelper
61    for HMCharacteristicEvent<TriggerValueType>
62{
63    type Result = HMMutableCharacteristicEvent<TriggerValueType>;
64}
65
66#[cfg(feature = "HMEvent")]
67extern_conformance!(
68    unsafe impl<TriggerValueType: ?Sized + NSCopying> NSObjectProtocol
69        for HMCharacteristicEvent<TriggerValueType>
70    {
71    }
72);
73
74#[cfg(feature = "HMEvent")]
75impl<TriggerValueType: Message + NSCopying> HMCharacteristicEvent<TriggerValueType> {
76    extern_methods!(
77        #[unsafe(method(init))]
78        #[unsafe(method_family = init)]
79        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
80
81        #[cfg(feature = "HMCharacteristic")]
82        /// Initializes a new characteristic event object
83        ///
84        ///
85        /// Parameter `characteristic`: The characteristic bound to the event. The characteristic must
86        /// support notification. An exception will be thrown otherwise.
87        ///
88        ///
89        /// Parameter `triggerValue`: The value of the characteristic that triggers the event.
90        /// Specifying nil as the trigger value corresponds to any change in the value of the
91        /// characteristic.
92        ///
93        ///
94        /// Returns: Instance object representing the characteristic event.
95        #[unsafe(method(initWithCharacteristic:triggerValue:))]
96        #[unsafe(method_family = init)]
97        pub unsafe fn initWithCharacteristic_triggerValue(
98            this: Allocated<Self>,
99            characteristic: &HMCharacteristic,
100            trigger_value: Option<&TriggerValueType>,
101        ) -> Retained<Self>;
102
103        #[cfg(feature = "HMCharacteristic")]
104        /// The characteristic associated with the event.
105        ///
106        /// This property is not atomic.
107        ///
108        /// # Safety
109        ///
110        /// This might not be thread-safe.
111        #[unsafe(method(characteristic))]
112        #[unsafe(method_family = none)]
113        pub unsafe fn characteristic(&self) -> Retained<HMCharacteristic>;
114
115        /// The value of the characteristic that triggers the event.
116        /// A value of nil corresponds to any change in the value of the characteristic.
117        ///
118        /// This property is not atomic.
119        ///
120        /// # Safety
121        ///
122        /// This might not be thread-safe.
123        #[unsafe(method(triggerValue))]
124        #[unsafe(method_family = none)]
125        pub unsafe fn triggerValue(&self) -> Option<Retained<TriggerValueType>>;
126
127        #[cfg(feature = "block2")]
128        /// This method is used to change trigger value for the characteristic.
129        ///
130        ///
131        /// Parameter `triggerValue`: New trigger value for the characteristic.
132        /// Specifying nil as the trigger value corresponds to any change in the value of the
133        /// characteristic.
134        ///
135        ///
136        /// Parameter `completion`: Block that is invoked once the request is processed.
137        /// The NSError provides more information on the status of the request, error
138        /// will be nil on success.
139        #[deprecated = "No longer supported."]
140        #[unsafe(method(updateTriggerValue:completionHandler:))]
141        #[unsafe(method_family = none)]
142        pub unsafe fn updateTriggerValue_completionHandler(
143            &self,
144            trigger_value: Option<&TriggerValueType>,
145            completion: &block2::DynBlock<dyn Fn(*mut NSError)>,
146        );
147    );
148}
149
150/// Methods declared on superclass `HMEvent`.
151#[cfg(feature = "HMEvent")]
152impl<TriggerValueType: Message + NSCopying> HMCharacteristicEvent<TriggerValueType> {
153    extern_methods!(
154        #[deprecated = "HMEvent is abstract"]
155        #[unsafe(method(new))]
156        #[unsafe(method_family = new)]
157        pub unsafe fn new() -> Retained<Self>;
158    );
159}
160
161extern_class!(
162    /// This class represents an event that is evaluated based on the value of a characteristic
163    /// set to a particular value.
164    ///
165    /// See also [Apple's documentation](https://developer.apple.com/documentation/homekit/hmmutablecharacteristicevent?language=objc)
166    #[unsafe(super(HMCharacteristicEvent, HMEvent, NSObject))]
167    #[derive(Debug, PartialEq, Eq, Hash)]
168    #[cfg(feature = "HMEvent")]
169    pub struct HMMutableCharacteristicEvent<TriggerValueType: ?Sized = AnyObject>;
170);
171
172#[cfg(feature = "HMEvent")]
173impl<TriggerValueType: ?Sized + Message + NSCopying>
174    HMMutableCharacteristicEvent<TriggerValueType>
175{
176    /// Unchecked conversion of the generic parameter.
177    ///
178    /// # Safety
179    ///
180    /// The generic must be valid to reinterpret as the given type.
181    #[inline]
182    pub unsafe fn cast_unchecked<NewTriggerValueType: ?Sized + Message + NSCopying>(
183        &self,
184    ) -> &HMMutableCharacteristicEvent<NewTriggerValueType> {
185        unsafe { &*((self as *const Self).cast()) }
186    }
187}
188
189#[cfg(feature = "HMEvent")]
190extern_conformance!(
191    unsafe impl<TriggerValueType: ?Sized + NSCopying> NSCopying
192        for HMMutableCharacteristicEvent<TriggerValueType>
193    {
194    }
195);
196
197#[cfg(feature = "HMEvent")]
198unsafe impl<TriggerValueType: ?Sized + Message + NSCopying> CopyingHelper
199    for HMMutableCharacteristicEvent<TriggerValueType>
200{
201    type Result = HMCharacteristicEvent<TriggerValueType>;
202}
203
204#[cfg(feature = "HMEvent")]
205extern_conformance!(
206    unsafe impl<TriggerValueType: ?Sized + NSCopying> NSMutableCopying
207        for HMMutableCharacteristicEvent<TriggerValueType>
208    {
209    }
210);
211
212#[cfg(feature = "HMEvent")]
213unsafe impl<TriggerValueType: ?Sized + Message + NSCopying> MutableCopyingHelper
214    for HMMutableCharacteristicEvent<TriggerValueType>
215{
216    type Result = Self;
217}
218
219#[cfg(feature = "HMEvent")]
220extern_conformance!(
221    unsafe impl<TriggerValueType: ?Sized + NSCopying> NSObjectProtocol
222        for HMMutableCharacteristicEvent<TriggerValueType>
223    {
224    }
225);
226
227#[cfg(feature = "HMEvent")]
228impl<TriggerValueType: Message + NSCopying> HMMutableCharacteristicEvent<TriggerValueType> {
229    extern_methods!(
230        #[unsafe(method(init))]
231        #[unsafe(method_family = init)]
232        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
233
234        #[cfg(feature = "HMCharacteristic")]
235        /// The characteristic associated with the event.
236        ///
237        /// This property is not atomic.
238        ///
239        /// # Safety
240        ///
241        /// This might not be thread-safe.
242        #[unsafe(method(characteristic))]
243        #[unsafe(method_family = none)]
244        pub unsafe fn characteristic(&self) -> Retained<HMCharacteristic>;
245
246        #[cfg(feature = "HMCharacteristic")]
247        /// Setter for [`characteristic`][Self::characteristic].
248        ///
249        /// # Safety
250        ///
251        /// This might not be thread-safe.
252        #[unsafe(method(setCharacteristic:))]
253        #[unsafe(method_family = none)]
254        pub unsafe fn setCharacteristic(&self, characteristic: &HMCharacteristic);
255
256        /// The value of the characteristic that triggers the event.
257        /// A value of nil corresponds to any change in the value of the characteristic.
258        ///
259        /// This property is not atomic.
260        ///
261        /// # Safety
262        ///
263        /// This might not be thread-safe.
264        #[unsafe(method(triggerValue))]
265        #[unsafe(method_family = none)]
266        pub unsafe fn triggerValue(&self) -> Option<Retained<TriggerValueType>>;
267
268        /// Setter for [`triggerValue`][Self::triggerValue].
269        ///
270        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
271        ///
272        /// # Safety
273        ///
274        /// This might not be thread-safe.
275        #[unsafe(method(setTriggerValue:))]
276        #[unsafe(method_family = none)]
277        pub unsafe fn setTriggerValue(&self, trigger_value: Option<&TriggerValueType>);
278    );
279}
280
281/// Methods declared on superclass `HMCharacteristicEvent`.
282#[cfg(feature = "HMEvent")]
283impl<TriggerValueType: Message + NSCopying> HMMutableCharacteristicEvent<TriggerValueType> {
284    extern_methods!(
285        #[cfg(feature = "HMCharacteristic")]
286        /// Initializes a new characteristic event object
287        ///
288        ///
289        /// Parameter `characteristic`: The characteristic bound to the event. The characteristic must
290        /// support notification. An exception will be thrown otherwise.
291        ///
292        ///
293        /// Parameter `triggerValue`: The value of the characteristic that triggers the event.
294        /// Specifying nil as the trigger value corresponds to any change in the value of the
295        /// characteristic.
296        ///
297        ///
298        /// Returns: Instance object representing the characteristic event.
299        #[unsafe(method(initWithCharacteristic:triggerValue:))]
300        #[unsafe(method_family = init)]
301        pub unsafe fn initWithCharacteristic_triggerValue(
302            this: Allocated<Self>,
303            characteristic: &HMCharacteristic,
304            trigger_value: Option<&TriggerValueType>,
305        ) -> Retained<Self>;
306    );
307}
308
309/// Methods declared on superclass `HMEvent`.
310#[cfg(feature = "HMEvent")]
311impl<TriggerValueType: Message + NSCopying> HMMutableCharacteristicEvent<TriggerValueType> {
312    extern_methods!(
313        #[deprecated = "HMEvent is abstract"]
314        #[unsafe(method(new))]
315        #[unsafe(method_family = new)]
316        pub unsafe fn new() -> Retained<Self>;
317    );
318}