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!(
    /// An HKHeartbeatSeriesBuilder is used to generate an HKHeartbeatSeriesSample.
    ///
    /// This class is intended for generating an HKHeartbeatSeriesSample which represents a series of
    /// heartbeats. If the discard method is called, collected data will be deleted.
    /// Calling finishSeriesWithcompletion: will stop and complete the series. If the builder is deleted,
    /// or the client goes away before calling the finish method, data will be lost.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/healthkit/hkheartbeatseriesbuilder?language=objc)
    #[unsafe(super(HKSeriesBuilder, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "HKSeriesBuilder")]
    pub struct HKHeartbeatSeriesBuilder;
);

#[cfg(feature = "HKSeriesBuilder")]
unsafe impl Send for HKHeartbeatSeriesBuilder {}

#[cfg(feature = "HKSeriesBuilder")]
unsafe impl Sync for HKHeartbeatSeriesBuilder {}

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

#[cfg(feature = "HKSeriesBuilder")]
impl HKHeartbeatSeriesBuilder {
    extern_methods!(
        /// The maximum number of heartbeats that can be added to an HKHeartbeatSeriesBuilder.
        ///
        /// Any calls to addHeartbeatWithTimeIntervalSinceSeriesStartDate:precededByGap:completion: once
        /// maximumCount has been reached will fail and an error will be returned in the completion handler.
        #[unsafe(method(maximumCount))]
        #[unsafe(method_family = none)]
        pub unsafe fn maximumCount() -> NSUInteger;

        #[cfg(all(feature = "HKDevice", feature = "HKHealthStore"))]
        /// The designated initializer to create an HKHeartbeatSeriesBuilder.
        ///
        /// The HKHealthStore is retained during the life of the object for the saving of the series data and final
        /// return of the series sample.
        ///
        ///
        /// Parameter `healthStore`: Specifies the HKHealthStore object to use for building the series.
        ///
        /// Parameter `device`: The optional device represents the HKDevice from which the data is provided.
        ///
        /// Parameter `startDate`: The start date of the HKHeartbeatSeriesSample that will be generated.
        #[unsafe(method(initWithHealthStore:device:startDate:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithHealthStore_device_startDate(
            this: Allocated<Self>,
            health_store: &HKHealthStore,
            device: Option<&HKDevice>,
            start_date: &NSDate,
        ) -> Retained<Self>;

        #[cfg(feature = "block2")]
        /// Associate a heartbeat with the receiver.
        ///
        /// Use this method to asynchronously add a heartbeat to the series.
        ///
        ///
        /// Parameter `timeIntervalSinceStart`: The elapsed time between the series startDate and the heartbeat occurence. Must be
        /// a positive value.
        ///
        /// Parameter `precededByGap`: Whether or not this heartbeat was preceded by a gap in data collection.
        ///
        /// Parameter `completion`: The completion callback handler returns the status of the save. If the completion
        /// handler success is NO, then error is non-nil. An error here is considered fatal and
        /// the series builder will be complete.
        #[unsafe(method(addHeartbeatWithTimeIntervalSinceSeriesStartDate:precededByGap:completion:))]
        #[unsafe(method_family = none)]
        pub unsafe fn addHeartbeatWithTimeIntervalSinceSeriesStartDate_precededByGap_completion(
            &self,
            time_interval_since_start: NSTimeInterval,
            preceded_by_gap: bool,
            completion: &block2::DynBlock<dyn Fn(Bool, *mut NSError)>,
        );

        #[cfg(feature = "block2")]
        /// Adds new metadata to the builder instance. This method can be called more than once; each time
        /// the newly provided metadata will be incorporated in the same manner as
        /// -[NSMutableDictionary addEntriesFromDictionary:].
        /// This operation is performed asynchronously and the completion will be executed on an arbitrary
        /// background queue.
        ///
        ///
        /// Parameter `metadata`: The metadata to add to the builder.
        ///
        /// Parameter `completion`: Block to be called when the addition of metadata to the builder is complete.
        /// If success is YES, the metadata has been added to the builder successfully. If success
        /// is NO, error will be non-null and will contain the error encountered during the
        /// insertion operation. When an error occurs, the builder's metadata will remain unchanged.
        ///
        /// # Safety
        ///
        /// `metadata` generic should be of the correct type.
        #[unsafe(method(addMetadata:completion:))]
        #[unsafe(method_family = none)]
        pub unsafe fn addMetadata_completion(
            &self,
            metadata: &NSDictionary<NSString, AnyObject>,
            completion: &block2::DynBlock<dyn Fn(Bool, *mut NSError)>,
        );

        #[cfg(all(
            feature = "HKHeartbeatSeriesSample",
            feature = "HKObject",
            feature = "HKSample",
            feature = "HKSeriesSample",
            feature = "block2"
        ))]
        /// Method to stop data collection and return the associated HKHeartbeatSeriesSample.
        ///
        /// Call this method when you have added all heartbeats to this builder. The completion handler will
        /// return the saved HKHeartbeatSeriesSample. If no heartbeat was added, then heartbeatSeries will be
        /// nil and an error returned. The receiver will be considered invalid afterwards and any further calls
        /// to it will result in an error.
        ///
        ///
        /// Parameter `completion`: The completion callback handler returns the saved HKHeartbeatSeriesSample object. If
        /// heartbeatSeries is nil, an error will indicate why the series could not be returned
        /// including database inaccessibility during device lock. Subsequent requests for the
        /// HKHeartbeatSeriesSample can be made through HKSampleQuery or similar queries. To
        /// retrieve the data stored with an HKHeartbeatSeriesSample use HKHeartbeatSeriesQuery.
        #[unsafe(method(finishSeriesWithCompletion:))]
        #[unsafe(method_family = none)]
        pub unsafe fn finishSeriesWithCompletion(
            &self,
            completion: &block2::DynBlock<dyn Fn(*mut HKHeartbeatSeriesSample, *mut NSError)>,
        );
    );
}

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

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