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/hkobjectquerynolimit?language=objc)
pub static HKObjectQueryNoLimit: NSUInteger = 0;

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

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

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

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

#[cfg(feature = "HKQuery")]
impl HKSampleQuery {
    extern_methods!(
        /// The maximum number of results the receiver will return upon completion.
        #[unsafe(method(limit))]
        #[unsafe(method_family = none)]
        pub unsafe fn limit(&self) -> NSUInteger;

        /// An array of NSSortDescriptors.
        #[unsafe(method(sortDescriptors))]
        #[unsafe(method_family = none)]
        pub unsafe fn sortDescriptors(&self) -> Option<Retained<NSArray<NSSortDescriptor>>>;

        #[cfg(all(
            feature = "HKObject",
            feature = "HKObjectType",
            feature = "HKSample",
            feature = "block2"
        ))]
        /// Returns a query that will retrieve HKSamples matching the given predicate.
        ///
        ///
        /// Parameter `sampleType`: The type of sample to retrieve.
        ///
        /// Parameter `predicate`: The predicate which samples should match.
        ///
        /// Parameter `limit`: The maximum number of samples to return.  Pass HKObjectQueryNoLimit for no limit.
        ///
        /// Parameter `sortDescriptors`: The sort descriptors to use to order the resulting samples.
        ///
        /// Parameter `resultsHandler`: The block to invoke with results when the query has finished executing.
        ///
        /// # Safety
        ///
        /// `results_handler` block must be sendable.
        #[unsafe(method(initWithSampleType:predicate:limit:sortDescriptors:resultsHandler:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithSampleType_predicate_limit_sortDescriptors_resultsHandler(
            this: Allocated<Self>,
            sample_type: &HKSampleType,
            predicate: Option<&NSPredicate>,
            limit: NSUInteger,
            sort_descriptors: Option<&NSArray<NSSortDescriptor>>,
            results_handler: &block2::DynBlock<
                dyn Fn(NonNull<HKSampleQuery>, *mut NSArray<HKSample>, *mut NSError),
            >,
        ) -> Retained<Self>;

        #[cfg(all(
            feature = "HKObject",
            feature = "HKQueryDescriptor",
            feature = "HKSample",
            feature = "block2"
        ))]
        /// Returns a query that will retrieve HKSamples matching any of the given queryDescriptors.
        ///
        ///
        /// Parameter `queryDescriptors`: An array of query descriptors that describes the sample types and predicates
        /// used for querying.
        ///
        /// Parameter `limit`: The maximum number of samples to return. Pass HKObjectQueryNoLimit
        /// for no limit.
        ///
        /// Parameter `resultsHandler`: The block to invoke with results when the query has finished executing. This
        /// block is invoked once with results, an array of HKSamples matching the
        /// queryDescriptors passed in, or nil if an error occurred.
        ///
        /// # Safety
        ///
        /// `results_handler` block must be sendable.
        #[unsafe(method(initWithQueryDescriptors:limit:resultsHandler:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithQueryDescriptors_limit_resultsHandler(
            this: Allocated<Self>,
            query_descriptors: &NSArray<HKQueryDescriptor>,
            limit: NSInteger,
            results_handler: &block2::DynBlock<
                dyn Fn(NonNull<HKSampleQuery>, *mut NSArray<HKSample>, *mut NSError),
            >,
        ) -> Retained<Self>;

        #[cfg(all(
            feature = "HKObject",
            feature = "HKQueryDescriptor",
            feature = "HKSample",
            feature = "block2"
        ))]
        /// Returns a query that will retrieve HKSamples matching any of the given queryDescriptors.
        ///
        ///
        /// Parameter `queryDescriptors`: An array of query descriptors that describes the sample types and predicates
        /// used for querying.
        ///
        /// Parameter `limit`: The maximum number of samples to return. Pass HKObjectQueryNoLimit
        /// for no limit.
        ///
        /// Parameter `sortDescriptors`: The sort descriptors to use to order the resulting samples.
        ///
        /// Parameter `resultsHandler`: The block to invoke with results when the query has finished executing. This
        /// block is invoked once with results, an array of HKSamples matching the
        /// queryDescriptors passed in, or nil if an error occurred. The HKSamples in the
        /// array are sorted by the specified sortDescriptors.
        ///
        /// # Safety
        ///
        /// `results_handler` block must be sendable.
        #[unsafe(method(initWithQueryDescriptors:limit:sortDescriptors:resultsHandler:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithQueryDescriptors_limit_sortDescriptors_resultsHandler(
            this: Allocated<Self>,
            query_descriptors: &NSArray<HKQueryDescriptor>,
            limit: NSInteger,
            sort_descriptors: &NSArray<NSSortDescriptor>,
            results_handler: &block2::DynBlock<
                dyn Fn(NonNull<HKSampleQuery>, *mut NSArray<HKSample>, *mut NSError),
            >,
        ) -> Retained<Self>;
    );
}

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