objc2-health-kit 0.3.2

Bindings to the HealthKit framework
Documentation
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
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
//! 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::*;

/// [Apple's documentation](https://developer.apple.com/documentation/healthkit/hkunitmolarmassbloodglucose?language=objc)
pub const HKUnitMolarMassBloodGlucose: c_float = 180.15588000005408;
extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/healthkit/hkunit?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct HKUnit;
);

unsafe impl Send for HKUnit {}

unsafe impl Sync for HKUnit {}

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

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

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

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

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

impl HKUnit {
    extern_methods!(
        /// Returns a unique string representation for the unit that could be used with +unitFromString:
        #[unsafe(method(unitString))]
        #[unsafe(method_family = none)]
        pub unsafe fn unitString(&self) -> Retained<NSString>;

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

        #[unsafe(method(unitFromString:))]
        #[unsafe(method_family = none)]
        pub unsafe fn unitFromString(string: &NSString) -> Retained<Self>;

        #[unsafe(method(unitFromMassFormatterUnit:))]
        #[unsafe(method_family = none)]
        pub unsafe fn unitFromMassFormatterUnit(
            mass_formatter_unit: NSMassFormatterUnit,
        ) -> Retained<Self>;

        #[unsafe(method(massFormatterUnitFromUnit:))]
        #[unsafe(method_family = none)]
        pub unsafe fn massFormatterUnitFromUnit(unit: &HKUnit) -> NSMassFormatterUnit;

        #[unsafe(method(unitFromLengthFormatterUnit:))]
        #[unsafe(method_family = none)]
        pub unsafe fn unitFromLengthFormatterUnit(
            length_formatter_unit: NSLengthFormatterUnit,
        ) -> Retained<Self>;

        #[unsafe(method(lengthFormatterUnitFromUnit:))]
        #[unsafe(method_family = none)]
        pub unsafe fn lengthFormatterUnitFromUnit(unit: &HKUnit) -> NSLengthFormatterUnit;

        #[unsafe(method(unitFromEnergyFormatterUnit:))]
        #[unsafe(method_family = none)]
        pub unsafe fn unitFromEnergyFormatterUnit(
            energy_formatter_unit: NSEnergyFormatterUnit,
        ) -> Retained<Self>;

        #[unsafe(method(energyFormatterUnitFromUnit:))]
        #[unsafe(method_family = none)]
        pub unsafe fn energyFormatterUnitFromUnit(unit: &HKUnit) -> NSEnergyFormatterUnit;

        #[unsafe(method(isNull))]
        #[unsafe(method_family = none)]
        pub unsafe fn isNull(&self) -> bool;
    );
}

/// Methods declared on superclass `NSObject`.
impl HKUnit {
    extern_methods!(
        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}

/// [Apple's documentation](https://developer.apple.com/documentation/healthkit/hkmetricprefix?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct HKMetricPrefix(pub NSInteger);
impl HKMetricPrefix {
    #[doc(alias = "HKMetricPrefixNone")]
    pub const None: Self = Self(0);
    #[doc(alias = "HKMetricPrefixFemto")]
    pub const Femto: Self = Self(13);
    #[doc(alias = "HKMetricPrefixPico")]
    pub const Pico: Self = Self(1);
    #[doc(alias = "HKMetricPrefixNano")]
    pub const Nano: Self = Self(2);
    #[doc(alias = "HKMetricPrefixMicro")]
    pub const Micro: Self = Self(3);
    #[doc(alias = "HKMetricPrefixMilli")]
    pub const Milli: Self = Self(4);
    #[doc(alias = "HKMetricPrefixCenti")]
    pub const Centi: Self = Self(5);
    #[doc(alias = "HKMetricPrefixDeci")]
    pub const Deci: Self = Self(6);
    #[doc(alias = "HKMetricPrefixDeca")]
    pub const Deca: Self = Self(7);
    #[doc(alias = "HKMetricPrefixHecto")]
    pub const Hecto: Self = Self(8);
    #[doc(alias = "HKMetricPrefixKilo")]
    pub const Kilo: Self = Self(9);
    #[doc(alias = "HKMetricPrefixMega")]
    pub const Mega: Self = Self(10);
    #[doc(alias = "HKMetricPrefixGiga")]
    pub const Giga: Self = Self(11);
    #[doc(alias = "HKMetricPrefixTera")]
    pub const Tera: Self = Self(12);
}

unsafe impl Encode for HKMetricPrefix {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for HKMetricPrefix {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

/// Mass.
impl HKUnit {
    extern_methods!(
        #[unsafe(method(gramUnitWithMetricPrefix:))]
        #[unsafe(method_family = none)]
        pub unsafe fn gramUnitWithMetricPrefix(prefix: HKMetricPrefix) -> Retained<Self>;

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

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

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

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

        #[unsafe(method(moleUnitWithMetricPrefix:molarMass:))]
        #[unsafe(method_family = none)]
        pub unsafe fn moleUnitWithMetricPrefix_molarMass(
            prefix: HKMetricPrefix,
            grams_per_mole: c_double,
        ) -> Retained<Self>;

        #[unsafe(method(moleUnitWithMolarMass:))]
        #[unsafe(method_family = none)]
        pub unsafe fn moleUnitWithMolarMass(grams_per_mole: c_double) -> Retained<Self>;
    );
}

/// Length.
impl HKUnit {
    extern_methods!(
        #[unsafe(method(meterUnitWithMetricPrefix:))]
        #[unsafe(method_family = none)]
        pub unsafe fn meterUnitWithMetricPrefix(prefix: HKMetricPrefix) -> Retained<Self>;

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

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

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

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

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

/// Volume.
impl HKUnit {
    extern_methods!(
        #[unsafe(method(literUnitWithMetricPrefix:))]
        #[unsafe(method_family = none)]
        pub unsafe fn literUnitWithMetricPrefix(prefix: HKMetricPrefix) -> Retained<Self>;

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

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

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

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

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

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

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

/// Pressure.
impl HKUnit {
    extern_methods!(
        #[unsafe(method(pascalUnitWithMetricPrefix:))]
        #[unsafe(method_family = none)]
        pub unsafe fn pascalUnitWithMetricPrefix(prefix: HKMetricPrefix) -> Retained<Self>;

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

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

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

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

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

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

/// Time.
impl HKUnit {
    extern_methods!(
        #[unsafe(method(secondUnitWithMetricPrefix:))]
        #[unsafe(method_family = none)]
        pub unsafe fn secondUnitWithMetricPrefix(prefix: HKMetricPrefix) -> Retained<Self>;

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

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

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

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

/// Energy.
impl HKUnit {
    extern_methods!(
        #[unsafe(method(jouleUnitWithMetricPrefix:))]
        #[unsafe(method_family = none)]
        pub unsafe fn jouleUnitWithMetricPrefix(prefix: HKMetricPrefix) -> Retained<Self>;

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

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

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

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

        #[deprecated = "Use smallCalorieUnit or largeCalorieUnit, depending on which you mean"]
        #[unsafe(method(calorieUnit))]
        #[unsafe(method_family = none)]
        pub unsafe fn calorieUnit() -> Retained<Self>;
    );
}

/// Temperature.
impl HKUnit {
    extern_methods!(
        #[unsafe(method(degreeCelsiusUnit))]
        #[unsafe(method_family = none)]
        pub unsafe fn degreeCelsiusUnit() -> Retained<Self>;

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

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

/// Conductance.
impl HKUnit {
    extern_methods!(
        #[unsafe(method(siemenUnitWithMetricPrefix:))]
        #[unsafe(method_family = none)]
        pub unsafe fn siemenUnitWithMetricPrefix(prefix: HKMetricPrefix) -> Retained<Self>;

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

/// Pharmacology.
impl HKUnit {
    extern_methods!(
        #[unsafe(method(internationalUnit))]
        #[unsafe(method_family = none)]
        pub unsafe fn internationalUnit() -> Retained<Self>;
    );
}

/// Scalar.
impl HKUnit {
    extern_methods!(
        #[unsafe(method(countUnit))]
        #[unsafe(method_family = none)]
        pub unsafe fn countUnit() -> Retained<Self>;

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

/// HearingSensitivity.
impl HKUnit {
    extern_methods!(
        #[unsafe(method(decibelHearingLevelUnit))]
        #[unsafe(method_family = none)]
        pub unsafe fn decibelHearingLevelUnit() -> Retained<Self>;
    );
}

/// Math.
impl HKUnit {
    extern_methods!(
        #[unsafe(method(unitMultipliedByUnit:))]
        #[unsafe(method_family = none)]
        pub unsafe fn unitMultipliedByUnit(&self, unit: &HKUnit) -> Retained<HKUnit>;

        #[unsafe(method(unitDividedByUnit:))]
        #[unsafe(method_family = none)]
        pub unsafe fn unitDividedByUnit(&self, unit: &HKUnit) -> Retained<HKUnit>;

        #[unsafe(method(unitRaisedToPower:))]
        #[unsafe(method_family = none)]
        pub unsafe fn unitRaisedToPower(&self, power: NSInteger) -> Retained<HKUnit>;

        #[unsafe(method(reciprocalUnit))]
        #[unsafe(method_family = none)]
        pub unsafe fn reciprocalUnit(&self) -> Retained<HKUnit>;
    );
}

/// Frequency.
impl HKUnit {
    extern_methods!(
        #[unsafe(method(hertzUnitWithMetricPrefix:))]
        #[unsafe(method_family = none)]
        pub unsafe fn hertzUnitWithMetricPrefix(prefix: HKMetricPrefix) -> Retained<Self>;

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

/// ElectricPotentialDifference.
impl HKUnit {
    extern_methods!(
        #[unsafe(method(voltUnitWithMetricPrefix:))]
        #[unsafe(method_family = none)]
        pub unsafe fn voltUnitWithMetricPrefix(prefix: HKMetricPrefix) -> Retained<Self>;

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

/// Power.
impl HKUnit {
    extern_methods!(
        #[unsafe(method(wattUnitWithMetricPrefix:))]
        #[unsafe(method_family = none)]
        pub unsafe fn wattUnitWithMetricPrefix(prefix: HKMetricPrefix) -> Retained<Self>;

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

/// OpticalPower.
impl HKUnit {
    extern_methods!(
        #[unsafe(method(diopterUnit))]
        #[unsafe(method_family = none)]
        pub unsafe fn diopterUnit() -> Retained<Self>;

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

/// Angle.
impl HKUnit {
    extern_methods!(
        #[unsafe(method(radianAngleUnitWithMetricPrefix:))]
        #[unsafe(method_family = none)]
        pub unsafe fn radianAngleUnitWithMetricPrefix(prefix: HKMetricPrefix) -> Retained<Self>;

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

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

/// Illuminance.
impl HKUnit {
    extern_methods!(
        #[unsafe(method(luxUnitWithMetricPrefix:))]
        #[unsafe(method_family = none)]
        pub unsafe fn luxUnitWithMetricPrefix(prefix: HKMetricPrefix) -> Retained<Self>;

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

/// UnitLess.
impl HKUnit {
    extern_methods!(
        #[unsafe(method(appleEffortScoreUnit))]
        #[unsafe(method_family = none)]
        pub unsafe fn appleEffortScoreUnit() -> Retained<Self>;
    );
}