objc2_health_kit/generated/
HKStatistics.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
9/// Options for specifying which statistics to calculate
10///
11/// When querying for HKStatistics objects, an options bitmask will specify which statistics will be
12/// calculated.
13///
14/// Statistics are classified as discrete or cumulative.  If a discrete statistics option is specified for a
15/// cumulative HKQuantityType, an exception will be thrown.  If a cumulative statistics options is specified
16/// for a discrete HKQuantityType, an exception will also be thrown.
17///
18/// See also [Apple's documentation](https://developer.apple.com/documentation/healthkit/hkstatisticsoptions?language=objc)
19// NS_OPTIONS
20#[repr(transparent)]
21#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
22pub struct HKStatisticsOptions(pub NSUInteger);
23bitflags::bitflags! {
24    impl HKStatisticsOptions: NSUInteger {
25        #[doc(alias = "HKStatisticsOptionNone")]
26        const None = 0;
27        #[doc(alias = "HKStatisticsOptionSeparateBySource")]
28        const SeparateBySource = 1<<0;
29        #[doc(alias = "HKStatisticsOptionDiscreteAverage")]
30        const DiscreteAverage = 1<<1;
31        #[doc(alias = "HKStatisticsOptionDiscreteMin")]
32        const DiscreteMin = 1<<2;
33        #[doc(alias = "HKStatisticsOptionDiscreteMax")]
34        const DiscreteMax = 1<<3;
35        #[doc(alias = "HKStatisticsOptionCumulativeSum")]
36        const CumulativeSum = 1<<4;
37        #[doc(alias = "HKStatisticsOptionMostRecent")]
38        const MostRecent = 1<<5;
39        #[doc(alias = "HKStatisticsOptionDiscreteMostRecent")]
40#[deprecated]
41        const DiscreteMostRecent = HKStatisticsOptions::MostRecent.0;
42        #[doc(alias = "HKStatisticsOptionDuration")]
43        const Duration = 1<<6;
44    }
45}
46
47unsafe impl Encode for HKStatisticsOptions {
48    const ENCODING: Encoding = NSUInteger::ENCODING;
49}
50
51unsafe impl RefEncode for HKStatisticsOptions {
52    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
53}
54
55extern_class!(
56    /// Represents statistics for quantity samples over a period of time.
57    ///
58    /// See also [Apple's documentation](https://developer.apple.com/documentation/healthkit/hkstatistics?language=objc)
59    #[unsafe(super(NSObject))]
60    #[derive(Debug, PartialEq, Eq, Hash)]
61    pub struct HKStatistics;
62);
63
64unsafe impl Send for HKStatistics {}
65
66unsafe impl Sync for HKStatistics {}
67
68extern_conformance!(
69    unsafe impl NSCoding for HKStatistics {}
70);
71
72extern_conformance!(
73    unsafe impl NSCopying for HKStatistics {}
74);
75
76unsafe impl CopyingHelper for HKStatistics {
77    type Result = Self;
78}
79
80extern_conformance!(
81    unsafe impl NSObjectProtocol for HKStatistics {}
82);
83
84extern_conformance!(
85    unsafe impl NSSecureCoding for HKStatistics {}
86);
87
88impl HKStatistics {
89    extern_methods!(
90        #[cfg(feature = "HKObjectType")]
91        #[unsafe(method(quantityType))]
92        #[unsafe(method_family = none)]
93        pub unsafe fn quantityType(&self) -> Retained<HKQuantityType>;
94
95        #[unsafe(method(startDate))]
96        #[unsafe(method_family = none)]
97        pub unsafe fn startDate(&self) -> Retained<NSDate>;
98
99        #[unsafe(method(endDate))]
100        #[unsafe(method_family = none)]
101        pub unsafe fn endDate(&self) -> Retained<NSDate>;
102
103        #[cfg(feature = "HKSource")]
104        #[unsafe(method(sources))]
105        #[unsafe(method_family = none)]
106        pub unsafe fn sources(&self) -> Option<Retained<NSArray<HKSource>>>;
107
108        #[unsafe(method(init))]
109        #[unsafe(method_family = init)]
110        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
111
112        #[cfg(all(feature = "HKQuantity", feature = "HKSource"))]
113        /// Returns the average quantity for the given source in the time period represented by the receiver.
114        ///
115        /// If HKStatisticsOptionSeparateBySource is not specified, then this will always be nil.
116        #[unsafe(method(averageQuantityForSource:))]
117        #[unsafe(method_family = none)]
118        pub unsafe fn averageQuantityForSource(
119            &self,
120            source: &HKSource,
121        ) -> Option<Retained<HKQuantity>>;
122
123        #[cfg(feature = "HKQuantity")]
124        /// Returns the average quantity in the time period represented by the receiver.
125        #[unsafe(method(averageQuantity))]
126        #[unsafe(method_family = none)]
127        pub unsafe fn averageQuantity(&self) -> Option<Retained<HKQuantity>>;
128
129        #[cfg(all(feature = "HKQuantity", feature = "HKSource"))]
130        /// Returns the minimum quantity for the given source in the time period represented by the receiver.
131        ///
132        /// If HKStatisticsOptionSeparateBySource is not specified, then this will always be nil.
133        #[unsafe(method(minimumQuantityForSource:))]
134        #[unsafe(method_family = none)]
135        pub unsafe fn minimumQuantityForSource(
136            &self,
137            source: &HKSource,
138        ) -> Option<Retained<HKQuantity>>;
139
140        #[cfg(feature = "HKQuantity")]
141        /// Returns the minimum quantity in the time period represented by the receiver.
142        #[unsafe(method(minimumQuantity))]
143        #[unsafe(method_family = none)]
144        pub unsafe fn minimumQuantity(&self) -> Option<Retained<HKQuantity>>;
145
146        #[cfg(all(feature = "HKQuantity", feature = "HKSource"))]
147        /// Returns the maximum quantity for the given source in the time period represented by the receiver.
148        ///
149        /// If HKStatisticsOptionSeparateBySource is not specified, then this will always be nil.
150        #[unsafe(method(maximumQuantityForSource:))]
151        #[unsafe(method_family = none)]
152        pub unsafe fn maximumQuantityForSource(
153            &self,
154            source: &HKSource,
155        ) -> Option<Retained<HKQuantity>>;
156
157        #[cfg(feature = "HKQuantity")]
158        /// Returns the maximum quantity in the time period represented by the receiver.
159        #[unsafe(method(maximumQuantity))]
160        #[unsafe(method_family = none)]
161        pub unsafe fn maximumQuantity(&self) -> Option<Retained<HKQuantity>>;
162
163        #[cfg(all(feature = "HKQuantity", feature = "HKSource"))]
164        /// Returns the most recent quantity for the given source in the time period represented by the receiver.
165        ///
166        /// If HKStatisticsOptionSeparateBySource is not specified, then this will always be nil.
167        #[unsafe(method(mostRecentQuantityForSource:))]
168        #[unsafe(method_family = none)]
169        pub unsafe fn mostRecentQuantityForSource(
170            &self,
171            source: &HKSource,
172        ) -> Option<Retained<HKQuantity>>;
173
174        #[cfg(feature = "HKQuantity")]
175        /// Returns the most recent quantity in the time period represented by the receiver.
176        #[unsafe(method(mostRecentQuantity))]
177        #[unsafe(method_family = none)]
178        pub unsafe fn mostRecentQuantity(&self) -> Option<Retained<HKQuantity>>;
179
180        #[cfg(feature = "HKSource")]
181        /// Returns the date interval of the most recent quantity for the given source in the time period
182        /// represented by the receiver.
183        ///
184        /// If HKStatisticsOptionSeparateBySource is not specified, then this will always be nil.
185        #[unsafe(method(mostRecentQuantityDateIntervalForSource:))]
186        #[unsafe(method_family = none)]
187        pub unsafe fn mostRecentQuantityDateIntervalForSource(
188            &self,
189            source: &HKSource,
190        ) -> Option<Retained<NSDateInterval>>;
191
192        /// Returns the date interval of the most recent quantity in the time period represented by the receiver.
193        #[unsafe(method(mostRecentQuantityDateInterval))]
194        #[unsafe(method_family = none)]
195        pub unsafe fn mostRecentQuantityDateInterval(&self) -> Option<Retained<NSDateInterval>>;
196
197        #[cfg(all(feature = "HKQuantity", feature = "HKSource"))]
198        /// Returns the sum quantity for the given source in the time period represented by the receiver.
199        ///
200        /// If HKStatisticsOptionSeparateBySource is not specified, then this will always be nil.
201        #[unsafe(method(sumQuantityForSource:))]
202        #[unsafe(method_family = none)]
203        pub unsafe fn sumQuantityForSource(
204            &self,
205            source: &HKSource,
206        ) -> Option<Retained<HKQuantity>>;
207
208        #[cfg(feature = "HKQuantity")]
209        /// Returns the sum of quantities in the time period represented by the receiver.
210        #[unsafe(method(sumQuantity))]
211        #[unsafe(method_family = none)]
212        pub unsafe fn sumQuantity(&self) -> Option<Retained<HKQuantity>>;
213
214        #[cfg(feature = "HKQuantity")]
215        /// Total duration (in seconds) covered by the samples represented by these statistics.
216        /// Only present if HKStatisticsOptionDuration is is specified.
217        ///
218        ///
219        ///
220        /// Total duration, as a time-unit compatible quantity, covered by the samples represented by these statistics.
221        ///
222        /// Only present if HKStatisticsOptionDuration is is specified.
223        #[unsafe(method(duration))]
224        #[unsafe(method_family = none)]
225        pub unsafe fn duration(&self) -> Option<Retained<HKQuantity>>;
226
227        #[cfg(all(feature = "HKQuantity", feature = "HKSource"))]
228        /// Returns the duration, as a time-unit compatible quantity, for the given source in the time period represented by the receiver.
229        ///
230        /// If HKStatisticsOptionSeparateBySource is not specified, then this will always be nil.
231        #[unsafe(method(durationForSource:))]
232        #[unsafe(method_family = none)]
233        pub unsafe fn durationForSource(&self, source: &HKSource) -> Option<Retained<HKQuantity>>;
234    );
235}
236
237/// Methods declared on superclass `NSObject`.
238impl HKStatistics {
239    extern_methods!(
240        #[unsafe(method(new))]
241        #[unsafe(method_family = new)]
242        pub unsafe fn new() -> Retained<Self>;
243    );
244}