objc2-health-kit 0.3.2

Bindings to the HealthKit 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::*;

/// [Apple's documentation](https://developer.apple.com/documentation/healthkit/hkobserverquerycompletionhandler?language=objc)
#[cfg(feature = "block2")]
pub type HKObserverQueryCompletionHandler = *mut block2::DynBlock<dyn Fn()>;

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/healthkit/hkobserverquery?language=objc)
    #[unsafe(super(HKQuery, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "HKQuery")]
    pub struct HKObserverQuery;
);

#[cfg(feature = "HKQuery")]
unsafe impl Send for HKObserverQuery {}

#[cfg(feature = "HKQuery")]
unsafe impl Sync for HKObserverQuery {}

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

#[cfg(feature = "HKQuery")]
impl HKObserverQuery {
    extern_methods!(
        #[cfg(all(feature = "HKObjectType", feature = "block2"))]
        /// This method installs a handler that is called when a sample type has a new sample added.
        ///
        /// If you have subscribed to background updates you must call the passed completion block
        /// once you have processed data from this notification. Otherwise the system will continue
        /// to notify you of this data.
        ///
        /// # Safety
        ///
        /// `update_handler` block must be sendable.
        #[unsafe(method(initWithSampleType:predicate:updateHandler:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithSampleType_predicate_updateHandler(
            this: Allocated<Self>,
            sample_type: &HKSampleType,
            predicate: Option<&NSPredicate>,
            update_handler: &block2::DynBlock<
                dyn Fn(NonNull<HKObserverQuery>, HKObserverQueryCompletionHandler, *mut NSError),
            >,
        ) -> Retained<Self>;

        #[cfg(all(
            feature = "HKObjectType",
            feature = "HKQueryDescriptor",
            feature = "block2"
        ))]
        /// This method installs a handler that is called when a sample matching the query descriptors is added.
        ///
        /// If you have subscribed to background updates you must call the passed completion block
        /// once you have processed data from this notification. Otherwise the system will continue
        /// to notify you of this data.
        ///
        ///
        /// Parameter `queryDescriptors`: An array of query descriptors that describes the sample types and predicates for
        /// which you are interested in getting notified.
        ///
        /// # Safety
        ///
        /// `update_handler` block must be sendable.
        #[unsafe(method(initWithQueryDescriptors:updateHandler:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithQueryDescriptors_updateHandler(
            this: Allocated<Self>,
            query_descriptors: &NSArray<HKQueryDescriptor>,
            update_handler: &block2::DynBlock<
                dyn Fn(
                    NonNull<HKObserverQuery>,
                    *mut NSSet<HKSampleType>,
                    HKObserverQueryCompletionHandler,
                    *mut NSError,
                ),
            >,
        ) -> Retained<Self>;
    );
}

/// Methods declared on superclass `HKQuery`.
#[cfg(feature = "HKQuery")]
impl HKObserverQuery {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
    );
}

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