objc2_home_kit/generated/
HMTrigger.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    /// Represents a trigger event.
12    ///
13    ///
14    /// This class describes a trigger which is an event that can
15    /// be used to execute one or more action sets when the event fires.
16    ///
17    /// See also [Apple's documentation](https://developer.apple.com/documentation/homekit/hmtrigger?language=objc)
18    #[unsafe(super(NSObject))]
19    #[derive(Debug, PartialEq, Eq, Hash)]
20    pub struct HMTrigger;
21);
22
23unsafe impl Send for HMTrigger {}
24
25unsafe impl Sync for HMTrigger {}
26
27extern_conformance!(
28    unsafe impl NSObjectProtocol for HMTrigger {}
29);
30
31impl HMTrigger {
32    extern_methods!(
33        #[unsafe(method(init))]
34        #[unsafe(method_family = init)]
35        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
36
37        /// Name of the trigger.
38        #[unsafe(method(name))]
39        #[unsafe(method_family = none)]
40        pub unsafe fn name(&self) -> Retained<NSString>;
41
42        /// State of the trigger.
43        ///
44        ///
45        /// TRUE if the trigger is enable, FALSE otherwise.
46        #[unsafe(method(isEnabled))]
47        #[unsafe(method_family = none)]
48        pub unsafe fn isEnabled(&self) -> bool;
49
50        #[cfg(feature = "HMActionSet")]
51        /// Array of HMActionSet objects that represent all the action sets associated
52        /// with this trigger.
53        #[unsafe(method(actionSets))]
54        #[unsafe(method_family = none)]
55        pub unsafe fn actionSets(&self) -> Retained<NSArray<HMActionSet>>;
56
57        /// The date that this trigger was most recently fired.
58        #[deprecated = "No longer supported"]
59        #[unsafe(method(lastFireDate))]
60        #[unsafe(method_family = none)]
61        pub unsafe fn lastFireDate(&self) -> Option<Retained<NSDate>>;
62
63        /// A unique identifier for the trigger.
64        #[unsafe(method(uniqueIdentifier))]
65        #[unsafe(method_family = none)]
66        pub unsafe fn uniqueIdentifier(&self) -> Retained<NSUUID>;
67
68        #[cfg(feature = "block2")]
69        /// This method is used to change the name of the trigger.
70        ///
71        ///
72        /// Parameter `name`: New name for the trigger.
73        ///
74        ///
75        /// Parameter `completion`: Block that is invoked once the request is processed.
76        /// The NSError provides more information on the status of the request.
77        #[unsafe(method(updateName:completionHandler:))]
78        #[unsafe(method_family = none)]
79        pub unsafe fn updateName_completionHandler(
80            &self,
81            name: &NSString,
82            completion: &block2::DynBlock<dyn Fn(*mut NSError)>,
83        );
84
85        #[cfg(all(feature = "HMActionSet", feature = "block2"))]
86        /// Registers an action set to be executed when the trigger is fired.
87        ///
88        ///
89        /// Parameter `actionSet`: HMActionSet to execute when the trigger fires. The order of execution of the
90        /// action set is not guaranteed.
91        ///
92        ///
93        /// Parameter `completion`: Block that is invoked once the request is processed.
94        /// The NSError provides more information on the status of the request.
95        #[unsafe(method(addActionSet:completionHandler:))]
96        #[unsafe(method_family = none)]
97        pub unsafe fn addActionSet_completionHandler(
98            &self,
99            action_set: &HMActionSet,
100            completion: &block2::DynBlock<dyn Fn(*mut NSError)>,
101        );
102
103        #[cfg(all(feature = "HMActionSet", feature = "block2"))]
104        /// De-registers an action set from the trigger.
105        ///
106        ///
107        /// Parameter `actionSet`: The HMActionSet to disassociate from the trigger.
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.
112        #[unsafe(method(removeActionSet:completionHandler:))]
113        #[unsafe(method_family = none)]
114        pub unsafe fn removeActionSet_completionHandler(
115            &self,
116            action_set: &HMActionSet,
117            completion: &block2::DynBlock<dyn Fn(*mut NSError)>,
118        );
119
120        #[cfg(feature = "block2")]
121        /// Enables or disables the trigger.
122        ///
123        /// In order for the trigger to be enabled the following criteria must be met:
124        /// 1. The trigger must be added to a home.
125        /// 2. The trigger must have at least one action set associated with it.
126        /// 3. Each action set added to the trigger must have at least one action.
127        /// 4. For HMTimerTrigger: The next fire date of the timer trigger must be less
128        /// than 5 weeks in the future. The fire date of a one-shot timer trigger
129        /// must be in the future.
130        ///
131        ///
132        /// Parameter `enable`: Setting this to TRUE will enable the trigger, FALSE will disable it.
133        ///
134        ///
135        /// Parameter `completion`: Block that is invoked once the request is processed.
136        /// The NSError provides more information on the status of the request.
137        #[unsafe(method(enable:completionHandler:))]
138        #[unsafe(method_family = none)]
139        pub unsafe fn enable_completionHandler(
140            &self,
141            enable: bool,
142            completion: &block2::DynBlock<dyn Fn(*mut NSError)>,
143        );
144    );
145}
146
147/// Methods declared on superclass `NSObject`.
148impl HMTrigger {
149    extern_methods!(
150        #[unsafe(method(new))]
151        #[unsafe(method_family = new)]
152        pub unsafe fn new() -> Retained<Self>;
153    );
154}