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!(
    /// This class is used to represent an entry in an action set that writes a specific
    /// value to a characteristic.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/homekit/hmcharacteristicwriteaction?language=objc)
    #[unsafe(super(HMAction, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "HMAction")]
    pub struct HMCharacteristicWriteAction<TargetValueType: ?Sized = AnyObject>;
);

#[cfg(feature = "HMAction")]
impl<TargetValueType: ?Sized + Message + NSCopying> HMCharacteristicWriteAction<TargetValueType> {
    /// Unchecked conversion of the generic parameter.
    ///
    /// # Safety
    ///
    /// The generic must be valid to reinterpret as the given type.
    #[inline]
    pub unsafe fn cast_unchecked<NewTargetValueType: ?Sized + Message + NSCopying>(
        &self,
    ) -> &HMCharacteristicWriteAction<NewTargetValueType> {
        unsafe { &*((self as *const Self).cast()) }
    }
}

#[cfg(feature = "HMAction")]
extern_conformance!(
    unsafe impl<TargetValueType: ?Sized + NSCopying> NSObjectProtocol
        for HMCharacteristicWriteAction<TargetValueType>
    {
    }
);

#[cfg(feature = "HMAction")]
impl<TargetValueType: Message + NSCopying> HMCharacteristicWriteAction<TargetValueType> {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;

        #[cfg(feature = "HMCharacteristic")]
        /// Initializer method that ties the action to a particular characteristic.
        ///
        ///
        /// Parameter `characteristic`: The characteristic bound to the action.
        ///
        ///
        /// Parameter `targetValue`: The target value for the characteristic.
        ///
        ///
        /// Returns: Instance object representing the characteristic write action.
        #[unsafe(method(initWithCharacteristic:targetValue:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithCharacteristic_targetValue(
            this: Allocated<Self>,
            characteristic: &HMCharacteristic,
            target_value: &TargetValueType,
        ) -> Retained<Self>;

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

        /// The target value for the action.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(targetValue))]
        #[unsafe(method_family = none)]
        pub unsafe fn targetValue(&self) -> Retained<TargetValueType>;

        #[cfg(feature = "block2")]
        /// This method is used to change target value for the characteristic.
        ///
        ///
        /// Parameter `targetValue`: New target value for 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(updateTargetValue:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn updateTargetValue_completionHandler(
            &self,
            target_value: &TargetValueType,
            completion: &block2::DynBlock<dyn Fn(*mut NSError)>,
        );
    );
}