objc2_home_kit/generated/
HMTimerTrigger.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    /// Timer based trigger.
12    ///
13    ///
14    /// This class represents a trigger that is based on timers.
15    ///
16    /// See also [Apple's documentation](https://developer.apple.com/documentation/homekit/hmtimertrigger?language=objc)
17    #[unsafe(super(HMTrigger, NSObject))]
18    #[derive(Debug, PartialEq, Eq, Hash)]
19    #[cfg(feature = "HMTrigger")]
20    pub struct HMTimerTrigger;
21);
22
23#[cfg(feature = "HMTrigger")]
24unsafe impl Send for HMTimerTrigger {}
25
26#[cfg(feature = "HMTrigger")]
27unsafe impl Sync for HMTimerTrigger {}
28
29#[cfg(feature = "HMTrigger")]
30extern_conformance!(
31    unsafe impl NSObjectProtocol for HMTimerTrigger {}
32);
33
34#[cfg(feature = "HMTrigger")]
35impl HMTimerTrigger {
36    extern_methods!(
37        #[unsafe(method(init))]
38        #[unsafe(method_family = init)]
39        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
40
41        /// Initialize a new HMTimerTrigger object.
42        ///
43        ///
44        /// Parameter `name`: Name for the trigger.
45        ///
46        ///
47        /// Parameter `fireDate`: The initial fire date for the timer trigger. The seconds value must be zero.
48        /// Date should be at least 1 minute ahead for reliable firing.
49        /// HMErrorCodeDateMustBeOnSpecifiedBoundaries will be returned when adding the trigger
50        /// to a home if the fireDate includes a seconds value other than 0.
51        ///
52        ///
53        /// Parameter `recurrence`: The recurrence interval to fire the trigger. A value of nil indicates that the
54        /// trigger is non-repeating. The minimum reccurence interval is 5 minutes, maximum
55        /// recurrence interval is 5 weeks and the recurrence interval must be specified in
56        /// multiples of whole minutes.
57        ///
58        ///
59        /// Validity checks are performed when the trigger is added to the home and the NSError in
60        /// the completion block for addTrigger: method indicates the reason for the failure:
61        /// HMErrorCodeDateMustBeOnSpecifiedBoundaries is returned if the seconds/nanoseconds fields
62        /// in recurrence interval or seconds field in fireDate have a value other than 0.
63        /// HMErrorCodeRecurrenceTooSmall is returned if recurrence interval is less than 5 minutes.
64        /// HMErrorCodeRecurrenceTooLarge is returned if recurrence interval is greater than 5 weeks.
65        /// HMErrorCodeFireDateInPast is returned if recurrence is nil and fireDate is in the past.
66        #[unsafe(method(initWithName:fireDate:recurrence:))]
67        #[unsafe(method_family = init)]
68        pub unsafe fn initWithName_fireDate_recurrence(
69            this: Allocated<Self>,
70            name: &NSString,
71            fire_date: &NSDate,
72            recurrence: Option<&NSDateComponents>,
73        ) -> Retained<Self>;
74
75        #[deprecated]
76        #[unsafe(method(initWithName:fireDate:timeZone:recurrence:recurrenceCalendar:))]
77        #[unsafe(method_family = init)]
78        pub unsafe fn initWithName_fireDate_timeZone_recurrence_recurrenceCalendar(
79            this: Allocated<Self>,
80            name: &NSString,
81            fire_date: &NSDate,
82            time_zone: Option<&NSTimeZone>,
83            recurrence: Option<&NSDateComponents>,
84            recurrence_calendar: Option<&NSCalendar>,
85        ) -> Retained<Self>;
86
87        /// Specifies when, in an absolute time, the trigger should fire the first time.
88        ///
89        ///
90        /// Timer triggers are only set at the top of the minute. When the timer trigger fires,
91        /// it will typically fire within 1 minute of the scheduled fire date or calculated
92        /// recurrence fire date, depending on how the system is managing its resources.
93        ///
94        ///
95        /// Note: Should be at least 1 minute ahead for reliable firing.
96        ///
97        /// This property is not atomic.
98        ///
99        /// # Safety
100        ///
101        /// This might not be thread-safe.
102        #[unsafe(method(fireDate))]
103        #[unsafe(method_family = none)]
104        pub unsafe fn fireDate(&self) -> Retained<NSDate>;
105
106        /// This property is not atomic.
107        ///
108        /// # Safety
109        ///
110        /// This might not be thread-safe.
111        #[deprecated = "Use HMEventTrigger with HMCalendarEvent for triggers based on a time-zone-relative time of day"]
112        #[unsafe(method(timeZone))]
113        #[unsafe(method_family = none)]
114        pub unsafe fn timeZone(&self) -> Option<Retained<NSTimeZone>>;
115
116        /// The date components that specify how a trigger is to be repeated.
117        ///
118        ///
119        /// This value must be nil if the trigger should not repeat. The date component
120        /// values are relative to the initial fire date of the trigger. If the
121        /// calendar value of the recurrence is nil, the current calendar
122        /// will be used to calculate the recurrence interval. Recurrence example: if a
123        /// trigger should repeat every hour, set the 'hour' property of the
124        /// recurrence to 1. The minimum recurrence interval is 5 minutes, maximum recurrence
125        /// interval is 5 weeks and the recurrence interval must be specified in multiples of
126        /// whole minutes. Examples are 5 minutes, 6 minutes, 1 day, 2 weeks.
127        ///
128        /// This property is not atomic.
129        ///
130        /// # Safety
131        ///
132        /// This might not be thread-safe.
133        #[unsafe(method(recurrence))]
134        #[unsafe(method_family = none)]
135        pub unsafe fn recurrence(&self) -> Option<Retained<NSDateComponents>>;
136
137        /// This property is not atomic.
138        ///
139        /// # Safety
140        ///
141        /// This might not be thread-safe.
142        #[deprecated = "No longer supported"]
143        #[unsafe(method(recurrenceCalendar))]
144        #[unsafe(method_family = none)]
145        pub unsafe fn recurrenceCalendar(&self) -> Option<Retained<NSCalendar>>;
146
147        #[cfg(feature = "block2")]
148        /// This method is used to change the fire date of a timer trigger.
149        ///
150        ///
151        /// Parameter `fireDate`: New fire date for the trigger. The seconds value must be zero.
152        ///
153        ///
154        /// Parameter `completion`: Block that is invoked once the request is processed.
155        /// The NSError provides more information on the status of the request,
156        /// error will be nil on success. HMErrorCodeDateMustBeOnSpecifiedBoundaries will
157        /// be returned if the fireDate includes a seconds value other than 0.
158        #[unsafe(method(updateFireDate:completionHandler:))]
159        #[unsafe(method_family = none)]
160        pub unsafe fn updateFireDate_completionHandler(
161            &self,
162            fire_date: &NSDate,
163            completion: &block2::DynBlock<dyn Fn(*mut NSError)>,
164        );
165
166        #[cfg(feature = "block2")]
167        #[deprecated = "Use HMEventTrigger with HMCalendarEvent for triggers based on a time-zone-relative time of day"]
168        #[unsafe(method(updateTimeZone:completionHandler:))]
169        #[unsafe(method_family = none)]
170        pub unsafe fn updateTimeZone_completionHandler(
171            &self,
172            time_zone: Option<&NSTimeZone>,
173            completion: &block2::DynBlock<dyn Fn(*mut NSError)>,
174        );
175
176        #[cfg(feature = "block2")]
177        /// This method is used to change the recurrence interval for a timer trigger.
178        ///
179        ///
180        /// Parameter `recurrence`: New recurrence interval for the trigger. Passing a nil indicates that
181        /// the trigger is non-repeating. The minimum recurrence interval is 5 minutes,
182        /// maximum recurrence interval is 5 weeks and the recurrence interval must be specified
183        /// in multiples of whole minutes.
184        ///
185        ///
186        /// Parameter `completion`: Block that is invoked once the request is processed.
187        /// The NSError provides more information on the status of the request:
188        /// HMErrorCodeDateMustBeOnSpecifiedBoundaries is returned if the seconds/nanoseconds
189        /// fields have a value other than 0;
190        /// HMErrorCodeRecurrenceTooSmall is returned if the recurrence interval is less than
191        /// 5 minutes;
192        /// HMErrorCodeRecurrenceTooLarge is returned if the recurrence interval is
193        /// greater than 5 weeks. *                   error will be nil on success.
194        #[unsafe(method(updateRecurrence:completionHandler:))]
195        #[unsafe(method_family = none)]
196        pub unsafe fn updateRecurrence_completionHandler(
197            &self,
198            recurrence: Option<&NSDateComponents>,
199            completion: &block2::DynBlock<dyn Fn(*mut NSError)>,
200        );
201    );
202}
203
204/// Methods declared on superclass `NSObject`.
205#[cfg(feature = "HMTrigger")]
206impl HMTimerTrigger {
207    extern_methods!(
208        #[unsafe(method(new))]
209        #[unsafe(method_family = new)]
210        pub unsafe fn new() -> Retained<Self>;
211    );
212}