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