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        #[unsafe(method(fireDate))]
97        #[unsafe(method_family = none)]
98        pub unsafe fn fireDate(&self) -> Retained<NSDate>;
99
100        #[deprecated = "Use HMEventTrigger with HMCalendarEvent for triggers based on a time-zone-relative time of day"]
101        #[unsafe(method(timeZone))]
102        #[unsafe(method_family = none)]
103        pub unsafe fn timeZone(&self) -> Option<Retained<NSTimeZone>>;
104
105        /// The date components that specify how a trigger is to be repeated.
106        ///
107        ///
108        /// This value must be nil if the trigger should not repeat. The date component
109        /// values are relative to the initial fire date of the trigger. If the
110        /// calendar value of the recurrence is nil, the current calendar
111        /// will be used to calculate the recurrence interval. Recurrence example: if a
112        /// trigger should repeat every hour, set the 'hour' property of the
113        /// recurrence to 1. The minimum recurrence interval is 5 minutes, maximum recurrence
114        /// interval is 5 weeks and the recurrence interval must be specified in multiples of
115        /// whole minutes. Examples are 5 minutes, 6 minutes, 1 day, 2 weeks.
116        #[unsafe(method(recurrence))]
117        #[unsafe(method_family = none)]
118        pub unsafe fn recurrence(&self) -> Option<Retained<NSDateComponents>>;
119
120        #[deprecated = "No longer supported"]
121        #[unsafe(method(recurrenceCalendar))]
122        #[unsafe(method_family = none)]
123        pub unsafe fn recurrenceCalendar(&self) -> Option<Retained<NSCalendar>>;
124
125        #[cfg(feature = "block2")]
126        /// This method is used to change the fire date of a timer trigger.
127        ///
128        ///
129        /// Parameter `fireDate`: New fire date for the trigger. The seconds value must be zero.
130        ///
131        ///
132        /// Parameter `completion`: Block that is invoked once the request is processed.
133        /// The NSError provides more information on the status of the request,
134        /// error will be nil on success. HMErrorCodeDateMustBeOnSpecifiedBoundaries will
135        /// be returned if the fireDate includes a seconds value other than 0.
136        #[unsafe(method(updateFireDate:completionHandler:))]
137        #[unsafe(method_family = none)]
138        pub unsafe fn updateFireDate_completionHandler(
139            &self,
140            fire_date: &NSDate,
141            completion: &block2::DynBlock<dyn Fn(*mut NSError)>,
142        );
143
144        #[cfg(feature = "block2")]
145        #[deprecated = "Use HMEventTrigger with HMCalendarEvent for triggers based on a time-zone-relative time of day"]
146        #[unsafe(method(updateTimeZone:completionHandler:))]
147        #[unsafe(method_family = none)]
148        pub unsafe fn updateTimeZone_completionHandler(
149            &self,
150            time_zone: Option<&NSTimeZone>,
151            completion: &block2::DynBlock<dyn Fn(*mut NSError)>,
152        );
153
154        #[cfg(feature = "block2")]
155        /// This method is used to change the recurrence interval for a timer trigger.
156        ///
157        ///
158        /// Parameter `recurrence`: New recurrence interval for the trigger. Passing a nil indicates that
159        /// the trigger is non-repeating. The minimum recurrence interval is 5 minutes,
160        /// maximum recurrence interval is 5 weeks and the recurrence interval must be specified
161        /// in multiples of whole minutes.
162        ///
163        ///
164        /// Parameter `completion`: Block that is invoked once the request is processed.
165        /// The NSError provides more information on the status of the request:
166        /// HMErrorCodeDateMustBeOnSpecifiedBoundaries is returned if the seconds/nanoseconds
167        /// fields have a value other than 0;
168        /// HMErrorCodeRecurrenceTooSmall is returned if the recurrence interval is less than
169        /// 5 minutes;
170        /// HMErrorCodeRecurrenceTooLarge is returned if the recurrence interval is
171        /// greater than 5 weeks. *                   error will be nil on success.
172        #[unsafe(method(updateRecurrence:completionHandler:))]
173        #[unsafe(method_family = none)]
174        pub unsafe fn updateRecurrence_completionHandler(
175            &self,
176            recurrence: Option<&NSDateComponents>,
177            completion: &block2::DynBlock<dyn Fn(*mut NSError)>,
178        );
179    );
180}
181
182/// Methods declared on superclass `NSObject`.
183#[cfg(feature = "HMTrigger")]
184impl HMTimerTrigger {
185    extern_methods!(
186        #[unsafe(method(new))]
187        #[unsafe(method_family = new)]
188        pub unsafe fn new() -> Retained<Self>;
189    );
190}