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::ptr::NonNull;
use objc2::__framework_prelude::*;
use objc2_foundation::*;

use crate::*;

extern_class!(
    /// An HKWorkoutActivity is an object describing the properties of an activity within an HKWorkout.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/healthkit/hkworkoutactivity?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct HKWorkoutActivity;
);

unsafe impl Send for HKWorkoutActivity {}

unsafe impl Sync for HKWorkoutActivity {}

extern_conformance!(
    unsafe impl NSCoding for HKWorkoutActivity {}
);

extern_conformance!(
    unsafe impl NSCopying for HKWorkoutActivity {}
);

unsafe impl CopyingHelper for HKWorkoutActivity {
    type Result = Self;
}

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

extern_conformance!(
    unsafe impl NSSecureCoding for HKWorkoutActivity {}
);

impl HKWorkoutActivity {
    extern_methods!(
        /// A unique identifier of the activity in the HealthKit database.
        #[unsafe(method(UUID))]
        #[unsafe(method_family = none)]
        pub unsafe fn UUID(&self) -> Retained<NSUUID>;

        #[cfg(feature = "HKWorkoutConfiguration")]
        /// The configuration object describing the workout activity.
        #[unsafe(method(workoutConfiguration))]
        #[unsafe(method_family = none)]
        pub unsafe fn workoutConfiguration(&self) -> Retained<HKWorkoutConfiguration>;

        /// The point in time when the workout activity was started.
        #[unsafe(method(startDate))]
        #[unsafe(method_family = none)]
        pub unsafe fn startDate(&self) -> Retained<NSDate>;

        /// The point in time when the workout activity was ended.
        ///
        /// This value is nil when a workout activity is in progress.
        #[unsafe(method(endDate))]
        #[unsafe(method_family = none)]
        pub unsafe fn endDate(&self) -> Option<Retained<NSDate>>;

        /// Extra information describing properties of the workout activity.
        ///
        /// Keys must be NSString and values must be either NSString, NSNumber, NSDate, or
        /// HKQuantity. See HKMetadata.h for potential metadata keys and values.
        #[unsafe(method(metadata))]
        #[unsafe(method_family = none)]
        pub unsafe fn metadata(&self) -> Option<Retained<NSDictionary<NSString, AnyObject>>>;

        /// The length of time that the workout activity was recording
        ///
        /// The duration is derived from the start and end dates of the activity and takes
        /// into account periods that the activity was paused. Periods that the activity was
        /// paused are based off of the workoutEvents property of the parent workout object.
        #[unsafe(method(duration))]
        #[unsafe(method_family = none)]
        pub unsafe fn duration(&self) -> NSTimeInterval;

        #[cfg(feature = "HKWorkout")]
        /// An array of HKWorkoutEvents that occurred during the workout activity.
        ///
        /// These events will be ordered by date in ascending order. These events are a subset
        /// of the workout events that take place between the start date and end date of the
        /// activity. This includes any event that overlaps the activity, even partially.
        /// Consequently, some events may be included in more than one activity.
        #[unsafe(method(workoutEvents))]
        #[unsafe(method_family = none)]
        pub unsafe fn workoutEvents(&self) -> Retained<NSArray<HKWorkoutEvent>>;

        #[cfg(all(feature = "HKObjectType", feature = "HKStatistics"))]
        /// A dictionary of statistics per quantity type during the activity
        ///
        /// This dictionary will contain HKStatistics objects containing the statistics by quantity
        /// sample type for all of the samples that have been added to the workout within the date
        /// interval of this activity.
        #[unsafe(method(allStatistics))]
        #[unsafe(method_family = none)]
        pub unsafe fn allStatistics(&self) -> Retained<NSDictionary<HKQuantityType, HKStatistics>>;

        #[cfg(all(feature = "HKObjectType", feature = "HKStatistics"))]
        /// Returns an HKStatistics object containing the statistics for all the samples of the given type that
        /// have been added to the workout within the date interval of this activity. If there are no samples of
        /// the given type then nil is returned.
        ///
        ///
        /// Parameter `quantityType`: The quantity type to gather statistics about.
        #[unsafe(method(statisticsForType:))]
        #[unsafe(method_family = none)]
        pub unsafe fn statisticsForType(
            &self,
            quantity_type: &HKQuantityType,
        ) -> Option<Retained<HKStatistics>>;

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

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;

        #[cfg(feature = "HKWorkoutConfiguration")]
        /// Initialize a new HKWorkoutActivity with the specified values.
        ///
        ///
        /// Parameter `workoutConfiguration`: The configuration object describing the workout activity.
        ///
        /// Parameter `startDate`: The point in time when the workout activity was started.
        ///
        /// Parameter `endDate`: The point in time when the workout activity was ended.
        ///
        /// Parameter `metadata`: Metadata for the workout activity. (Optional)
        ///
        /// # Safety
        ///
        /// `metadata` generic should be of the correct type.
        #[unsafe(method(initWithWorkoutConfiguration:startDate:endDate:metadata:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithWorkoutConfiguration_startDate_endDate_metadata(
            this: Allocated<Self>,
            workout_configuration: &HKWorkoutConfiguration,
            start_date: &NSDate,
            end_date: Option<&NSDate>,
            metadata: Option<&NSDictionary<NSString, AnyObject>>,
        ) -> Retained<Self>;
    );
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/healthkit/hkpredicatekeypathworkoutactivitytype?language=objc)
    pub static HKPredicateKeyPathWorkoutActivityType: &'static NSString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/healthkit/hkpredicatekeypathworkoutactivityduration?language=objc)
    pub static HKPredicateKeyPathWorkoutActivityDuration: &'static NSString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/healthkit/hkpredicatekeypathworkoutactivitystartdate?language=objc)
    pub static HKPredicateKeyPathWorkoutActivityStartDate: &'static NSString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/healthkit/hkpredicatekeypathworkoutactivityenddate?language=objc)
    pub static HKPredicateKeyPathWorkoutActivityEndDate: &'static NSString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/healthkit/hkpredicatekeypathworkoutactivitysumquantity?language=objc)
    pub static HKPredicateKeyPathWorkoutActivitySumQuantity: &'static NSString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/healthkit/hkpredicatekeypathworkoutactivityminimumquantity?language=objc)
    pub static HKPredicateKeyPathWorkoutActivityMinimumQuantity: &'static NSString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/healthkit/hkpredicatekeypathworkoutactivitymaximumquantity?language=objc)
    pub static HKPredicateKeyPathWorkoutActivityMaximumQuantity: &'static NSString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/healthkit/hkpredicatekeypathworkoutactivityaveragequantity?language=objc)
    pub static HKPredicateKeyPathWorkoutActivityAverageQuantity: &'static NSString;
}