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