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 service provided by an accessory.
    ///
    ///
    /// This class represents a service provided by an accessory in the home.
    /// A service is composed of one or more characteristics that can be
    /// modified.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/homekit/hmservice?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct HMService;
);

unsafe impl Send for HMService {}

unsafe impl Sync for HMService {}

extern_conformance!(
    unsafe impl NSObjectProtocol for HMService {}
);

impl HMService {
    extern_methods!(
        #[cfg(feature = "HMAccessory")]
        /// Accessory that provides this service.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(accessory))]
        #[unsafe(method_family = none)]
        pub unsafe fn accessory(&self) -> Option<Retained<HMAccessory>>;

        /// The type of the service, e.g. HMServiceTypeLightbulb.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(serviceType))]
        #[unsafe(method_family = none)]
        pub unsafe fn serviceType(&self) -> Retained<NSString>;

        /// The localized description of the service.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(localizedDescription))]
        #[unsafe(method_family = none)]
        pub unsafe fn localizedDescription(&self) -> Retained<NSString>;

        /// Name for the service.
        ///
        ///
        /// Returns the service's name that is associated with HomeKit. The initial value is the value of
        /// the name characteristic of the service, if it has one.
        ///
        /// 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>;

        /// For HMServiceTypeOutlet and HMServiceTypeSwitch, this is the type of the associated service.
        ///
        ///
        /// This could be any of the HomeKit Accessory Profile defined services (except HMServiceTypeOutlet
        /// or HMServiceTypeSwitch) that supports HMCharacteristicTypePowerState characteristic.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(associatedServiceType))]
        #[unsafe(method_family = none)]
        pub unsafe fn associatedServiceType(&self) -> Option<Retained<NSString>>;

        #[cfg(feature = "HMCharacteristic")]
        /// Array of HMCharacteristic objects that represents all the characteristics
        /// provided by the service.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(characteristics))]
        #[unsafe(method_family = none)]
        pub unsafe fn characteristics(&self) -> Retained<NSArray<HMCharacteristic>>;

        /// A unique identifier for the service.
        ///
        /// 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>;

        /// Indicates if this service supports user interaction or not.
        ///
        ///
        /// Applications should use this property to filter out services that the users
        /// should not directly interact with, e.g. HMServiceTypeAccessoryInformation.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(isUserInteractive))]
        #[unsafe(method_family = none)]
        pub unsafe fn isUserInteractive(&self) -> bool;

        /// Indicates if this services is the primary service.
        ///
        ///
        /// Applications should use this property to show the primary service on the accessory.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(isPrimaryService))]
        #[unsafe(method_family = none)]
        pub unsafe fn isPrimaryService(&self) -> bool;

        /// Array of HMService objects that represents all the services that the service links to.
        ///
        ///
        /// Applications should use this property to show logical grouping of services on the accessory.
        /// linkedServices will be nil when the service does not link to any other services.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(linkedServices))]
        #[unsafe(method_family = none)]
        pub unsafe fn linkedServices(&self) -> Option<Retained<NSArray<HMService>>>;

        /// The Matter endpoint identifier that this service is mapped to.
        ///
        ///
        /// This property is nil for HAP accessories, and set to a valid value for Matter devices.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(matterEndpointID))]
        #[unsafe(method_family = none)]
        pub unsafe fn matterEndpointID(&self) -> Option<Retained<NSNumber>>;

        #[cfg(feature = "block2")]
        /// This method is used to change the name of the service.
        ///
        ///
        /// Parameter `name`: New name for the service.
        ///
        ///
        /// The new name is stored in HomeKit and not on the accessory.
        ///
        ///
        /// 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.
        #[unsafe(method(updateName:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn updateName_completionHandler(
            &self,
            name: &NSString,
            completion: &block2::DynBlock<dyn Fn(*mut NSError)>,
        );

        #[cfg(feature = "block2")]
        /// This method is used to set up the service type of the device connected to a contact sensor, switch or an outlet.
        ///
        ///
        /// Parameter `serviceType`: Service type of the device connected to a contact sensor/switch/outlet service.
        ///
        ///
        /// This method is only valid for the services of the following types:
        /// HMServiceTypeOutlet, HMServiceTypeContactSensor and HMServiceTypeSwitch
        ///
        /// For services of type HMServiceTypeOutlet and HMServiceTypeSwitch, serviceType can be one of the
        /// HomeKit Accessory Profile defined services (except HMServiceTypeOutlet or HMServiceTypeSwitch)
        /// that supports HMCharacteristicTypePowerState characteristic.
        ///
        /// For services of type HMServiceTypeContactSensor, serviceType can be one of the following services:
        /// HMServiceTypeDoor, HMServiceTypeGarageDoorOpener, HMServiceTypeWindow and HMServiceTypeWindowCovering
        ///
        ///
        /// 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.
        #[unsafe(method(updateAssociatedServiceType:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn updateAssociatedServiceType_completionHandler(
            &self,
            service_type: Option<&NSString>,
            completion: &block2::DynBlock<dyn Fn(*mut NSError)>,
        );

        #[deprecated = "HMService objects are created by their parent container objects. Directly creating them is not supported."]
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
    );
}

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