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/hkstatisticscollection?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct HKStatisticsCollection;
);

unsafe impl Send for HKStatisticsCollection {}

unsafe impl Sync for HKStatisticsCollection {}

extern_conformance!(
    unsafe impl NSObjectProtocol for HKStatisticsCollection {}
);

impl HKStatisticsCollection {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[cfg(feature = "HKStatistics")]
        /// Returns the statistics object that this date is inside of
        ///
        /// If there are no samples for the given date, an HKStatistics instance with nil quantities will be returned.
        #[unsafe(method(statisticsForDate:))]
        #[unsafe(method_family = none)]
        pub unsafe fn statisticsForDate(&self, date: &NSDate) -> Option<Retained<HKStatistics>>;

        #[cfg(all(feature = "HKStatistics", feature = "block2"))]
        /// Enumerates all statistics objects from startDate to endDate.
        ///
        /// Statistics objects will be enumerated in chronological order. If there are no samples for an interval
        /// between the start and end date, then the HKStatistics object for that interval will have nil quantities.
        #[unsafe(method(enumerateStatisticsFromDate:toDate:withBlock:))]
        #[unsafe(method_family = none)]
        pub unsafe fn enumerateStatisticsFromDate_toDate_withBlock(
            &self,
            start_date: &NSDate,
            end_date: &NSDate,
            block: &block2::DynBlock<dyn Fn(NonNull<HKStatistics>, NonNull<Bool>)>,
        );

        #[cfg(feature = "HKStatistics")]
        /// Returns a copy of the populated statistics objects.
        ///
        /// The statistics objects are ordered chronologically.
        #[unsafe(method(statistics))]
        #[unsafe(method_family = none)]
        pub unsafe fn statistics(&self) -> Retained<NSArray<HKStatistics>>;

        #[cfg(feature = "HKSource")]
        /// Returns all HKSources found in the contained HKStatistics objects.
        ///
        /// Sources will be empty unless HKStatisticsOptionSeparateBySource is specified in the
        /// HKStatisticsCollectionQuery options.
        #[unsafe(method(sources))]
        #[unsafe(method_family = none)]
        pub unsafe fn sources(&self) -> Retained<NSSet<HKSource>>;
    );
}

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

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

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

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

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

#[cfg(feature = "HKQuery")]
impl HKStatisticsCollectionQuery {
    extern_methods!(
        #[unsafe(method(anchorDate))]
        #[unsafe(method_family = none)]
        pub unsafe fn anchorDate(&self) -> Retained<NSDate>;

        #[cfg(feature = "HKStatistics")]
        #[unsafe(method(options))]
        #[unsafe(method_family = none)]
        pub unsafe fn options(&self) -> HKStatisticsOptions;

        #[unsafe(method(intervalComponents))]
        #[unsafe(method_family = none)]
        pub unsafe fn intervalComponents(&self) -> Retained<NSDateComponents>;

        #[cfg(feature = "block2")]
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// - The returned block must be sendable.
        /// - This might not be thread-safe.
        #[unsafe(method(initialResultsHandler))]
        #[unsafe(method_family = none)]
        pub unsafe fn initialResultsHandler(
            &self,
        ) -> *mut block2::DynBlock<
            dyn Fn(NonNull<HKStatisticsCollectionQuery>, *mut HKStatisticsCollection, *mut NSError),
        >;

        #[cfg(feature = "block2")]
        /// Setter for [`initialResultsHandler`][Self::initialResultsHandler].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        ///
        /// # Safety
        ///
        /// - `initial_results_handler` block must be sendable.
        /// - This might not be thread-safe.
        #[unsafe(method(setInitialResultsHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setInitialResultsHandler(
            &self,
            initial_results_handler: Option<
                &block2::DynBlock<
                    dyn Fn(
                        NonNull<HKStatisticsCollectionQuery>,
                        *mut HKStatisticsCollection,
                        *mut NSError,
                    ),
                >,
            >,
        );

        #[cfg(all(feature = "HKStatistics", feature = "block2"))]
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// - The returned block must be sendable.
        /// - This might not be thread-safe.
        #[unsafe(method(statisticsUpdateHandler))]
        #[unsafe(method_family = none)]
        pub unsafe fn statisticsUpdateHandler(
            &self,
        ) -> *mut block2::DynBlock<
            dyn Fn(
                NonNull<HKStatisticsCollectionQuery>,
                *mut HKStatistics,
                *mut HKStatisticsCollection,
                *mut NSError,
            ),
        >;

        #[cfg(all(feature = "HKStatistics", feature = "block2"))]
        /// Setter for [`statisticsUpdateHandler`][Self::statisticsUpdateHandler].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        ///
        /// # Safety
        ///
        /// - `statistics_update_handler` block must be sendable.
        /// - This might not be thread-safe.
        #[unsafe(method(setStatisticsUpdateHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setStatisticsUpdateHandler(
            &self,
            statistics_update_handler: Option<
                &block2::DynBlock<
                    dyn Fn(
                        NonNull<HKStatisticsCollectionQuery>,
                        *mut HKStatistics,
                        *mut HKStatisticsCollection,
                        *mut NSError,
                    ),
                >,
            >,
        );

        #[cfg(all(feature = "HKObjectType", feature = "HKStatistics"))]
        #[unsafe(method(initWithQuantityType:quantitySamplePredicate:options:anchorDate:intervalComponents:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithQuantityType_quantitySamplePredicate_options_anchorDate_intervalComponents(
            this: Allocated<Self>,
            quantity_type: &HKQuantityType,
            quantity_sample_predicate: Option<&NSPredicate>,
            options: HKStatisticsOptions,
            anchor_date: &NSDate,
            interval_components: &NSDateComponents,
        ) -> Retained<Self>;
    );
}

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