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
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
//! 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::*;

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/healthkit/hkquery?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct HKQuery;
);

unsafe impl Send for HKQuery {}

unsafe impl Sync for HKQuery {}

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

impl HKQuery {
    extern_methods!(
        #[cfg(feature = "HKObjectType")]
        #[unsafe(method(objectType))]
        #[unsafe(method_family = none)]
        pub unsafe fn objectType(&self) -> Option<Retained<HKObjectType>>;

        #[cfg(feature = "HKObjectType")]
        #[deprecated]
        #[unsafe(method(sampleType))]
        #[unsafe(method_family = none)]
        pub unsafe fn sampleType(&self) -> Option<Retained<HKSampleType>>;

        #[unsafe(method(predicate))]
        #[unsafe(method_family = none)]
        pub unsafe fn predicate(&self) -> Option<Retained<NSPredicate>>;

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

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

/// Time interval options are used to describe how an HKSample's time period overlaps with a given time period.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/healthkit/hkqueryoptions?language=objc)
// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct HKQueryOptions(pub NSUInteger);
bitflags::bitflags! {
    impl HKQueryOptions: NSUInteger {
        #[doc(alias = "HKQueryOptionNone")]
        const None = 0;
        #[doc(alias = "HKQueryOptionStrictStartDate")]
        const StrictStartDate = 1<<0;
        #[doc(alias = "HKQueryOptionStrictEndDate")]
        const StrictEndDate = 1<<1;
    }
}

unsafe impl Encode for HKQueryOptions {
    const ENCODING: Encoding = NSUInteger::ENCODING;
}

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

/// HKObjectPredicates.
impl HKQuery {
    extern_methods!(
        /// Creates a predicate for use with HKQuery subclasses.
        ///
        /// Creates a query predicate that matches objects with metadata that contains a given key.
        ///
        ///
        /// Parameter `key`: The metadata key.
        #[unsafe(method(predicateForObjectsWithMetadataKey:))]
        #[unsafe(method_family = none)]
        pub unsafe fn predicateForObjectsWithMetadataKey(key: &NSString) -> Retained<NSPredicate>;

        /// Creates a predicate for use with HKQuery subclasses
        ///
        /// Creates a query predicate that matches objects with metadata containing a value the matches one of the
        /// given values for the given key.
        ///
        ///
        /// Parameter `key`: The metadata key.
        ///
        /// Parameter `allowedValues`: The list of values that the metadata value can be equal to.
        ///
        /// # Safety
        ///
        /// `allowed_values` generic should be of the correct type.
        #[unsafe(method(predicateForObjectsWithMetadataKey:allowedValues:))]
        #[unsafe(method_family = none)]
        pub unsafe fn predicateForObjectsWithMetadataKey_allowedValues(
            key: &NSString,
            allowed_values: &NSArray,
        ) -> Retained<NSPredicate>;

        /// Creates a predicate for use with HKQuery subclasses
        ///
        /// Creates a query predicate that matches objects with a value for a given metadata key matches the given
        /// operator type and value.
        ///
        ///
        /// Parameter `key`: The metadata key.
        ///
        /// Parameter `operatorType`: The comparison operator type for the expression.
        ///
        /// Parameter `value`: The value to be compared against.
        ///
        /// # Safety
        ///
        /// `value` should be of the correct type.
        #[unsafe(method(predicateForObjectsWithMetadataKey:operatorType:value:))]
        #[unsafe(method_family = none)]
        pub unsafe fn predicateForObjectsWithMetadataKey_operatorType_value(
            key: &NSString,
            operator_type: NSPredicateOperatorType,
            value: &AnyObject,
        ) -> Retained<NSPredicate>;

        #[cfg(feature = "HKSource")]
        /// Creates a predicate for use with HKQuery subclasses.
        ///
        /// Creates a query predicate that matches objects saved by a given source.
        ///
        ///
        /// Parameter `source`: The source.
        #[unsafe(method(predicateForObjectsFromSource:))]
        #[unsafe(method_family = none)]
        pub unsafe fn predicateForObjectsFromSource(source: &HKSource) -> Retained<NSPredicate>;

        #[cfg(feature = "HKSource")]
        /// Creates a predicate for use with HKQuery subclasses.
        ///
        /// Creates a query predicate that matches objects saved by any of the given sources.
        ///
        ///
        /// Parameter `sources`: The list of sources.
        #[unsafe(method(predicateForObjectsFromSources:))]
        #[unsafe(method_family = none)]
        pub unsafe fn predicateForObjectsFromSources(
            sources: &NSSet<HKSource>,
        ) -> Retained<NSPredicate>;

        #[cfg(feature = "HKSourceRevision")]
        /// Creates a predicate for use with HKQuery subclasses.
        ///
        /// Creates a query predicate that matches objects saved by any of the specified HKSourceRevisions.
        ///
        ///
        /// Parameter `sourceRevisions`: The list of source revisions.
        #[unsafe(method(predicateForObjectsFromSourceRevisions:))]
        #[unsafe(method_family = none)]
        pub unsafe fn predicateForObjectsFromSourceRevisions(
            source_revisions: &NSSet<HKSourceRevision>,
        ) -> Retained<NSPredicate>;

        #[cfg(feature = "HKDevice")]
        /// Creates a predicate for use with HKQuery subclasses.
        ///
        /// Creates a query predicate that matches objects associated with any of the given devices. All properties
        /// of each HKDevice are considered in the query and must match exactly, including nil values. To perform
        /// searches based on specific device properties, use predicateForObjectsWithDeviceProperty:allowedValues:.
        ///
        ///
        /// Parameter `devices`: The set of devices that generated data.
        #[unsafe(method(predicateForObjectsFromDevices:))]
        #[unsafe(method_family = none)]
        pub unsafe fn predicateForObjectsFromDevices(
            devices: &NSSet<HKDevice>,
        ) -> Retained<NSPredicate>;

        /// Creates a predicate for use with HKQuery subclasses.
        ///
        /// Creates a query predicate that matches objects associated with an HKDevice with the specified device
        /// property matching any value included in allowedValues. To query for samples with devices that match all
        /// the properties of an HKDevice, use predicateForObjectsFromDevices.
        ///
        ///
        /// Parameter `key`: The device property key. (See HKDevice.h)
        ///
        /// Parameter `allowedValues`: The set of values for which the device property can match. An empty set will match all
        /// devices whose property value is nil.
        #[unsafe(method(predicateForObjectsWithDeviceProperty:allowedValues:))]
        #[unsafe(method_family = none)]
        pub unsafe fn predicateForObjectsWithDeviceProperty_allowedValues(
            key: &NSString,
            allowed_values: &NSSet<NSString>,
        ) -> Retained<NSPredicate>;

        /// Creates a predicate for use with HKQuery subclasses.
        ///
        /// Creates a query predicate that matches the object saved with a particular UUID.
        ///
        ///
        /// Parameter `UUID`: The UUID of the object.
        #[unsafe(method(predicateForObjectWithUUID:))]
        #[unsafe(method_family = none)]
        pub unsafe fn predicateForObjectWithUUID(uuid: &NSUUID) -> Retained<NSPredicate>;

        /// Creates a predicate for use with HKQuery subclasses.
        ///
        /// Creates a query predicate that matches the objects saved with one of the given UUIDs.
        ///
        ///
        /// Parameter `UUIDs`: The set of NSUUIDs.
        #[unsafe(method(predicateForObjectsWithUUIDs:))]
        #[unsafe(method_family = none)]
        pub unsafe fn predicateForObjectsWithUUIDs(uui_ds: &NSSet<NSUUID>)
            -> Retained<NSPredicate>;

        /// Creates a predicate for use with HKQuery subclasses.
        ///
        /// Creates a query predicate that matches the objects that are not associated with an HKCorrelation.
        #[unsafe(method(predicateForObjectsWithNoCorrelation))]
        #[unsafe(method_family = none)]
        pub unsafe fn predicateForObjectsWithNoCorrelation() -> Retained<NSPredicate>;

        #[cfg(all(feature = "HKObject", feature = "HKSample", feature = "HKWorkout"))]
        /// Creates a predicate for use with HKQuery subclasses.
        ///
        /// Creates a query predicate that matches the objects that have been added to the given workout.
        ///
        ///
        /// Parameter `workout`: The HKWorkout that the object was added to.
        #[unsafe(method(predicateForObjectsFromWorkout:))]
        #[unsafe(method_family = none)]
        pub unsafe fn predicateForObjectsFromWorkout(workout: &HKWorkout) -> Retained<NSPredicate>;

        #[cfg(all(
            feature = "HKElectrocardiogram",
            feature = "HKObject",
            feature = "HKSample"
        ))]
        /// Creates a predicate for use with HKQuery subclasses.
        ///
        /// Creates a query predicate that matches the objects that have been added to the given electrocardiogram
        ///
        ///
        /// Parameter `electrocardiogram`: The HKElectrocardiogram that the object was added to.
        #[unsafe(method(predicateForObjectsAssociatedWithElectrocardiogram:))]
        #[unsafe(method_family = none)]
        pub unsafe fn predicateForObjectsAssociatedWithElectrocardiogram(
            electrocardiogram: &HKElectrocardiogram,
        ) -> Retained<NSPredicate>;

        #[cfg(all(
            feature = "HKObject",
            feature = "HKSample",
            feature = "HKWorkout",
            feature = "HKWorkoutActivity"
        ))]
        /// Creates a predicate for use with HKQuery subclasses.
        ///
        /// Creates a query predicate that matches Workout Effort samples that have been related to the given workout
        ///
        ///
        /// Parameter `workout`: The HKWorkout that the object is related to.
        ///
        /// Parameter `activity`: The HKWorkoutActivity that the object is related to.
        #[unsafe(method(predicateForWorkoutEffortSamplesRelatedToWorkout:activity:))]
        #[unsafe(method_family = none)]
        pub unsafe fn predicateForWorkoutEffortSamplesRelatedToWorkout_activity(
            workout: &HKWorkout,
            activity: Option<&HKWorkoutActivity>,
        ) -> Retained<NSPredicate>;
    );
}

/// HKSamplePredicates.
impl HKQuery {
    extern_methods!(
        /// Creates a predicate for use with HKQuery subclasses.
        ///
        /// Creates a query predicate that matches samples with a startDate and an endDate that lie inside of a
        /// given time interval.
        ///
        ///
        /// Parameter `startDate`: The start date of the predicate's time interval.
        ///
        /// Parameter `endDate`: The end date of the predicate's time interval.
        ///
        /// Parameter `options`: The rules for how a sample's time interval overlaps with the predicate's time interval.
        #[unsafe(method(predicateForSamplesWithStartDate:endDate:options:))]
        #[unsafe(method_family = none)]
        pub unsafe fn predicateForSamplesWithStartDate_endDate_options(
            start_date: Option<&NSDate>,
            end_date: Option<&NSDate>,
            options: HKQueryOptions,
        ) -> Retained<NSPredicate>;
    );
}

/// HKQuantitySamplePredicates.
impl HKQuery {
    extern_methods!(
        #[cfg(feature = "HKQuantity")]
        /// Creates a predicate for use with HKQuery subclasses.
        ///
        /// Creates a query predicate that matches quantity samples with values that match the expression formed by
        /// the given operator and quantity.
        ///
        ///
        /// Parameter `operatorType`: The operator type for the expression.
        ///
        /// Parameter `quantity`: The quantity that the sample's quantity is being compared to. It is the right hand side
        /// of the expression.
        #[unsafe(method(predicateForQuantitySamplesWithOperatorType:quantity:))]
        #[unsafe(method_family = none)]
        pub unsafe fn predicateForQuantitySamplesWithOperatorType_quantity(
            operator_type: NSPredicateOperatorType,
            quantity: &HKQuantity,
        ) -> Retained<NSPredicate>;
    );
}

/// HKCategorySamplePredicates.
impl HKQuery {
    extern_methods!(
        #[unsafe(method(predicateForCategorySamplesWithOperatorType:value:))]
        #[unsafe(method_family = none)]
        pub unsafe fn predicateForCategorySamplesWithOperatorType_value(
            operator_type: NSPredicateOperatorType,
            value: NSInteger,
        ) -> Retained<NSPredicate>;

        /// Creates a predicate for use with HKQuery subclasses.
        ///
        /// Creates a query predicate that matches all specified category values.
        #[unsafe(method(predicateForCategorySamplesEqualToValues:))]
        #[unsafe(method_family = none)]
        pub unsafe fn predicateForCategorySamplesEqualToValues(
            values: &NSSet<NSNumber>,
        ) -> Retained<NSPredicate>;
    );
}

/// HKWorkoutPredicates.
impl HKQuery {
    extern_methods!(
        #[cfg(feature = "HKWorkout")]
        /// Creates a predicate for use with HKQuery subclasses.
        ///
        /// Creates a query predicate that matches HKWorkouts with the given HKWorkoutActivityType.
        ///
        ///
        /// Parameter `workoutActivityType`: The HKWorkoutActivity type of the workout
        #[unsafe(method(predicateForWorkoutsWithWorkoutActivityType:))]
        #[unsafe(method_family = none)]
        pub unsafe fn predicateForWorkoutsWithWorkoutActivityType(
            workout_activity_type: HKWorkoutActivityType,
        ) -> Retained<NSPredicate>;

        /// Creates a predicate for use with HKQuery subclasses.
        ///
        /// Creates a query predicate that matches HKWorkouts by the given operator type and duration
        ///
        ///
        /// Parameter `operatorType`: The operator type for the expression.
        ///
        /// Parameter `duration`: The value that the workout's duration is being compared to. It is the right hand side of the
        /// expression.
        #[unsafe(method(predicateForWorkoutsWithOperatorType:duration:))]
        #[unsafe(method_family = none)]
        pub unsafe fn predicateForWorkoutsWithOperatorType_duration(
            operator_type: NSPredicateOperatorType,
            duration: NSTimeInterval,
        ) -> Retained<NSPredicate>;

        #[cfg(feature = "HKQuantity")]
        /// Creates a predicate for use with HKQuery subclasses.
        ///
        /// Creates a query predicate that matches HKWorkouts by the given operator type and totalEnergyBurned
        ///
        ///
        /// Parameter `operatorType`: The operator type for the expression.
        ///
        /// Parameter `totalEnergyBurned`: The value that the workout's totalEnergyBurned is being compared to. It is the right hand side of the
        /// expression. The unit for this value should be of type Energy.
        #[deprecated = "Use predicateForWorkoutsWithOperatorType:quantityType:sumQuantity: passing the HKQuantityType for HKQuantityTypeIdentifierActiveEnergyBurned"]
        #[unsafe(method(predicateForWorkoutsWithOperatorType:totalEnergyBurned:))]
        #[unsafe(method_family = none)]
        pub unsafe fn predicateForWorkoutsWithOperatorType_totalEnergyBurned(
            operator_type: NSPredicateOperatorType,
            total_energy_burned: &HKQuantity,
        ) -> Retained<NSPredicate>;

        #[cfg(feature = "HKQuantity")]
        /// Creates a predicate for use with HKQuery subclasses.
        ///
        /// Creates a query predicate that matches HKWorkouts by the given operator type and totalEnergyBurned
        ///
        ///
        /// Parameter `operatorType`: The operator type for the expression.
        ///
        /// Parameter `totalDistance`: The value that the workout's totalEnergyBurned is being compared to. It is the right hand side of the
        /// expression. The unit for this value should be of type Distance.
        #[deprecated = "Use predicateForWorkoutsWithOperatorType:quantityType:sumQuantity: passing the HKQuantityType for the desired distance type"]
        #[unsafe(method(predicateForWorkoutsWithOperatorType:totalDistance:))]
        #[unsafe(method_family = none)]
        pub unsafe fn predicateForWorkoutsWithOperatorType_totalDistance(
            operator_type: NSPredicateOperatorType,
            total_distance: &HKQuantity,
        ) -> Retained<NSPredicate>;

        #[cfg(feature = "HKQuantity")]
        /// Creates a predicate for use with HKQuery subclasses.
        ///
        /// Creates a query predicate that matches HKWorkouts by the given operator type and totalSwimmingStrokeCount
        ///
        ///
        /// Parameter `operatorType`: The operator type for the expression.
        ///
        /// Parameter `totalSwimmingStrokeCount`: The value that the workout's totalSwimmingStrokeCount is being compared to.
        /// It is the right hand side of the expression. The unit for this value should
        /// be of type Count.
        #[deprecated = "Use predicateForWorkoutsWithOperatorType:quantityType:sumQuantity: passing the HKQuantityType for HKQuantityTypeIdentifierSwimmingStrokeCount"]
        #[unsafe(method(predicateForWorkoutsWithOperatorType:totalSwimmingStrokeCount:))]
        #[unsafe(method_family = none)]
        pub unsafe fn predicateForWorkoutsWithOperatorType_totalSwimmingStrokeCount(
            operator_type: NSPredicateOperatorType,
            total_swimming_stroke_count: &HKQuantity,
        ) -> Retained<NSPredicate>;

        #[cfg(feature = "HKQuantity")]
        /// Creates a predicate for use with HKQuery subclasses.
        ///
        /// Creates a query predicate that matches HKWorkouts by the given operator type and totalFlightsClimbed
        ///
        ///
        /// Parameter `operatorType`: The operator type for the expression.
        ///
        /// Parameter `totalFlightsClimbed`: The value that the workout's totalFlightsClimbed is being compared to.
        /// It is the right hand side of the expression. The unit for this value should
        /// be of type Count.
        #[deprecated = "Use predicateForWorkoutsWithOperatorType:quantityType:sumQuantity: passing the HKQuantityType for HKQuantityTypeIdentifierFlightsClimbed"]
        #[unsafe(method(predicateForWorkoutsWithOperatorType:totalFlightsClimbed:))]
        #[unsafe(method_family = none)]
        pub unsafe fn predicateForWorkoutsWithOperatorType_totalFlightsClimbed(
            operator_type: NSPredicateOperatorType,
            total_flights_climbed: &HKQuantity,
        ) -> Retained<NSPredicate>;

        #[cfg(all(feature = "HKObjectType", feature = "HKQuantity"))]
        /// Creates a predicate for use with HKQuery subclasses.
        ///
        /// Creates a query predicate that matches HKWorkouts by the given operator type and sumQuantity in the statistics for
        /// the specified type.
        ///
        ///
        /// Parameter `operatorType`: The operator type for the expression.
        ///
        /// Parameter `quantityType`: The quantity type to compare statistics for. Should be a cumulative quantity type.
        ///
        /// Parameter `sumQuantity`: The sum value that the workout statistics are being compared to. The unit for this value should
        /// match the allowed values for the quantityType.
        #[unsafe(method(predicateForWorkoutsWithOperatorType:quantityType:sumQuantity:))]
        #[unsafe(method_family = none)]
        pub unsafe fn predicateForWorkoutsWithOperatorType_quantityType_sumQuantity(
            operator_type: NSPredicateOperatorType,
            quantity_type: &HKQuantityType,
            sum_quantity: &HKQuantity,
        ) -> Retained<NSPredicate>;

        #[cfg(all(feature = "HKObjectType", feature = "HKQuantity"))]
        /// Creates a predicate for use with HKQuery subclasses.
        ///
        /// Creates a query predicate that matches HKWorkouts by the given operator type and minimumQuantity in the statistics
        /// for the specified type.
        ///
        ///
        /// Parameter `operatorType`: The operator type for the expression.
        ///
        /// Parameter `quantityType`: The quantity type to compare statistics for. Should be a discrete quantity type.
        ///
        /// Parameter `minimumQuantity`: The minumum value that the workout statistics are being compared to. The unit for this value should
        /// match the allowed values for the quantityType.
        #[unsafe(method(predicateForWorkoutsWithOperatorType:quantityType:minimumQuantity:))]
        #[unsafe(method_family = none)]
        pub unsafe fn predicateForWorkoutsWithOperatorType_quantityType_minimumQuantity(
            operator_type: NSPredicateOperatorType,
            quantity_type: &HKQuantityType,
            minimum_quantity: &HKQuantity,
        ) -> Retained<NSPredicate>;

        #[cfg(all(feature = "HKObjectType", feature = "HKQuantity"))]
        /// Creates a predicate for use with HKQuery subclasses.
        ///
        /// Creates a query predicate that matches HKWorkouts by the given operator type and maximumQuantity in the statistics
        /// for the specified type.
        ///
        ///
        /// Parameter `operatorType`: The operator type for the expression.
        ///
        /// Parameter `quantityType`: The quantity type to compare statistics for. Should be a discrete quantity type.
        ///
        /// Parameter `maximumQuantity`: The maximum value that the workout statistics are being compared to. The unit for this value should
        /// match the allowed values for the quantityType.
        #[unsafe(method(predicateForWorkoutsWithOperatorType:quantityType:maximumQuantity:))]
        #[unsafe(method_family = none)]
        pub unsafe fn predicateForWorkoutsWithOperatorType_quantityType_maximumQuantity(
            operator_type: NSPredicateOperatorType,
            quantity_type: &HKQuantityType,
            maximum_quantity: &HKQuantity,
        ) -> Retained<NSPredicate>;

        #[cfg(all(feature = "HKObjectType", feature = "HKQuantity"))]
        /// Creates a predicate for use with HKQuery subclasses.
        ///
        /// Creates a query predicate that matches HKWorkouts by the given operator type and averageQuantity in the statistics
        /// for the specified type.
        ///
        ///
        /// Parameter `operatorType`: The operator type for the expression.
        ///
        /// Parameter `quantityType`: The quantity type to compare statistics for. Should be a discrete quantity type.
        ///
        /// Parameter `averageQuantity`: The average value that the workout statistics are being compared to. The unit for this value should
        /// match the allowed values for the quantityType.
        #[unsafe(method(predicateForWorkoutsWithOperatorType:quantityType:averageQuantity:))]
        #[unsafe(method_family = none)]
        pub unsafe fn predicateForWorkoutsWithOperatorType_quantityType_averageQuantity(
            operator_type: NSPredicateOperatorType,
            quantity_type: &HKQuantityType,
            average_quantity: &HKQuantity,
        ) -> Retained<NSPredicate>;
    );
}

/// HKWorkoutActivityPredicates.
impl HKQuery {
    extern_methods!(
        #[cfg(feature = "HKWorkout")]
        /// Creates a predicate for use with HKQuery subclasses.
        ///
        /// Creates a query predicate that matches HKWorkoutActivity objects with the given HKWorkoutActivityType.
        /// The resulting predicate should be wrapped using predicateForWorkoutsWithActivityPredicate: before being used in a query.
        ///
        ///
        /// Parameter `workoutActivityType`: The HKWorkoutActivity type of the workout
        #[unsafe(method(predicateForWorkoutActivitiesWithWorkoutActivityType:))]
        #[unsafe(method_family = none)]
        pub unsafe fn predicateForWorkoutActivitiesWithWorkoutActivityType(
            workout_activity_type: HKWorkoutActivityType,
        ) -> Retained<NSPredicate>;

        /// Creates a predicate for use with HKQuery subclasses.
        ///
        /// Creates a query predicate that matches HKWorkoutActivity objects by the given operator type and duration.
        /// The resulting predicate should be wrapped using predicateForWorkoutsWithActivityPredicate: before being used in a query.
        ///
        ///
        /// Parameter `operatorType`: The operator type for the expression.
        ///
        /// Parameter `duration`: The value that the workout's duration is being compared to. It is the right hand side of the
        /// expression.
        #[unsafe(method(predicateForWorkoutActivitiesWithOperatorType:duration:))]
        #[unsafe(method_family = none)]
        pub unsafe fn predicateForWorkoutActivitiesWithOperatorType_duration(
            operator_type: NSPredicateOperatorType,
            duration: NSTimeInterval,
        ) -> Retained<NSPredicate>;

        /// Creates a predicate for use with HKQuery subclasses.
        ///
        /// Creates a query predicate that matches HKWorkoutActivity objects with a startDate and an endDate that lie inside of a
        /// given time interval. The resulting predicate should be wrapped using predicateForWorkoutsWithActivityPredicate:
        /// before being used in a query.
        ///
        ///
        /// Parameter `startDate`: The start date of the predicate's time interval.
        ///
        /// Parameter `endDate`: The end date of the predicate's time interval.
        ///
        /// Parameter `options`: The rules for how a activity's time interval overlaps with the predicate's time interval.
        #[unsafe(method(predicateForWorkoutActivitiesWithStartDate:endDate:options:))]
        #[unsafe(method_family = none)]
        pub unsafe fn predicateForWorkoutActivitiesWithStartDate_endDate_options(
            start_date: Option<&NSDate>,
            end_date: Option<&NSDate>,
            options: HKQueryOptions,
        ) -> Retained<NSPredicate>;

        #[cfg(all(feature = "HKObjectType", feature = "HKQuantity"))]
        /// Creates a predicate for use with HKQuery subclasses.
        ///
        /// Creates a query predicate that matches HKWorkoutActivity objetcs by the given operator type and sumQuantity in the
        /// statistics for the specified type. The resulting predicate should be wrapped using predicateForWorkoutsWithActivityPredicate:
        /// before being used in a query.
        ///
        ///
        /// Parameter `operatorType`: The operator type for the expression.
        ///
        /// Parameter `quantityType`: The quantity type to compare statistics for. Should be a cumulative quantity type.
        ///
        /// Parameter `sumQuantity`: The sum value that the activity statistics are being compared to. The unit for this value should
        /// match the allowed values for the quantityType.
        #[unsafe(method(predicateForWorkoutActivitiesWithOperatorType:quantityType:sumQuantity:))]
        #[unsafe(method_family = none)]
        pub unsafe fn predicateForWorkoutActivitiesWithOperatorType_quantityType_sumQuantity(
            operator_type: NSPredicateOperatorType,
            quantity_type: &HKQuantityType,
            sum_quantity: &HKQuantity,
        ) -> Retained<NSPredicate>;

        #[cfg(all(feature = "HKObjectType", feature = "HKQuantity"))]
        /// Creates a predicate for use with HKQuery subclasses.
        ///
        /// Creates a query predicate that matches HKWorkoutActivity objetcs  by the given operator type and minimumQuantity in the
        /// statistics for the specified type. The resulting predicate should be wrapped using predicateForWorkoutsWithActivityPredicate:
        /// before being used in a query.
        ///
        ///
        /// Parameter `operatorType`: The operator type for the expression.
        ///
        /// Parameter `quantityType`: The quantity type to compare statistics for. Should be a discrete quantity type.
        ///
        /// Parameter `minimumQuantity`: The minumum value that the activty statistics are being compared to. The unit for this value should
        /// match the allowed values for the quantityType.
        #[unsafe(method(predicateForWorkoutActivitiesWithOperatorType:quantityType:minimumQuantity:))]
        #[unsafe(method_family = none)]
        pub unsafe fn predicateForWorkoutActivitiesWithOperatorType_quantityType_minimumQuantity(
            operator_type: NSPredicateOperatorType,
            quantity_type: &HKQuantityType,
            minimum_quantity: &HKQuantity,
        ) -> Retained<NSPredicate>;

        #[cfg(all(feature = "HKObjectType", feature = "HKQuantity"))]
        /// Creates a predicate for use with HKQuery subclasses.
        ///
        /// Creates a query predicate that matches HKWorkoutActivity objetcs by the given operator type and maximumQuantity in the
        /// statistics for the specified type. The resulting predicate should be wrapped using predicateForWorkoutsWithActivityPredicate:
        /// before being used in a query.
        ///
        ///
        /// Parameter `operatorType`: The operator type for the expression.
        ///
        /// Parameter `quantityType`: The quantity type to compare statistics for. Should be a discrete quantity type.
        ///
        /// Parameter `maximumQuantity`: The maximum value that the activity statistics are being compared to. The unit for this value should
        /// match the allowed values for the quantityType.
        #[unsafe(method(predicateForWorkoutActivitiesWithOperatorType:quantityType:maximumQuantity:))]
        #[unsafe(method_family = none)]
        pub unsafe fn predicateForWorkoutActivitiesWithOperatorType_quantityType_maximumQuantity(
            operator_type: NSPredicateOperatorType,
            quantity_type: &HKQuantityType,
            maximum_quantity: &HKQuantity,
        ) -> Retained<NSPredicate>;

        #[cfg(all(feature = "HKObjectType", feature = "HKQuantity"))]
        /// Creates a predicate for use with HKQuery subclasses.
        ///
        /// Creates a query predicate that matches HKWorkoutActivity objetcs by the given operator type and averageQuantity in the
        /// statistics for the specified type. The resulting predicate should be wrapped using predicateForWorkoutsWithActivityPredicate:
        /// before being used in a query.
        ///
        ///
        /// Parameter `operatorType`: The operator type for the expression.
        ///
        /// Parameter `quantityType`: The quantity type to compare statistics for. Should be a discrete quantity type.
        ///
        /// Parameter `averageQuantity`: The average value that the activity statistics are being compared to. The unit for this value should
        /// match the allowed values for the quantityType.
        #[unsafe(method(predicateForWorkoutActivitiesWithOperatorType:quantityType:averageQuantity:))]
        #[unsafe(method_family = none)]
        pub unsafe fn predicateForWorkoutActivitiesWithOperatorType_quantityType_averageQuantity(
            operator_type: NSPredicateOperatorType,
            quantity_type: &HKQuantityType,
            average_quantity: &HKQuantity,
        ) -> Retained<NSPredicate>;

        /// Creates a predicate for use with HKQuery subclasses.
        ///
        /// Creates a query predicate that matches workouts containing an activity matching the passed predicate.
        ///
        ///
        /// Parameter `activityPredicate`: The predicate on the activities of the workout
        #[unsafe(method(predicateForWorkoutsWithActivityPredicate:))]
        #[unsafe(method_family = none)]
        pub unsafe fn predicateForWorkoutsWithActivityPredicate(
            activity_predicate: &NSPredicate,
        ) -> Retained<NSPredicate>;
    );
}

/// HKActivitySummaryPredicates.
impl HKQuery {
    extern_methods!(
        /// Creates a predicate for use with HKActivitySummaryQuery
        ///
        /// Creates a query predicate that matches HKActivitySummaries with the given date components.
        ///
        ///
        /// Parameter `dateComponents`: The date components of the activity summary. These date components should contain era, year, month,
        /// and day components in the gregorian calendar.
        #[unsafe(method(predicateForActivitySummaryWithDateComponents:))]
        #[unsafe(method_family = none)]
        pub unsafe fn predicateForActivitySummaryWithDateComponents(
            date_components: &NSDateComponents,
        ) -> Retained<NSPredicate>;

        /// Creates a predicate for use with HKActivitySummaryQuery
        ///
        /// Creates a query predicate that matches HKActivitySummaries that fall between the given date components.
        ///
        ///
        /// Parameter `startDateComponents`: The date components that define the beginning of the range. These date components should contain
        /// era, year, month, and day components in the gregorian calendar.
        ///
        ///
        /// Parameter `endDateComponents`: The date components that define the end of the range. These date components should contain era,
        /// year, month, and day components in the gregorian calendar.
        #[unsafe(method(predicateForActivitySummariesBetweenStartDateComponents:endDateComponents:))]
        #[unsafe(method_family = none)]
        pub unsafe fn predicateForActivitySummariesBetweenStartDateComponents_endDateComponents(
            start_date_components: &NSDateComponents,
            end_date_components: &NSDateComponents,
        ) -> Retained<NSPredicate>;
    );
}

/// HKClinicalRecordPredicates.
impl HKQuery {
    extern_methods!(
        #[cfg(feature = "HKFHIRResource")]
        /// Creates a predicate for use with HKQuery subclasses.
        ///
        /// Creates a query predicate that matches HKClinicalRecords with a specific FHIR resource type.
        ///
        ///
        /// Parameter `resourceType`: The FHIR resource type.
        #[unsafe(method(predicateForClinicalRecordsWithFHIRResourceType:))]
        #[unsafe(method_family = none)]
        pub unsafe fn predicateForClinicalRecordsWithFHIRResourceType(
            resource_type: &HKFHIRResourceType,
        ) -> Retained<NSPredicate>;

        #[cfg(all(feature = "HKFHIRResource", feature = "HKSource"))]
        /// Creates a predicate for use with HKQuery subclasses.
        ///
        /// Creates a query predicate that matches HKClinicalRecords for a given source, FHIR resource type, and FHIR identifier.
        ///
        ///
        /// Parameter `source`: The source.
        ///
        /// Parameter `resourceType`: The FHIR resource type.
        ///
        /// Parameter `identifier`: The FHIR identifier.
        #[unsafe(method(predicateForClinicalRecordsFromSource:FHIRResourceType:identifier:))]
        #[unsafe(method_family = none)]
        pub unsafe fn predicateForClinicalRecordsFromSource_FHIRResourceType_identifier(
            source: &HKSource,
            resource_type: &HKFHIRResourceType,
            identifier: &NSString,
        ) -> Retained<NSPredicate>;
    );
}

/// HKElectrocardiogramPredicates.
impl HKQuery {
    extern_methods!(
        #[cfg(feature = "HKElectrocardiogram")]
        /// Creates a predicate for use with HKQuery subclasses.
        ///
        /// Creates a query predicate that matches HKElectrocardiograms with a specific classification.
        ///
        ///
        /// Parameter `classification`: The classification for the electrocardiogram.
        #[unsafe(method(predicateForElectrocardiogramsWithClassification:))]
        #[unsafe(method_family = none)]
        pub unsafe fn predicateForElectrocardiogramsWithClassification(
            classification: HKElectrocardiogramClassification,
        ) -> Retained<NSPredicate>;

        #[cfg(feature = "HKElectrocardiogram")]
        /// Creates a predicate for use with HKQuery subclasses.
        ///
        /// Creates a query predicate that matches HKElectrocardiograms with a specificied symptoms status.
        ///
        ///
        /// Parameter `symptomsStatus`: The symptoms status for the electrocardiogram.
        #[unsafe(method(predicateForElectrocardiogramsWithSymptomsStatus:))]
        #[unsafe(method_family = none)]
        pub unsafe fn predicateForElectrocardiogramsWithSymptomsStatus(
            symptoms_status: HKElectrocardiogramSymptomsStatus,
        ) -> Retained<NSPredicate>;
    );
}

/// HKVerifiableClinicalRecordPredicates.
impl HKQuery {
    extern_methods!(
        /// Creates a predicate for use with HKQuery subclasses.
        ///
        /// Creates a predicate that matches HKVerifiableClinicalRecords with a relevant date within a date interval.
        ///
        ///
        /// Parameter `dateInterval`: The date interval that the record's relevant date is in.
        #[unsafe(method(predicateForVerifiableClinicalRecordsWithRelevantDateWithinDateInterval:))]
        #[unsafe(method_family = none)]
        pub unsafe fn predicateForVerifiableClinicalRecordsWithRelevantDateWithinDateInterval(
            date_interval: &NSDateInterval,
        ) -> Retained<NSPredicate>;
    );
}

/// HKStateOfMind.
impl HKQuery {
    extern_methods!(
        /// Creates a predicate for use with HKStateOfMind
        ///
        /// Creates a query predicate that matches HKStateOfMind samples that have a valence property matching the operator type and valence.
        ///
        ///
        /// Parameter `valence`: The value to be compared against.
        ///
        /// Parameter `operatorType`: The comparison operator type for the expression.
        #[unsafe(method(predicateForStatesOfMindWithValence:operatorType:))]
        #[unsafe(method_family = none)]
        pub unsafe fn predicateForStatesOfMindWithValence_operatorType(
            valence: c_double,
            operator_type: NSPredicateOperatorType,
        ) -> Retained<NSPredicate>;

        #[cfg(feature = "HKStateOfMind")]
        /// Creates a predicate for use with HKStateOfMind
        ///
        /// Creates a query predicate that matches HKStateOfMind samples that have the specified kind of feeling type.
        ///
        ///
        /// Parameter `kind`: The kind of feeling type to be compared against.
        #[unsafe(method(predicateForStatesOfMindWithKind:))]
        #[unsafe(method_family = none)]
        pub unsafe fn predicateForStatesOfMindWithKind(
            kind: HKStateOfMindKind,
        ) -> Retained<NSPredicate>;

        #[cfg(feature = "HKStateOfMind")]
        /// Creates a predicate for use with HKStateOfMind
        ///
        /// Creates a query predicate that matches HKStateOfMind samples that have the specified label.
        ///
        ///
        /// Parameter `label`: The label to be compared against.
        #[unsafe(method(predicateForStatesOfMindWithLabel:))]
        #[unsafe(method_family = none)]
        pub unsafe fn predicateForStatesOfMindWithLabel(
            label: HKStateOfMindLabel,
        ) -> Retained<NSPredicate>;

        #[cfg(feature = "HKStateOfMind")]
        /// Creates a predicate for use with HKStateOfMind
        ///
        /// Creates a query predicate that matches HKStateOfMind samples that have the specified association.
        ///
        ///
        /// Parameter `association`: The association to be compared against.
        #[unsafe(method(predicateForStatesOfMindWithAssociation:))]
        #[unsafe(method_family = none)]
        pub unsafe fn predicateForStatesOfMindWithAssociation(
            association: HKStateOfMindAssociation,
        ) -> Retained<NSPredicate>;
    );
}

/// HKMedicationDoseEvent.
impl HKQuery {
    extern_methods!(
        #[cfg(feature = "HKMedicationDoseEvent")]
        /// Creates a predicate for use with HKQuery subclasses.
        ///
        /// Creates a query predicate that matches HKMedicationDoseEvent samples that have the status specified.
        ///
        ///
        /// Parameter `status`: The logged status of the medication dose event to match.
        #[unsafe(method(predicateForMedicationDoseEventWithStatus:))]
        #[unsafe(method_family = none)]
        pub unsafe fn predicateForMedicationDoseEventWithStatus(
            status: HKMedicationDoseEventLogStatus,
        ) -> Retained<NSPredicate>;

        /// Creates a predicate for use with HKQuery subclasses.
        ///
        /// Creates a query predicate that matches HKMedicationDoseEvent samples that have any of the statuses specified.
        ///
        ///
        /// Parameter `statuses`: The logged statuses of the medication dose event to match.
        #[unsafe(method(predicateForMedicationDoseEventWithStatuses:))]
        #[unsafe(method_family = none)]
        pub unsafe fn predicateForMedicationDoseEventWithStatuses(
            statuses: &NSSet<NSNumber>,
        ) -> Retained<NSPredicate>;

        /// Creates a predicate for use with HKQuery subclasses.
        ///
        /// Creates a query predicate that matches HKMedicationDoseEvent samples that have the exact scheduled date specified.
        ///
        ///
        /// Parameter `scheduledDate`: The exact scheduled date of the medication dose event to match.
        #[unsafe(method(predicateForMedicationDoseEventWithScheduledDate:))]
        #[unsafe(method_family = none)]
        pub unsafe fn predicateForMedicationDoseEventWithScheduledDate(
            scheduled_date: &NSDate,
        ) -> Retained<NSPredicate>;

        /// Creates a predicate for use with HKQuery subclasses.
        ///
        /// Creates a query predicate that matches HKMedicationDoseEvent samples that have any of the exact scheduled dates specified.
        ///
        ///
        /// Parameter `scheduledDates`: The exact scheduled dates of any medication dose event to match.
        #[unsafe(method(predicateForMedicationDoseEventWithScheduledDates:))]
        #[unsafe(method_family = none)]
        pub unsafe fn predicateForMedicationDoseEventWithScheduledDates(
            scheduled_dates: &NSSet<NSDate>,
        ) -> Retained<NSPredicate>;

        /// Creates a predicate for use with HKQuery subclasses.
        ///
        /// Creates a query predicate that matches HKMedicationDoseEvent samples that have a scheduled date within a window of scheduled times. If nil is provided to either parameter, the respective side of the window is unbound.
        ///
        ///
        /// Parameter `startDate`: The beginning of the window for scheduled dates of any medication dose event to match.
        ///
        /// Parameter `endDate`: The beginning of the window for scheduled dates of any medication dose event to match.
        #[unsafe(method(predicateForMedicationDoseEventWithScheduledStartDate:endDate:))]
        #[unsafe(method_family = none)]
        pub unsafe fn predicateForMedicationDoseEventWithScheduledStartDate_endDate(
            start_date: Option<&NSDate>,
            end_date: Option<&NSDate>,
        ) -> Retained<NSPredicate>;

        #[cfg(feature = "HKHealthConceptIdentifier")]
        /// Creates a predicate for use with HKQuery subclasses.
        ///
        /// Creates a query predicate that matches HKMedicationDoseEvent samples that match a medication's concept identifier.
        ///
        ///
        /// Parameter `medicationConceptIdentifier`: The identifier of the medication that a dose event was created for.
        #[unsafe(method(predicateForMedicationDoseEventWithMedicationConceptIdentifier:))]
        #[unsafe(method_family = none)]
        pub unsafe fn predicateForMedicationDoseEventWithMedicationConceptIdentifier(
            medication_concept_identifier: &HKHealthConceptIdentifier,
        ) -> Retained<NSPredicate>;

        #[cfg(feature = "HKHealthConceptIdentifier")]
        /// Creates a predicate for use with HKQuery subclasses.
        ///
        /// Creates a query predicate that matches HKMedicationDoseEvent samples generated by any medication in a set of medication concept identifiers.
        ///
        ///
        /// Parameter `medicationConceptIdentifiers`: Any identifier of a medication that a dose event was created for.
        #[unsafe(method(predicateForMedicationDoseEventWithMedicationConceptIdentifiers:))]
        #[unsafe(method_family = none)]
        pub unsafe fn predicateForMedicationDoseEventWithMedicationConceptIdentifiers(
            medication_concept_identifiers: &NSSet<HKHealthConceptIdentifier>,
        ) -> Retained<NSPredicate>;
    );
}

/// HKUserAnnotatedMedications.
impl HKQuery {
    extern_methods!(
        /// Creates a predicate for use with HKUserAnnotatedMedicationQuery.
        ///
        /// Creates a query predicate that matches HKUserAnnotatedMedication objects that have the archived status specified.
        ///
        ///
        /// Parameter `isArchived`: The archived status of the medication. Ex: True will match medications in the archived section in the Health App.
        #[unsafe(method(predicateForUserAnnotatedMedicationsWithIsArchived:))]
        #[unsafe(method_family = none)]
        pub unsafe fn predicateForUserAnnotatedMedicationsWithIsArchived(
            is_archived: bool,
        ) -> Retained<NSPredicate>;

        /// Creates a predicate for use with HKUserAnnotatedMedicationQuery.
        ///
        /// Creates a query predicate that matches HKUserAnnotatedMedication objects that match the schedule status specified.
        ///
        ///
        /// Parameter `hasSchedule`: The schedule status of the medication. Ex: True will match medications that have a reminders schedule set up in the Health App.
        #[unsafe(method(predicateForUserAnnotatedMedicationsWithHasSchedule:))]
        #[unsafe(method_family = none)]
        pub unsafe fn predicateForUserAnnotatedMedicationsWithHasSchedule(
            has_schedule: bool,
        ) -> Retained<NSPredicate>;
    );
}