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_protocol!(
    /// [Apple's documentation](https://developer.apple.com/documentation/healthkit/hkliveworkoutbuilderdelegate?language=objc)
    pub unsafe trait HKLiveWorkoutBuilderDelegate: NSObjectProtocol {
        #[cfg(all(feature = "HKObjectType", feature = "HKWorkoutBuilder"))]
        /// Called every time new samples are added to the workout builder.
        ///
        /// With new samples added, statistics for the collectedTypes may have changed and should be read again
        ///
        ///
        /// Parameter `workoutBuilder`: The workout builder to which samples were added.
        ///
        /// Parameter `collectedTypes`: The sample types that were added.
        #[unsafe(method(workoutBuilder:didCollectDataOfTypes:))]
        #[unsafe(method_family = none)]
        unsafe fn workoutBuilder_didCollectDataOfTypes(
            &self,
            workout_builder: &HKLiveWorkoutBuilder,
            collected_types: &NSSet<HKSampleType>,
        );

        #[cfg(feature = "HKWorkoutBuilder")]
        /// Called every time a new event is added to the workout builder.
        ///
        ///
        /// Parameter `workoutBuilder`: The workout builder to which an event was added.
        #[unsafe(method(workoutBuilderDidCollectEvent:))]
        #[unsafe(method_family = none)]
        unsafe fn workoutBuilderDidCollectEvent(&self, workout_builder: &HKLiveWorkoutBuilder);

        #[cfg(all(feature = "HKWorkoutActivity", feature = "HKWorkoutBuilder"))]
        /// Called every time new activity is started and added to the workout builder.
        ///
        ///
        /// Parameter `workoutBuilder`: The workout builder to which the activity was added to.
        ///
        /// Parameter `workoutActivity`: The activity that was added.
        #[optional]
        #[unsafe(method(workoutBuilder:didBeginActivity:))]
        #[unsafe(method_family = none)]
        unsafe fn workoutBuilder_didBeginActivity(
            &self,
            workout_builder: &HKLiveWorkoutBuilder,
            workout_activity: &HKWorkoutActivity,
        );

        #[cfg(all(feature = "HKWorkoutActivity", feature = "HKWorkoutBuilder"))]
        /// Called every time the end date is set on an activity in the workout builder.
        ///
        ///
        /// Parameter `workoutBuilder`: The workout builder to which the activity belongs to
        ///
        /// Parameter `workoutActivity`: The activity that was ended.
        #[optional]
        #[unsafe(method(workoutBuilder:didEndActivity:))]
        #[unsafe(method_family = none)]
        unsafe fn workoutBuilder_didEndActivity(
            &self,
            workout_builder: &HKLiveWorkoutBuilder,
            workout_activity: &HKWorkoutActivity,
        );
    }
);

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

#[cfg(feature = "HKWorkoutBuilder")]
unsafe impl Send for HKLiveWorkoutBuilder {}

#[cfg(feature = "HKWorkoutBuilder")]
unsafe impl Sync for HKLiveWorkoutBuilder {}

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

#[cfg(feature = "HKWorkoutBuilder")]
impl HKLiveWorkoutBuilder {
    extern_methods!(
        #[cfg(all(
            feature = "HKDevice",
            feature = "HKHealthStore",
            feature = "HKWorkoutConfiguration"
        ))]
        #[unsafe(method(initWithHealthStore:configuration:device:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithHealthStore_configuration_device(
            this: Allocated<Self>,
            health_store: &HKHealthStore,
            configuration: &HKWorkoutConfiguration,
            device: Option<&HKDevice>,
        ) -> Retained<Self>;

        /// The delegate object which will be notified of changes to collected data and elapsed workout time.
        #[unsafe(method(delegate))]
        #[unsafe(method_family = none)]
        pub unsafe fn delegate(
            &self,
        ) -> Option<Retained<ProtocolObject<dyn HKLiveWorkoutBuilderDelegate>>>;

        /// Setter for [`delegate`][Self::delegate].
        ///
        /// This is a [weak property][objc2::topics::weak_property].
        #[unsafe(method(setDelegate:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setDelegate(
            &self,
            delegate: Option<&ProtocolObject<dyn HKLiveWorkoutBuilderDelegate>>,
        );

        #[cfg(feature = "HKWorkoutSession")]
        /// The workout session with which this builder is associated.
        #[unsafe(method(workoutSession))]
        #[unsafe(method_family = none)]
        pub unsafe fn workoutSession(&self) -> Option<Retained<HKWorkoutSession>>;

        /// Whether or not the builder should automatically incorporate events generated by the session.
        ///
        /// YES if the builder should automatically incorporate events from the associated session. If NO, the client
        /// is expected to add relevant events directly to the builder and those generated by the session will be
        /// ignored. Defaults to YES. The result of changing this value after a call to
        /// beginCollectionWithStartDate:completion: is undefined.
        #[unsafe(method(shouldCollectWorkoutEvents))]
        #[unsafe(method_family = none)]
        pub unsafe fn shouldCollectWorkoutEvents(&self) -> bool;

        /// Setter for [`shouldCollectWorkoutEvents`][Self::shouldCollectWorkoutEvents].
        #[unsafe(method(setShouldCollectWorkoutEvents:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setShouldCollectWorkoutEvents(&self, should_collect_workout_events: bool);

        #[cfg(feature = "HKLiveWorkoutDataSource")]
        /// The data source that will provide data to this workout builder.
        #[unsafe(method(dataSource))]
        #[unsafe(method_family = none)]
        pub unsafe fn dataSource(&self) -> Option<Retained<HKLiveWorkoutDataSource>>;

        #[cfg(feature = "HKLiveWorkoutDataSource")]
        /// Setter for [`dataSource`][Self::dataSource].
        #[unsafe(method(setDataSource:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setDataSource(&self, data_source: Option<&HKLiveWorkoutDataSource>);

        /// The elapsed duration of the workout as constructed thus far, considering paused time. When the builder
        /// is reading events from an active session, it is possible for this value to increase or decrease;
        /// when this occurs, the workoutBuilderDidCollectEvent: delegate method will be called.
        #[unsafe(method(elapsedTime))]
        #[unsafe(method_family = none)]
        pub unsafe fn elapsedTime(&self) -> NSTimeInterval;

        #[cfg(feature = "HKWorkoutActivity")]
        /// The latest activity that has been added to this builder.
        ///
        /// When an activity is in progress it will be returned by this property. The end date of this activity will always
        /// be nil. When the activity is ended, the property would be set to nil until a new activity begins.
        #[unsafe(method(currentWorkoutActivity))]
        #[unsafe(method_family = none)]
        pub unsafe fn currentWorkoutActivity(&self) -> Option<Retained<HKWorkoutActivity>>;
    );
}

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