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::*;

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

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

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

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

#[cfg(feature = "HKQuery")]
impl HKAnchoredObjectQuery {
    extern_methods!(
        #[cfg(all(
            feature = "HKDeletedObject",
            feature = "HKObject",
            feature = "HKQueryAnchor",
            feature = "HKSample",
            feature = "block2"
        ))]
        /// An optional handler to be called when samples matching the given predicate are added or deleted.
        ///
        /// This property may not be modified once the query has been executed.  It may only be set if the query has
        /// no limit.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// - The returned block must be sendable.
        /// - This might not be thread-safe.
        #[unsafe(method(updateHandler))]
        #[unsafe(method_family = none)]
        pub unsafe fn updateHandler(
            &self,
        ) -> *mut block2::DynBlock<
            dyn Fn(
                NonNull<HKAnchoredObjectQuery>,
                *mut NSArray<HKSample>,
                *mut NSArray<HKDeletedObject>,
                *mut HKQueryAnchor,
                *mut NSError,
            ),
        >;

        #[cfg(all(
            feature = "HKDeletedObject",
            feature = "HKObject",
            feature = "HKQueryAnchor",
            feature = "HKSample",
            feature = "block2"
        ))]
        /// Setter for [`updateHandler`][Self::updateHandler].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        ///
        /// # Safety
        ///
        /// - `update_handler` block must be sendable.
        /// - This might not be thread-safe.
        #[unsafe(method(setUpdateHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setUpdateHandler(
            &self,
            update_handler: Option<
                &block2::DynBlock<
                    dyn Fn(
                        NonNull<HKAnchoredObjectQuery>,
                        *mut NSArray<HKSample>,
                        *mut NSArray<HKDeletedObject>,
                        *mut HKQueryAnchor,
                        *mut NSError,
                    ),
                >,
            >,
        );

        #[cfg(all(
            feature = "HKDeletedObject",
            feature = "HKObject",
            feature = "HKObjectType",
            feature = "HKQueryAnchor",
            feature = "HKSample",
            feature = "block2"
        ))]
        /// Returns a query that will retrieve HKSamples and HKDeletedObjects matching the given predicate that are
        /// newer than the given anchor.
        ///
        /// If no updateHandler is set on the query, the query will automatically stop after calling resultsHandler.
        /// Otherwise, the query continues to run and call updateHandler as samples matching the predicate are
        /// created or deleted.
        ///
        ///
        /// Parameter `type`: The type of sample to retrieve.
        ///
        /// Parameter `predicate`: The predicate which samples should match.
        ///
        /// Parameter `anchor`: The anchor which was returned by a previous HKAnchoredObjectQuery result or update
        /// handler.  Pass nil when querying for the first time.
        ///
        /// Parameter `limit`: The maximum number of samples and deleted objects to return.  Pass HKObjectQueryNoLimit
        /// for no limit.
        ///
        /// Parameter `handler`: The block to invoke with results when the query has finished finding.
        ///
        /// # Safety
        ///
        /// `handler` block must be sendable.
        #[unsafe(method(initWithType:predicate:anchor:limit:resultsHandler:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithType_predicate_anchor_limit_resultsHandler(
            this: Allocated<Self>,
            r#type: &HKSampleType,
            predicate: Option<&NSPredicate>,
            anchor: Option<&HKQueryAnchor>,
            limit: NSUInteger,
            handler: &block2::DynBlock<
                dyn Fn(
                    NonNull<HKAnchoredObjectQuery>,
                    *mut NSArray<HKSample>,
                    *mut NSArray<HKDeletedObject>,
                    *mut HKQueryAnchor,
                    *mut NSError,
                ),
            >,
        ) -> Retained<Self>;

        #[cfg(all(
            feature = "HKObject",
            feature = "HKObjectType",
            feature = "HKSample",
            feature = "block2"
        ))]
        /// # Safety
        ///
        /// `handler` block must be sendable.
        #[deprecated]
        #[unsafe(method(initWithType:predicate:anchor:limit:completionHandler:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithType_predicate_anchor_limit_completionHandler(
            this: Allocated<Self>,
            r#type: &HKSampleType,
            predicate: Option<&NSPredicate>,
            anchor: NSUInteger,
            limit: NSUInteger,
            handler: &block2::DynBlock<
                dyn Fn(
                    NonNull<HKAnchoredObjectQuery>,
                    *mut NSArray<HKSample>,
                    NSUInteger,
                    *mut NSError,
                ),
            >,
        ) -> Retained<Self>;

        #[cfg(all(
            feature = "HKDeletedObject",
            feature = "HKObject",
            feature = "HKQueryAnchor",
            feature = "HKQueryDescriptor",
            feature = "HKSample",
            feature = "block2"
        ))]
        /// Returns a query that will retrieve HKSamples and HKDeletedObjects matching the given query descriptors
        /// that are newer than the given anchor.
        ///
        /// If no updateHandler is set on the query, the query will automatically stop after calling resultsHandler.
        /// Otherwise, the query continues to run and call updateHandler as samples matching the query descriptors
        /// are created or deleted.
        ///
        ///
        /// Parameter `queryDescriptors`: An array of query descriptors that describes the sample types and predicates that
        /// you are interested in getting notified for.
        ///
        /// Parameter `anchor`: The anchor which was returned by a previous HKAnchoredObjectQuery result or update
        /// handler.  Pass nil when querying for the first time.
        ///
        /// Parameter `limit`: The maximum number of samples and deleted objects to return. Pass
        /// HKObjectQueryNoLimit for no limit.
        ///
        /// Parameter `handler`: The block to invoke with results when the query has finished finding.
        ///
        /// # Safety
        ///
        /// `handler` block must be sendable.
        #[unsafe(method(initWithQueryDescriptors:anchor:limit:resultsHandler:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithQueryDescriptors_anchor_limit_resultsHandler(
            this: Allocated<Self>,
            query_descriptors: &NSArray<HKQueryDescriptor>,
            anchor: Option<&HKQueryAnchor>,
            limit: NSInteger,
            handler: &block2::DynBlock<
                dyn Fn(
                    NonNull<HKAnchoredObjectQuery>,
                    *mut NSArray<HKSample>,
                    *mut NSArray<HKDeletedObject>,
                    *mut HKQueryAnchor,
                    *mut NSError,
                ),
            >,
        ) -> Retained<Self>;
    );
}

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