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