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!(
    /// A concrete subclass of HKQuery that provides an interface to retrieve documents from the Health store.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/healthkit/hkdocumentquery?language=objc)
    #[unsafe(super(HKQuery, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "HKQuery")]
    pub struct HKDocumentQuery;
);

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

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

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

#[cfg(feature = "HKQuery")]
impl HKDocumentQuery {
    extern_methods!(
        /// The maximum number of documents 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>>>;

        /// The XML content for documents may be large.  This property can be used to control whether the query
        /// returns the XML content for each record.
        #[unsafe(method(includeDocumentData))]
        #[unsafe(method_family = none)]
        pub unsafe fn includeDocumentData(&self) -> bool;

        #[cfg(all(
            feature = "HKDocumentSample",
            feature = "HKObject",
            feature = "HKObjectType",
            feature = "HKSample",
            feature = "block2"
        ))]
        /// Returns a query that will retrieve HKDocumentSamples matching the given predicate.
        ///
        ///
        /// Parameter `documentType`: The type of document to retreive.
        ///
        /// Parameter `predicate`: The predicate which documents should match.
        ///
        /// Parameter `limit`: The maximum number of documents to return.  Pass HKObjectQueryNoLimit for no limit.
        ///
        /// Parameter `sortDescriptors`: The sort descriptors to use to order the resulting documents.
        ///
        /// Parameter `includeDocumentData`: If true, the document content will be returned with the HKDocumentSample instance.
        /// This option can be used to limit the size of the content returned since the content
        /// may be large.
        ///
        /// Parameter `resultsHandler`: The block that will receive query results.  Results will be returned incrementally
        /// through several calls to this block.  When there are no more results, the done
        /// parameter will be YES and the results array will be empty.  If results is nil, then
        /// an error has occurred and the error parameter will be set.  Delivery of results can
        /// be stopped by calling HKHealthStore's stopQuery: method.
        ///
        ///
        /// Health documents may contain sensitive data that a user may want to control explicitly. HKDocumentSample
        /// objects returned by HKSampleQuery and HKAnchoredObjectQuery do not include this data (i.e., the document
        /// property is nil).  This query can be used to retrieve fully populated HKDocumentSample instances.  The
        /// query will prompt the user to authorize your app to read individual documents.  The query will then
        /// return the documents that your app is authorized to read. The user will only be asked to authorize your
        /// app to read documents that are new since the last time an HKDocumentQuery was executed.
        ///
        /// # Safety
        ///
        /// `results_handler` block must be sendable.
        #[unsafe(method(initWithDocumentType:predicate:limit:sortDescriptors:includeDocumentData:resultsHandler:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithDocumentType_predicate_limit_sortDescriptors_includeDocumentData_resultsHandler(
            this: Allocated<Self>,
            document_type: &HKDocumentType,
            predicate: Option<&NSPredicate>,
            limit: NSUInteger,
            sort_descriptors: Option<&NSArray<NSSortDescriptor>>,
            include_document_data: bool,
            results_handler: &block2::DynBlock<
                dyn Fn(
                    NonNull<HKDocumentQuery>,
                    *mut NSArray<HKDocumentSample>,
                    Bool,
                    *mut NSError,
                ),
            >,
        ) -> Retained<Self>;
    );
}

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