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::*;
#[cfg(feature = "objc2-core-location")]
use objc2_core_location::*;
use objc2_foundation::*;

use crate::*;

extern_class!(
    /// An HKWorkoutRouteBuilder is used to generate an HKWorkoutRoute.
    ///
    /// This class is intended for generating long-running location data collection such as
    /// might be associated with a workout. If the discard method is called, collected data will be deleted.
    /// Calling finishRouteWithWorkout:metadata: will stop and complete the route. 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/hkworkoutroutebuilder?language=objc)
    #[unsafe(super(HKSeriesBuilder, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "HKSeriesBuilder")]
    pub struct HKWorkoutRouteBuilder;
);

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

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

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

#[cfg(feature = "HKSeriesBuilder")]
impl HKWorkoutRouteBuilder {
    extern_methods!(
        #[cfg(all(feature = "HKDevice", feature = "HKHealthStore"))]
        /// The designated initializer to create an HKWorkoutRouteBuilder. If you are using an HKWorkoutBuilder , you
        /// should not create an HKWorkoutRouteBuilder, instead use -[HKWorkoutBuilder seriesBuilderForType:]
        ///
        /// 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.
        #[unsafe(method(initWithHealthStore:device:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithHealthStore_device(
            this: Allocated<Self>,
            health_store: &HKHealthStore,
            device: Option<&HKDevice>,
        ) -> Retained<Self>;

        #[cfg(all(feature = "block2", feature = "objc2-core-location"))]
        /// Associate CLLocation with the receiver.
        ///
        /// Use this method to asynchronously add one or more CLLocation to the
        /// series. Note that CLLocation may be inserted in any order but will be
        /// sorted according to date when the series is finalized.
        ///
        ///
        /// Parameter `routeData`: An array of one or more CLLocation.
        ///
        /// 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.
        /// If data was previously saved, then the HKWorkoutRoute may be retrieved by the
        /// finishRouteWithMetadata: method.
        #[unsafe(method(insertRouteData:completion:))]
        #[unsafe(method_family = none)]
        pub unsafe fn insertRouteData_completion(
            &self,
            route_data: &NSArray<CLLocation>,
            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 = "HKObject",
            feature = "HKSample",
            feature = "HKSeriesSample",
            feature = "HKWorkout",
            feature = "HKWorkoutRoute",
            feature = "block2"
        ))]
        /// Method to stop data collection and return the associated HKWorkoutRoute. If you are using this route
        /// builder with a workout builder, you should never call this method. The route will be finished when you
        /// finish the workout builder.
        ///
        /// Call this method when the route has been completed. The completion handler will return the saved
        /// HKWorkoutRoute.     If no series data was added, then workoutRoute 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 `workout`: The HKWorkout object to which the route will be associated. Must be saved to HealthKit
        ///
        /// Parameter `metadata`: Optional metadata may be added to associate with the series. Predefined keys are found in
        /// HKMetadata.h, or private NSString keys used by the client are allowed. Acceptable metadata value
        /// types are NSString, NSDate, NSNumber and HKQuantity
        ///
        /// Parameter `completion`: The completion callback handler returns the saved HKWorkoutRoute object. If workoutRoute is nil, an
        /// error will indicate why the series could not be returned including database inaccessibility during
        /// device lock. Subsequent requests for the HKWorkoutRoute can be made through HKSampleQuery or similar
        /// queries. workoutRoute cannot be associated to another workout.
        ///
        /// # Safety
        ///
        /// `metadata` generic should be of the correct type.
        #[unsafe(method(finishRouteWithWorkout:metadata:completion:))]
        #[unsafe(method_family = none)]
        pub unsafe fn finishRouteWithWorkout_metadata_completion(
            &self,
            workout: &HKWorkout,
            metadata: Option<&NSDictionary<NSString, AnyObject>>,
            completion: &block2::DynBlock<dyn Fn(*mut HKWorkoutRoute, *mut NSError)>,
        );
    );
}

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