objc2_health_kit/generated/
HKWorkoutActivity.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ptr::NonNull;
4use objc2::__framework_prelude::*;
5use objc2_foundation::*;
6
7use crate::*;
8
9extern_class!(
10    /// An HKWorkoutActivity is an object describing the properties of an activity within an HKWorkout.
11    ///
12    /// See also [Apple's documentation](https://developer.apple.com/documentation/healthkit/hkworkoutactivity?language=objc)
13    #[unsafe(super(NSObject))]
14    #[derive(Debug, PartialEq, Eq, Hash)]
15    pub struct HKWorkoutActivity;
16);
17
18unsafe impl Send for HKWorkoutActivity {}
19
20unsafe impl Sync for HKWorkoutActivity {}
21
22extern_conformance!(
23    unsafe impl NSCoding for HKWorkoutActivity {}
24);
25
26extern_conformance!(
27    unsafe impl NSCopying for HKWorkoutActivity {}
28);
29
30unsafe impl CopyingHelper for HKWorkoutActivity {
31    type Result = Self;
32}
33
34extern_conformance!(
35    unsafe impl NSObjectProtocol for HKWorkoutActivity {}
36);
37
38extern_conformance!(
39    unsafe impl NSSecureCoding for HKWorkoutActivity {}
40);
41
42impl HKWorkoutActivity {
43    extern_methods!(
44        /// A unique identifier of the activity in the HealthKit database.
45        #[unsafe(method(UUID))]
46        #[unsafe(method_family = none)]
47        pub unsafe fn UUID(&self) -> Retained<NSUUID>;
48
49        #[cfg(feature = "HKWorkoutConfiguration")]
50        /// The configuration object describing the workout activity.
51        #[unsafe(method(workoutConfiguration))]
52        #[unsafe(method_family = none)]
53        pub unsafe fn workoutConfiguration(&self) -> Retained<HKWorkoutConfiguration>;
54
55        /// The point in time when the workout activity was started.
56        #[unsafe(method(startDate))]
57        #[unsafe(method_family = none)]
58        pub unsafe fn startDate(&self) -> Retained<NSDate>;
59
60        /// The point in time when the workout activity was ended.
61        ///
62        /// This value is nil when a workout activity is in progress.
63        #[unsafe(method(endDate))]
64        #[unsafe(method_family = none)]
65        pub unsafe fn endDate(&self) -> Option<Retained<NSDate>>;
66
67        /// Extra information describing properties of the workout activity.
68        ///
69        /// Keys must be NSString and values must be either NSString, NSNumber, NSDate, or
70        /// HKQuantity. See HKMetadata.h for potential metadata keys and values.
71        #[unsafe(method(metadata))]
72        #[unsafe(method_family = none)]
73        pub unsafe fn metadata(&self) -> Option<Retained<NSDictionary<NSString, AnyObject>>>;
74
75        /// The length of time that the workout activity was recording
76        ///
77        /// The duration is derived from the start and end dates of the activity and takes
78        /// into account periods that the activity was paused. Periods that the activity was
79        /// paused are based off of the workoutEvents property of the parent workout object.
80        #[unsafe(method(duration))]
81        #[unsafe(method_family = none)]
82        pub unsafe fn duration(&self) -> NSTimeInterval;
83
84        #[cfg(feature = "HKWorkout")]
85        /// An array of HKWorkoutEvents that occurred during the workout activity.
86        ///
87        /// These events will be ordered by date in ascending order. These events are a subset
88        /// of the workout events that take place between the start date and end date of the
89        /// activity. This includes any event that overlaps the activity, even partially.
90        /// Consequently, some events may be included in more than one activity.
91        #[unsafe(method(workoutEvents))]
92        #[unsafe(method_family = none)]
93        pub unsafe fn workoutEvents(&self) -> Retained<NSArray<HKWorkoutEvent>>;
94
95        #[cfg(all(feature = "HKObjectType", feature = "HKStatistics"))]
96        /// A dictionary of statistics per quantity type during the activity
97        ///
98        /// This dictionary will contain HKStatistics objects containing the statistics by quantity
99        /// sample type for all of the samples that have been added to the workout within the date
100        /// interval of this activity.
101        #[unsafe(method(allStatistics))]
102        #[unsafe(method_family = none)]
103        pub unsafe fn allStatistics(&self) -> Retained<NSDictionary<HKQuantityType, HKStatistics>>;
104
105        #[cfg(all(feature = "HKObjectType", feature = "HKStatistics"))]
106        /// Returns an HKStatistics object containing the statistics for all the samples of the given type that
107        /// have been added to the workout within the date interval of this activity. If there are no samples of
108        /// the given type then nil is returned.
109        ///
110        ///
111        /// Parameter `quantityType`: The quantity type to gather statistics about.
112        #[unsafe(method(statisticsForType:))]
113        #[unsafe(method_family = none)]
114        pub unsafe fn statisticsForType(
115            &self,
116            quantity_type: &HKQuantityType,
117        ) -> Option<Retained<HKStatistics>>;
118
119        #[unsafe(method(init))]
120        #[unsafe(method_family = init)]
121        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
122
123        #[unsafe(method(new))]
124        #[unsafe(method_family = new)]
125        pub unsafe fn new() -> Retained<Self>;
126
127        #[cfg(feature = "HKWorkoutConfiguration")]
128        /// Initialize a new HKWorkoutActivity with the specified values.
129        ///
130        ///
131        /// Parameter `workoutConfiguration`: The configuration object describing the workout activity.
132        ///
133        /// Parameter `startDate`: The point in time when the workout activity was started.
134        ///
135        /// Parameter `endDate`: The point in time when the workout activity was ended.
136        ///
137        /// Parameter `metadata`: Metadata for the workout activity. (Optional)
138        ///
139        /// # Safety
140        ///
141        /// `metadata` generic should be of the correct type.
142        #[unsafe(method(initWithWorkoutConfiguration:startDate:endDate:metadata:))]
143        #[unsafe(method_family = init)]
144        pub unsafe fn initWithWorkoutConfiguration_startDate_endDate_metadata(
145            this: Allocated<Self>,
146            workout_configuration: &HKWorkoutConfiguration,
147            start_date: &NSDate,
148            end_date: Option<&NSDate>,
149            metadata: Option<&NSDictionary<NSString, AnyObject>>,
150        ) -> Retained<Self>;
151    );
152}
153
154extern "C" {
155    /// [Apple's documentation](https://developer.apple.com/documentation/healthkit/hkpredicatekeypathworkoutactivitytype?language=objc)
156    pub static HKPredicateKeyPathWorkoutActivityType: &'static NSString;
157}
158
159extern "C" {
160    /// [Apple's documentation](https://developer.apple.com/documentation/healthkit/hkpredicatekeypathworkoutactivityduration?language=objc)
161    pub static HKPredicateKeyPathWorkoutActivityDuration: &'static NSString;
162}
163
164extern "C" {
165    /// [Apple's documentation](https://developer.apple.com/documentation/healthkit/hkpredicatekeypathworkoutactivitystartdate?language=objc)
166    pub static HKPredicateKeyPathWorkoutActivityStartDate: &'static NSString;
167}
168
169extern "C" {
170    /// [Apple's documentation](https://developer.apple.com/documentation/healthkit/hkpredicatekeypathworkoutactivityenddate?language=objc)
171    pub static HKPredicateKeyPathWorkoutActivityEndDate: &'static NSString;
172}
173
174extern "C" {
175    /// [Apple's documentation](https://developer.apple.com/documentation/healthkit/hkpredicatekeypathworkoutactivitysumquantity?language=objc)
176    pub static HKPredicateKeyPathWorkoutActivitySumQuantity: &'static NSString;
177}
178
179extern "C" {
180    /// [Apple's documentation](https://developer.apple.com/documentation/healthkit/hkpredicatekeypathworkoutactivityminimumquantity?language=objc)
181    pub static HKPredicateKeyPathWorkoutActivityMinimumQuantity: &'static NSString;
182}
183
184extern "C" {
185    /// [Apple's documentation](https://developer.apple.com/documentation/healthkit/hkpredicatekeypathworkoutactivitymaximumquantity?language=objc)
186    pub static HKPredicateKeyPathWorkoutActivityMaximumQuantity: &'static NSString;
187}
188
189extern "C" {
190    /// [Apple's documentation](https://developer.apple.com/documentation/healthkit/hkpredicatekeypathworkoutactivityaveragequantity?language=objc)
191    pub static HKPredicateKeyPathWorkoutActivityAverageQuantity: &'static NSString;
192}