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!(
    /// Represent a characteristic on a service of an accessory.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/homekit/hmcharacteristic?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct HMCharacteristic;
);

unsafe impl Send for HMCharacteristic {}

unsafe impl Sync for HMCharacteristic {}

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

impl HMCharacteristic {
    extern_methods!(
        /// The type of the characteristic, e.g. HMCharacteristicTypePowerState.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(characteristicType))]
        #[unsafe(method_family = none)]
        pub unsafe fn characteristicType(&self) -> Retained<NSString>;

        /// The localized description of the characteristic.
        ///
        /// 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>;

        #[cfg(feature = "HMService")]
        /// Service that contains this characteristic.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(service))]
        #[unsafe(method_family = none)]
        pub unsafe fn service(&self) -> Option<Retained<HMService>>;

        /// Array that describes the properties of the characteristic.
        ///
        ///
        /// This value corresponds to the properties associated with this characteristic.
        /// The contents of the array are one or more HMCharacteristicProperty constants.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(properties))]
        #[unsafe(method_family = none)]
        pub unsafe fn properties(&self) -> Retained<NSArray<NSString>>;

        #[cfg(feature = "HMCharacteristicMetadata")]
        /// Meta data associated with the characteristic.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(metadata))]
        #[unsafe(method_family = none)]
        pub unsafe fn metadata(&self) -> Option<Retained<HMCharacteristicMetadata>>;

        /// The value of the characteristic.
        ///
        ///
        /// The value is a cached value that may have been updated as a result of prior
        /// interaction with the accessory.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(value))]
        #[unsafe(method_family = none)]
        pub unsafe fn value(&self) -> Option<Retained<AnyObject>>;

        /// Specifies whether the characteristic has been enabled to send notifications.
        ///
        ///
        /// This property is reset to NO if the reachability of the accessory is NO.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(isNotificationEnabled))]
        #[unsafe(method_family = none)]
        pub unsafe fn isNotificationEnabled(&self) -> bool;

        /// A unique identifier for the characteristic.
        ///
        /// 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")]
        /// Modifies the value of the characteristic.
        ///
        ///
        /// Parameter `value`: The value to be written.
        ///
        ///
        /// 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.
        ///
        ///
        /// The value being written is validated against the metadata, format and permissions.
        /// The value written may be bounded by metadata for characteristics with int and
        /// float format. If validation fails, the error provided to the completion handler
        /// indicates the type of failure.
        ///
        /// # Safety
        ///
        /// `value` should be of the correct type.
        #[unsafe(method(writeValue:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn writeValue_completionHandler(
            &self,
            value: Option<&AnyObject>,
            completion: &block2::DynBlock<dyn Fn(*mut NSError)>,
        );

        #[cfg(feature = "block2")]
        /// Reads the value of the characteristic. The updated value can be read from the 'value' property of the characteristic.
        ///
        ///
        /// 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(readValueWithCompletionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn readValueWithCompletionHandler(
            &self,
            completion: &block2::DynBlock<dyn Fn(*mut NSError)>,
        );

        #[cfg(feature = "block2")]
        /// Enables/disables notifications or indications for the value of a specified characteristic.
        ///
        ///
        /// Parameter `enable`: A Boolean value indicating whether you wish to receive notifications or
        /// indications whenever the characteristic’s value changes.
        ///
        ///
        /// 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(enableNotification:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn enableNotification_completionHandler(
            &self,
            enable: bool,
            completion: &block2::DynBlock<dyn Fn(*mut NSError)>,
        );

        #[cfg(feature = "block2")]
        /// Sets/clears authorization data used when writing to the characteristic.
        ///
        ///
        /// Parameter `data`: New authorization data to use. Specify nil to remove authorization data.
        ///
        ///
        /// 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(updateAuthorizationData:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn updateAuthorizationData_completionHandler(
            &self,
            data: Option<&NSData>,
            completion: &block2::DynBlock<dyn Fn(*mut NSError)>,
        );

        #[deprecated = "HMCharacteristic 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 HMCharacteristic {
    extern_methods!(
        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}