objc2-home-kit 0.3.2

Bindings to the HomeKit framework
Documentation
//! 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!(
    /// Timer based trigger.
    ///
    ///
    /// This class represents a trigger that is based on timers.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/homekit/hmtimertrigger?language=objc)
    #[unsafe(super(HMTrigger, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "HMTrigger")]
    pub struct HMTimerTrigger;
);

#[cfg(feature = "HMTrigger")]
unsafe impl Send for HMTimerTrigger {}

#[cfg(feature = "HMTrigger")]
unsafe impl Sync for HMTimerTrigger {}

#[cfg(feature = "HMTrigger")]
extern_conformance!(
    unsafe impl NSObjectProtocol for HMTimerTrigger {}
);

#[cfg(feature = "HMTrigger")]
impl HMTimerTrigger {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        /// Initialize a new HMTimerTrigger object.
        ///
        ///
        /// Parameter `name`: Name for the trigger.
        ///
        ///
        /// Parameter `fireDate`: The initial fire date for the timer trigger. The seconds value must be zero.
        /// Date should be at least 1 minute ahead for reliable firing.
        /// HMErrorCodeDateMustBeOnSpecifiedBoundaries will be returned when adding the trigger
        /// to a home if the fireDate includes a seconds value other than 0.
        ///
        ///
        /// Parameter `recurrence`: The recurrence interval to fire the trigger. A value of nil indicates that the
        /// trigger is non-repeating. The minimum reccurence interval is 5 minutes, maximum
        /// recurrence interval is 5 weeks and the recurrence interval must be specified in
        /// multiples of whole minutes.
        ///
        ///
        /// Validity checks are performed when the trigger is added to the home and the NSError in
        /// the completion block for addTrigger: method indicates the reason for the failure:
        /// HMErrorCodeDateMustBeOnSpecifiedBoundaries is returned if the seconds/nanoseconds fields
        /// in recurrence interval or seconds field in fireDate have a value other than 0.
        /// HMErrorCodeRecurrenceTooSmall is returned if recurrence interval is less than 5 minutes.
        /// HMErrorCodeRecurrenceTooLarge is returned if recurrence interval is greater than 5 weeks.
        /// HMErrorCodeFireDateInPast is returned if recurrence is nil and fireDate is in the past.
        #[unsafe(method(initWithName:fireDate:recurrence:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithName_fireDate_recurrence(
            this: Allocated<Self>,
            name: &NSString,
            fire_date: &NSDate,
            recurrence: Option<&NSDateComponents>,
        ) -> Retained<Self>;

        #[deprecated]
        #[unsafe(method(initWithName:fireDate:timeZone:recurrence:recurrenceCalendar:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithName_fireDate_timeZone_recurrence_recurrenceCalendar(
            this: Allocated<Self>,
            name: &NSString,
            fire_date: &NSDate,
            time_zone: Option<&NSTimeZone>,
            recurrence: Option<&NSDateComponents>,
            recurrence_calendar: Option<&NSCalendar>,
        ) -> Retained<Self>;

        /// Specifies when, in an absolute time, the trigger should fire the first time.
        ///
        ///
        /// Timer triggers are only set at the top of the minute. When the timer trigger fires,
        /// it will typically fire within 1 minute of the scheduled fire date or calculated
        /// recurrence fire date, depending on how the system is managing its resources.
        ///
        ///
        /// Note: Should be at least 1 minute ahead for reliable firing.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(fireDate))]
        #[unsafe(method_family = none)]
        pub unsafe fn fireDate(&self) -> Retained<NSDate>;

        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[deprecated = "Use HMEventTrigger with HMCalendarEvent for triggers based on a time-zone-relative time of day"]
        #[unsafe(method(timeZone))]
        #[unsafe(method_family = none)]
        pub unsafe fn timeZone(&self) -> Option<Retained<NSTimeZone>>;

        /// The date components that specify how a trigger is to be repeated.
        ///
        ///
        /// This value must be nil if the trigger should not repeat. The date component
        /// values are relative to the initial fire date of the trigger. If the
        /// calendar value of the recurrence is nil, the current calendar
        /// will be used to calculate the recurrence interval. Recurrence example: if a
        /// trigger should repeat every hour, set the 'hour' property of the
        /// recurrence to 1. The minimum recurrence interval is 5 minutes, maximum recurrence
        /// interval is 5 weeks and the recurrence interval must be specified in multiples of
        /// whole minutes. Examples are 5 minutes, 6 minutes, 1 day, 2 weeks.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(recurrence))]
        #[unsafe(method_family = none)]
        pub unsafe fn recurrence(&self) -> Option<Retained<NSDateComponents>>;

        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[deprecated = "No longer supported"]
        #[unsafe(method(recurrenceCalendar))]
        #[unsafe(method_family = none)]
        pub unsafe fn recurrenceCalendar(&self) -> Option<Retained<NSCalendar>>;

        #[cfg(feature = "block2")]
        /// This method is used to change the fire date of a timer trigger.
        ///
        ///
        /// Parameter `fireDate`: New fire date for the trigger. The seconds value must be zero.
        ///
        ///
        /// Parameter `completion`: Block that is invoked once the request is processed.
        /// The NSError provides more information on the status of the request,
        /// error will be nil on success. HMErrorCodeDateMustBeOnSpecifiedBoundaries will
        /// be returned if the fireDate includes a seconds value other than 0.
        #[unsafe(method(updateFireDate:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn updateFireDate_completionHandler(
            &self,
            fire_date: &NSDate,
            completion: &block2::DynBlock<dyn Fn(*mut NSError)>,
        );

        #[cfg(feature = "block2")]
        #[deprecated = "Use HMEventTrigger with HMCalendarEvent for triggers based on a time-zone-relative time of day"]
        #[unsafe(method(updateTimeZone:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn updateTimeZone_completionHandler(
            &self,
            time_zone: Option<&NSTimeZone>,
            completion: &block2::DynBlock<dyn Fn(*mut NSError)>,
        );

        #[cfg(feature = "block2")]
        /// This method is used to change the recurrence interval for a timer trigger.
        ///
        ///
        /// Parameter `recurrence`: New recurrence interval for the trigger. Passing a nil indicates that
        /// the trigger is non-repeating. The minimum recurrence interval is 5 minutes,
        /// maximum recurrence interval is 5 weeks and the recurrence interval must be specified
        /// in multiples of whole minutes.
        ///
        ///
        /// Parameter `completion`: Block that is invoked once the request is processed.
        /// The NSError provides more information on the status of the request:
        /// HMErrorCodeDateMustBeOnSpecifiedBoundaries is returned if the seconds/nanoseconds
        /// fields have a value other than 0;
        /// HMErrorCodeRecurrenceTooSmall is returned if the recurrence interval is less than
        /// 5 minutes;
        /// HMErrorCodeRecurrenceTooLarge is returned if the recurrence interval is
        /// greater than 5 weeks. *                   error will be nil on success.
        #[unsafe(method(updateRecurrence:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn updateRecurrence_completionHandler(
            &self,
            recurrence: Option<&NSDateComponents>,
            completion: &block2::DynBlock<dyn Fn(*mut NSError)>,
        );
    );
}

/// Methods declared on superclass `NSObject`.
#[cfg(feature = "HMTrigger")]
impl HMTimerTrigger {
    extern_methods!(
        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}