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