objc2_home_kit/generated/
HMCharacteristicWriteAction.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 is used to represent an entry in an action set that writes a specific
12    /// value to a characteristic.
13    ///
14    /// See also [Apple's documentation](https://developer.apple.com/documentation/homekit/hmcharacteristicwriteaction?language=objc)
15    #[unsafe(super(HMAction, NSObject))]
16    #[derive(Debug, PartialEq, Eq, Hash)]
17    #[cfg(feature = "HMAction")]
18    pub struct HMCharacteristicWriteAction<TargetValueType: ?Sized = AnyObject>;
19);
20
21#[cfg(feature = "HMAction")]
22impl<TargetValueType: ?Sized + Message + NSCopying> HMCharacteristicWriteAction<TargetValueType> {
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<NewTargetValueType: ?Sized + Message + NSCopying>(
30        &self,
31    ) -> &HMCharacteristicWriteAction<NewTargetValueType> {
32        unsafe { &*((self as *const Self).cast()) }
33    }
34}
35
36#[cfg(feature = "HMAction")]
37extern_conformance!(
38    unsafe impl<TargetValueType: ?Sized + NSCopying> NSObjectProtocol
39        for HMCharacteristicWriteAction<TargetValueType>
40    {
41    }
42);
43
44#[cfg(feature = "HMAction")]
45impl<TargetValueType: Message + NSCopying> HMCharacteristicWriteAction<TargetValueType> {
46    extern_methods!(
47        #[unsafe(method(init))]
48        #[unsafe(method_family = init)]
49        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
50
51        #[unsafe(method(new))]
52        #[unsafe(method_family = new)]
53        pub unsafe fn new() -> Retained<Self>;
54
55        #[cfg(feature = "HMCharacteristic")]
56        /// Initializer method that ties the action to a particular characteristic.
57        ///
58        ///
59        /// Parameter `characteristic`: The characteristic bound to the action.
60        ///
61        ///
62        /// Parameter `targetValue`: The target value for the characteristic.
63        ///
64        ///
65        /// Returns: Instance object representing the characteristic write action.
66        #[unsafe(method(initWithCharacteristic:targetValue:))]
67        #[unsafe(method_family = init)]
68        pub unsafe fn initWithCharacteristic_targetValue(
69            this: Allocated<Self>,
70            characteristic: &HMCharacteristic,
71            target_value: &TargetValueType,
72        ) -> Retained<Self>;
73
74        #[cfg(feature = "HMCharacteristic")]
75        /// The characteristic associated with the action.
76        ///
77        /// This property is not atomic.
78        ///
79        /// # Safety
80        ///
81        /// This might not be thread-safe.
82        #[unsafe(method(characteristic))]
83        #[unsafe(method_family = none)]
84        pub unsafe fn characteristic(&self) -> Retained<HMCharacteristic>;
85
86        /// The target value for the action.
87        ///
88        /// This property is not atomic.
89        ///
90        /// # Safety
91        ///
92        /// This might not be thread-safe.
93        #[unsafe(method(targetValue))]
94        #[unsafe(method_family = none)]
95        pub unsafe fn targetValue(&self) -> Retained<TargetValueType>;
96
97        #[cfg(feature = "block2")]
98        /// This method is used to change target value for the characteristic.
99        ///
100        ///
101        /// Parameter `targetValue`: New target value for the characteristic.
102        ///
103        ///
104        /// Parameter `completion`: Block that is invoked once the request is processed.
105        /// The NSError provides more information on the status of the request, error
106        /// will be nil on success.
107        #[unsafe(method(updateTargetValue:completionHandler:))]
108        #[unsafe(method_family = none)]
109        pub unsafe fn updateTargetValue_completionHandler(
110            &self,
111            target_value: &TargetValueType,
112            completion: &block2::DynBlock<dyn Fn(*mut NSError)>,
113        );
114    );
115}