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!(
    /// 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>;
    );
}