objc2_health_kit/generated/
HKQuery.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10extern_class!(
11    /// [Apple's documentation](https://developer.apple.com/documentation/healthkit/hkquery?language=objc)
12    #[unsafe(super(NSObject))]
13    #[derive(Debug, PartialEq, Eq, Hash)]
14    pub struct HKQuery;
15);
16
17unsafe impl Send for HKQuery {}
18
19unsafe impl Sync for HKQuery {}
20
21extern_conformance!(
22    unsafe impl NSObjectProtocol for HKQuery {}
23);
24
25impl HKQuery {
26    extern_methods!(
27        #[cfg(feature = "HKObjectType")]
28        #[unsafe(method(objectType))]
29        #[unsafe(method_family = none)]
30        pub unsafe fn objectType(&self) -> Option<Retained<HKObjectType>>;
31
32        #[cfg(feature = "HKObjectType")]
33        #[deprecated]
34        #[unsafe(method(sampleType))]
35        #[unsafe(method_family = none)]
36        pub unsafe fn sampleType(&self) -> Option<Retained<HKSampleType>>;
37
38        #[unsafe(method(predicate))]
39        #[unsafe(method_family = none)]
40        pub unsafe fn predicate(&self) -> Option<Retained<NSPredicate>>;
41
42        #[unsafe(method(init))]
43        #[unsafe(method_family = init)]
44        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
45    );
46}
47
48/// Methods declared on superclass `NSObject`.
49impl HKQuery {
50    extern_methods!(
51        #[unsafe(method(new))]
52        #[unsafe(method_family = new)]
53        pub unsafe fn new() -> Retained<Self>;
54    );
55}
56
57/// Time interval options are used to describe how an HKSample's time period overlaps with a given time period.
58///
59/// See also [Apple's documentation](https://developer.apple.com/documentation/healthkit/hkqueryoptions?language=objc)
60// NS_OPTIONS
61#[repr(transparent)]
62#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
63pub struct HKQueryOptions(pub NSUInteger);
64bitflags::bitflags! {
65    impl HKQueryOptions: NSUInteger {
66        #[doc(alias = "HKQueryOptionNone")]
67        const None = 0;
68        #[doc(alias = "HKQueryOptionStrictStartDate")]
69        const StrictStartDate = 1<<0;
70        #[doc(alias = "HKQueryOptionStrictEndDate")]
71        const StrictEndDate = 1<<1;
72    }
73}
74
75unsafe impl Encode for HKQueryOptions {
76    const ENCODING: Encoding = NSUInteger::ENCODING;
77}
78
79unsafe impl RefEncode for HKQueryOptions {
80    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
81}
82
83/// HKObjectPredicates.
84impl HKQuery {
85    extern_methods!(
86        /// Creates a predicate for use with HKQuery subclasses.
87        ///
88        /// Creates a query predicate that matches objects with metadata that contains a given key.
89        ///
90        ///
91        /// Parameter `key`: The metadata key.
92        #[unsafe(method(predicateForObjectsWithMetadataKey:))]
93        #[unsafe(method_family = none)]
94        pub unsafe fn predicateForObjectsWithMetadataKey(key: &NSString) -> Retained<NSPredicate>;
95
96        /// Creates a predicate for use with HKQuery subclasses
97        ///
98        /// Creates a query predicate that matches objects with metadata containing a value the matches one of the
99        /// given values for the given key.
100        ///
101        ///
102        /// Parameter `key`: The metadata key.
103        ///
104        /// Parameter `allowedValues`: The list of values that the metadata value can be equal to.
105        ///
106        /// # Safety
107        ///
108        /// `allowed_values` generic should be of the correct type.
109        #[unsafe(method(predicateForObjectsWithMetadataKey:allowedValues:))]
110        #[unsafe(method_family = none)]
111        pub unsafe fn predicateForObjectsWithMetadataKey_allowedValues(
112            key: &NSString,
113            allowed_values: &NSArray,
114        ) -> Retained<NSPredicate>;
115
116        /// Creates a predicate for use with HKQuery subclasses
117        ///
118        /// Creates a query predicate that matches objects with a value for a given metadata key matches the given
119        /// operator type and value.
120        ///
121        ///
122        /// Parameter `key`: The metadata key.
123        ///
124        /// Parameter `operatorType`: The comparison operator type for the expression.
125        ///
126        /// Parameter `value`: The value to be compared against.
127        ///
128        /// # Safety
129        ///
130        /// `value` should be of the correct type.
131        #[unsafe(method(predicateForObjectsWithMetadataKey:operatorType:value:))]
132        #[unsafe(method_family = none)]
133        pub unsafe fn predicateForObjectsWithMetadataKey_operatorType_value(
134            key: &NSString,
135            operator_type: NSPredicateOperatorType,
136            value: &AnyObject,
137        ) -> Retained<NSPredicate>;
138
139        #[cfg(feature = "HKSource")]
140        /// Creates a predicate for use with HKQuery subclasses.
141        ///
142        /// Creates a query predicate that matches objects saved by a given source.
143        ///
144        ///
145        /// Parameter `source`: The source.
146        #[unsafe(method(predicateForObjectsFromSource:))]
147        #[unsafe(method_family = none)]
148        pub unsafe fn predicateForObjectsFromSource(source: &HKSource) -> Retained<NSPredicate>;
149
150        #[cfg(feature = "HKSource")]
151        /// Creates a predicate for use with HKQuery subclasses.
152        ///
153        /// Creates a query predicate that matches objects saved by any of the given sources.
154        ///
155        ///
156        /// Parameter `sources`: The list of sources.
157        #[unsafe(method(predicateForObjectsFromSources:))]
158        #[unsafe(method_family = none)]
159        pub unsafe fn predicateForObjectsFromSources(
160            sources: &NSSet<HKSource>,
161        ) -> Retained<NSPredicate>;
162
163        #[cfg(feature = "HKSourceRevision")]
164        /// Creates a predicate for use with HKQuery subclasses.
165        ///
166        /// Creates a query predicate that matches objects saved by any of the specified HKSourceRevisions.
167        ///
168        ///
169        /// Parameter `sourceRevisions`: The list of source revisions.
170        #[unsafe(method(predicateForObjectsFromSourceRevisions:))]
171        #[unsafe(method_family = none)]
172        pub unsafe fn predicateForObjectsFromSourceRevisions(
173            source_revisions: &NSSet<HKSourceRevision>,
174        ) -> Retained<NSPredicate>;
175
176        #[cfg(feature = "HKDevice")]
177        /// Creates a predicate for use with HKQuery subclasses.
178        ///
179        /// Creates a query predicate that matches objects associated with any of the given devices. All properties
180        /// of each HKDevice are considered in the query and must match exactly, including nil values. To perform
181        /// searches based on specific device properties, use predicateForObjectsWithDeviceProperty:allowedValues:.
182        ///
183        ///
184        /// Parameter `devices`: The set of devices that generated data.
185        #[unsafe(method(predicateForObjectsFromDevices:))]
186        #[unsafe(method_family = none)]
187        pub unsafe fn predicateForObjectsFromDevices(
188            devices: &NSSet<HKDevice>,
189        ) -> Retained<NSPredicate>;
190
191        /// Creates a predicate for use with HKQuery subclasses.
192        ///
193        /// Creates a query predicate that matches objects associated with an HKDevice with the specified device
194        /// property matching any value included in allowedValues. To query for samples with devices that match all
195        /// the properties of an HKDevice, use predicateForObjectsFromDevices.
196        ///
197        ///
198        /// Parameter `key`: The device property key. (See HKDevice.h)
199        ///
200        /// Parameter `allowedValues`: The set of values for which the device property can match. An empty set will match all
201        /// devices whose property value is nil.
202        #[unsafe(method(predicateForObjectsWithDeviceProperty:allowedValues:))]
203        #[unsafe(method_family = none)]
204        pub unsafe fn predicateForObjectsWithDeviceProperty_allowedValues(
205            key: &NSString,
206            allowed_values: &NSSet<NSString>,
207        ) -> Retained<NSPredicate>;
208
209        /// Creates a predicate for use with HKQuery subclasses.
210        ///
211        /// Creates a query predicate that matches the object saved with a particular UUID.
212        ///
213        ///
214        /// Parameter `UUID`: The UUID of the object.
215        #[unsafe(method(predicateForObjectWithUUID:))]
216        #[unsafe(method_family = none)]
217        pub unsafe fn predicateForObjectWithUUID(uuid: &NSUUID) -> Retained<NSPredicate>;
218
219        /// Creates a predicate for use with HKQuery subclasses.
220        ///
221        /// Creates a query predicate that matches the objects saved with one of the given UUIDs.
222        ///
223        ///
224        /// Parameter `UUIDs`: The set of NSUUIDs.
225        #[unsafe(method(predicateForObjectsWithUUIDs:))]
226        #[unsafe(method_family = none)]
227        pub unsafe fn predicateForObjectsWithUUIDs(uui_ds: &NSSet<NSUUID>)
228            -> Retained<NSPredicate>;
229
230        /// Creates a predicate for use with HKQuery subclasses.
231        ///
232        /// Creates a query predicate that matches the objects that are not associated with an HKCorrelation.
233        #[unsafe(method(predicateForObjectsWithNoCorrelation))]
234        #[unsafe(method_family = none)]
235        pub unsafe fn predicateForObjectsWithNoCorrelation() -> Retained<NSPredicate>;
236
237        #[cfg(all(feature = "HKObject", feature = "HKSample", feature = "HKWorkout"))]
238        /// Creates a predicate for use with HKQuery subclasses.
239        ///
240        /// Creates a query predicate that matches the objects that have been added to the given workout.
241        ///
242        ///
243        /// Parameter `workout`: The HKWorkout that the object was added to.
244        #[unsafe(method(predicateForObjectsFromWorkout:))]
245        #[unsafe(method_family = none)]
246        pub unsafe fn predicateForObjectsFromWorkout(workout: &HKWorkout) -> Retained<NSPredicate>;
247
248        #[cfg(all(
249            feature = "HKElectrocardiogram",
250            feature = "HKObject",
251            feature = "HKSample"
252        ))]
253        /// Creates a predicate for use with HKQuery subclasses.
254        ///
255        /// Creates a query predicate that matches the objects that have been added to the given electrocardiogram
256        ///
257        ///
258        /// Parameter `electrocardiogram`: The HKElectrocardiogram that the object was added to.
259        #[unsafe(method(predicateForObjectsAssociatedWithElectrocardiogram:))]
260        #[unsafe(method_family = none)]
261        pub unsafe fn predicateForObjectsAssociatedWithElectrocardiogram(
262            electrocardiogram: &HKElectrocardiogram,
263        ) -> Retained<NSPredicate>;
264
265        #[cfg(all(
266            feature = "HKObject",
267            feature = "HKSample",
268            feature = "HKWorkout",
269            feature = "HKWorkoutActivity"
270        ))]
271        /// Creates a predicate for use with HKQuery subclasses.
272        ///
273        /// Creates a query predicate that matches Workout Effort samples that have been related to the given workout
274        ///
275        ///
276        /// Parameter `workout`: The HKWorkout that the object is related to.
277        ///
278        /// Parameter `activity`: The HKWorkoutActivity that the object is related to.
279        #[unsafe(method(predicateForWorkoutEffortSamplesRelatedToWorkout:activity:))]
280        #[unsafe(method_family = none)]
281        pub unsafe fn predicateForWorkoutEffortSamplesRelatedToWorkout_activity(
282            workout: &HKWorkout,
283            activity: Option<&HKWorkoutActivity>,
284        ) -> Retained<NSPredicate>;
285    );
286}
287
288/// HKSamplePredicates.
289impl HKQuery {
290    extern_methods!(
291        /// Creates a predicate for use with HKQuery subclasses.
292        ///
293        /// Creates a query predicate that matches samples with a startDate and an endDate that lie inside of a
294        /// given time interval.
295        ///
296        ///
297        /// Parameter `startDate`: The start date of the predicate's time interval.
298        ///
299        /// Parameter `endDate`: The end date of the predicate's time interval.
300        ///
301        /// Parameter `options`: The rules for how a sample's time interval overlaps with the predicate's time interval.
302        #[unsafe(method(predicateForSamplesWithStartDate:endDate:options:))]
303        #[unsafe(method_family = none)]
304        pub unsafe fn predicateForSamplesWithStartDate_endDate_options(
305            start_date: Option<&NSDate>,
306            end_date: Option<&NSDate>,
307            options: HKQueryOptions,
308        ) -> Retained<NSPredicate>;
309    );
310}
311
312/// HKQuantitySamplePredicates.
313impl HKQuery {
314    extern_methods!(
315        #[cfg(feature = "HKQuantity")]
316        /// Creates a predicate for use with HKQuery subclasses.
317        ///
318        /// Creates a query predicate that matches quantity samples with values that match the expression formed by
319        /// the given operator and quantity.
320        ///
321        ///
322        /// Parameter `operatorType`: The operator type for the expression.
323        ///
324        /// Parameter `quantity`: The quantity that the sample's quantity is being compared to. It is the right hand side
325        /// of the expression.
326        #[unsafe(method(predicateForQuantitySamplesWithOperatorType:quantity:))]
327        #[unsafe(method_family = none)]
328        pub unsafe fn predicateForQuantitySamplesWithOperatorType_quantity(
329            operator_type: NSPredicateOperatorType,
330            quantity: &HKQuantity,
331        ) -> Retained<NSPredicate>;
332    );
333}
334
335/// HKCategorySamplePredicates.
336impl HKQuery {
337    extern_methods!(
338        #[unsafe(method(predicateForCategorySamplesWithOperatorType:value:))]
339        #[unsafe(method_family = none)]
340        pub unsafe fn predicateForCategorySamplesWithOperatorType_value(
341            operator_type: NSPredicateOperatorType,
342            value: NSInteger,
343        ) -> Retained<NSPredicate>;
344
345        /// Creates a predicate for use with HKQuery subclasses.
346        ///
347        /// Creates a query predicate that matches all specified category values.
348        #[unsafe(method(predicateForCategorySamplesEqualToValues:))]
349        #[unsafe(method_family = none)]
350        pub unsafe fn predicateForCategorySamplesEqualToValues(
351            values: &NSSet<NSNumber>,
352        ) -> Retained<NSPredicate>;
353    );
354}
355
356/// HKWorkoutPredicates.
357impl HKQuery {
358    extern_methods!(
359        #[cfg(feature = "HKWorkout")]
360        /// Creates a predicate for use with HKQuery subclasses.
361        ///
362        /// Creates a query predicate that matches HKWorkouts with the given HKWorkoutActivityType.
363        ///
364        ///
365        /// Parameter `workoutActivityType`: The HKWorkoutActivity type of the workout
366        #[unsafe(method(predicateForWorkoutsWithWorkoutActivityType:))]
367        #[unsafe(method_family = none)]
368        pub unsafe fn predicateForWorkoutsWithWorkoutActivityType(
369            workout_activity_type: HKWorkoutActivityType,
370        ) -> Retained<NSPredicate>;
371
372        /// Creates a predicate for use with HKQuery subclasses.
373        ///
374        /// Creates a query predicate that matches HKWorkouts by the given operator type and duration
375        ///
376        ///
377        /// Parameter `operatorType`: The operator type for the expression.
378        ///
379        /// Parameter `duration`: The value that the workout's duration is being compared to. It is the right hand side of the
380        /// expression.
381        #[unsafe(method(predicateForWorkoutsWithOperatorType:duration:))]
382        #[unsafe(method_family = none)]
383        pub unsafe fn predicateForWorkoutsWithOperatorType_duration(
384            operator_type: NSPredicateOperatorType,
385            duration: NSTimeInterval,
386        ) -> Retained<NSPredicate>;
387
388        #[cfg(feature = "HKQuantity")]
389        /// Creates a predicate for use with HKQuery subclasses.
390        ///
391        /// Creates a query predicate that matches HKWorkouts by the given operator type and totalEnergyBurned
392        ///
393        ///
394        /// Parameter `operatorType`: The operator type for the expression.
395        ///
396        /// Parameter `totalEnergyBurned`: The value that the workout's totalEnergyBurned is being compared to. It is the right hand side of the
397        /// expression. The unit for this value should be of type Energy.
398        #[deprecated = "Use predicateForWorkoutsWithOperatorType:quantityType:sumQuantity: passing the HKQuantityType for HKQuantityTypeIdentifierActiveEnergyBurned"]
399        #[unsafe(method(predicateForWorkoutsWithOperatorType:totalEnergyBurned:))]
400        #[unsafe(method_family = none)]
401        pub unsafe fn predicateForWorkoutsWithOperatorType_totalEnergyBurned(
402            operator_type: NSPredicateOperatorType,
403            total_energy_burned: &HKQuantity,
404        ) -> Retained<NSPredicate>;
405
406        #[cfg(feature = "HKQuantity")]
407        /// Creates a predicate for use with HKQuery subclasses.
408        ///
409        /// Creates a query predicate that matches HKWorkouts by the given operator type and totalEnergyBurned
410        ///
411        ///
412        /// Parameter `operatorType`: The operator type for the expression.
413        ///
414        /// Parameter `totalDistance`: The value that the workout's totalEnergyBurned is being compared to. It is the right hand side of the
415        /// expression. The unit for this value should be of type Distance.
416        #[deprecated = "Use predicateForWorkoutsWithOperatorType:quantityType:sumQuantity: passing the HKQuantityType for the desired distance type"]
417        #[unsafe(method(predicateForWorkoutsWithOperatorType:totalDistance:))]
418        #[unsafe(method_family = none)]
419        pub unsafe fn predicateForWorkoutsWithOperatorType_totalDistance(
420            operator_type: NSPredicateOperatorType,
421            total_distance: &HKQuantity,
422        ) -> Retained<NSPredicate>;
423
424        #[cfg(feature = "HKQuantity")]
425        /// Creates a predicate for use with HKQuery subclasses.
426        ///
427        /// Creates a query predicate that matches HKWorkouts by the given operator type and totalSwimmingStrokeCount
428        ///
429        ///
430        /// Parameter `operatorType`: The operator type for the expression.
431        ///
432        /// Parameter `totalSwimmingStrokeCount`: The value that the workout's totalSwimmingStrokeCount is being compared to.
433        /// It is the right hand side of the expression. The unit for this value should
434        /// be of type Count.
435        #[deprecated = "Use predicateForWorkoutsWithOperatorType:quantityType:sumQuantity: passing the HKQuantityType for HKQuantityTypeIdentifierSwimmingStrokeCount"]
436        #[unsafe(method(predicateForWorkoutsWithOperatorType:totalSwimmingStrokeCount:))]
437        #[unsafe(method_family = none)]
438        pub unsafe fn predicateForWorkoutsWithOperatorType_totalSwimmingStrokeCount(
439            operator_type: NSPredicateOperatorType,
440            total_swimming_stroke_count: &HKQuantity,
441        ) -> Retained<NSPredicate>;
442
443        #[cfg(feature = "HKQuantity")]
444        /// Creates a predicate for use with HKQuery subclasses.
445        ///
446        /// Creates a query predicate that matches HKWorkouts by the given operator type and totalFlightsClimbed
447        ///
448        ///
449        /// Parameter `operatorType`: The operator type for the expression.
450        ///
451        /// Parameter `totalFlightsClimbed`: The value that the workout's totalFlightsClimbed is being compared to.
452        /// It is the right hand side of the expression. The unit for this value should
453        /// be of type Count.
454        #[deprecated = "Use predicateForWorkoutsWithOperatorType:quantityType:sumQuantity: passing the HKQuantityType for HKQuantityTypeIdentifierFlightsClimbed"]
455        #[unsafe(method(predicateForWorkoutsWithOperatorType:totalFlightsClimbed:))]
456        #[unsafe(method_family = none)]
457        pub unsafe fn predicateForWorkoutsWithOperatorType_totalFlightsClimbed(
458            operator_type: NSPredicateOperatorType,
459            total_flights_climbed: &HKQuantity,
460        ) -> Retained<NSPredicate>;
461
462        #[cfg(all(feature = "HKObjectType", feature = "HKQuantity"))]
463        /// Creates a predicate for use with HKQuery subclasses.
464        ///
465        /// Creates a query predicate that matches HKWorkouts by the given operator type and sumQuantity in the statistics for
466        /// the specified type.
467        ///
468        ///
469        /// Parameter `operatorType`: The operator type for the expression.
470        ///
471        /// Parameter `quantityType`: The quantity type to compare statistics for. Should be a cumulative quantity type.
472        ///
473        /// Parameter `sumQuantity`: The sum value that the workout statistics are being compared to. The unit for this value should
474        /// match the allowed values for the quantityType.
475        #[unsafe(method(predicateForWorkoutsWithOperatorType:quantityType:sumQuantity:))]
476        #[unsafe(method_family = none)]
477        pub unsafe fn predicateForWorkoutsWithOperatorType_quantityType_sumQuantity(
478            operator_type: NSPredicateOperatorType,
479            quantity_type: &HKQuantityType,
480            sum_quantity: &HKQuantity,
481        ) -> Retained<NSPredicate>;
482
483        #[cfg(all(feature = "HKObjectType", feature = "HKQuantity"))]
484        /// Creates a predicate for use with HKQuery subclasses.
485        ///
486        /// Creates a query predicate that matches HKWorkouts by the given operator type and minimumQuantity in the statistics
487        /// for the specified type.
488        ///
489        ///
490        /// Parameter `operatorType`: The operator type for the expression.
491        ///
492        /// Parameter `quantityType`: The quantity type to compare statistics for. Should be a discrete quantity type.
493        ///
494        /// Parameter `minimumQuantity`: The minumum value that the workout statistics are being compared to. The unit for this value should
495        /// match the allowed values for the quantityType.
496        #[unsafe(method(predicateForWorkoutsWithOperatorType:quantityType:minimumQuantity:))]
497        #[unsafe(method_family = none)]
498        pub unsafe fn predicateForWorkoutsWithOperatorType_quantityType_minimumQuantity(
499            operator_type: NSPredicateOperatorType,
500            quantity_type: &HKQuantityType,
501            minimum_quantity: &HKQuantity,
502        ) -> Retained<NSPredicate>;
503
504        #[cfg(all(feature = "HKObjectType", feature = "HKQuantity"))]
505        /// Creates a predicate for use with HKQuery subclasses.
506        ///
507        /// Creates a query predicate that matches HKWorkouts by the given operator type and maximumQuantity in the statistics
508        /// for the specified type.
509        ///
510        ///
511        /// Parameter `operatorType`: The operator type for the expression.
512        ///
513        /// Parameter `quantityType`: The quantity type to compare statistics for. Should be a discrete quantity type.
514        ///
515        /// Parameter `maximumQuantity`: The maximum value that the workout statistics are being compared to. The unit for this value should
516        /// match the allowed values for the quantityType.
517        #[unsafe(method(predicateForWorkoutsWithOperatorType:quantityType:maximumQuantity:))]
518        #[unsafe(method_family = none)]
519        pub unsafe fn predicateForWorkoutsWithOperatorType_quantityType_maximumQuantity(
520            operator_type: NSPredicateOperatorType,
521            quantity_type: &HKQuantityType,
522            maximum_quantity: &HKQuantity,
523        ) -> Retained<NSPredicate>;
524
525        #[cfg(all(feature = "HKObjectType", feature = "HKQuantity"))]
526        /// Creates a predicate for use with HKQuery subclasses.
527        ///
528        /// Creates a query predicate that matches HKWorkouts by the given operator type and averageQuantity in the statistics
529        /// for the specified type.
530        ///
531        ///
532        /// Parameter `operatorType`: The operator type for the expression.
533        ///
534        /// Parameter `quantityType`: The quantity type to compare statistics for. Should be a discrete quantity type.
535        ///
536        /// Parameter `averageQuantity`: The average value that the workout statistics are being compared to. The unit for this value should
537        /// match the allowed values for the quantityType.
538        #[unsafe(method(predicateForWorkoutsWithOperatorType:quantityType:averageQuantity:))]
539        #[unsafe(method_family = none)]
540        pub unsafe fn predicateForWorkoutsWithOperatorType_quantityType_averageQuantity(
541            operator_type: NSPredicateOperatorType,
542            quantity_type: &HKQuantityType,
543            average_quantity: &HKQuantity,
544        ) -> Retained<NSPredicate>;
545    );
546}
547
548/// HKWorkoutActivityPredicates.
549impl HKQuery {
550    extern_methods!(
551        #[cfg(feature = "HKWorkout")]
552        /// Creates a predicate for use with HKQuery subclasses.
553        ///
554        /// Creates a query predicate that matches HKWorkoutActivity objects with the given HKWorkoutActivityType.
555        /// The resulting predicate should be wrapped using predicateForWorkoutsWithActivityPredicate: before being used in a query.
556        ///
557        ///
558        /// Parameter `workoutActivityType`: The HKWorkoutActivity type of the workout
559        #[unsafe(method(predicateForWorkoutActivitiesWithWorkoutActivityType:))]
560        #[unsafe(method_family = none)]
561        pub unsafe fn predicateForWorkoutActivitiesWithWorkoutActivityType(
562            workout_activity_type: HKWorkoutActivityType,
563        ) -> Retained<NSPredicate>;
564
565        /// Creates a predicate for use with HKQuery subclasses.
566        ///
567        /// Creates a query predicate that matches HKWorkoutActivity objects by the given operator type and duration.
568        /// The resulting predicate should be wrapped using predicateForWorkoutsWithActivityPredicate: before being used in a query.
569        ///
570        ///
571        /// Parameter `operatorType`: The operator type for the expression.
572        ///
573        /// Parameter `duration`: The value that the workout's duration is being compared to. It is the right hand side of the
574        /// expression.
575        #[unsafe(method(predicateForWorkoutActivitiesWithOperatorType:duration:))]
576        #[unsafe(method_family = none)]
577        pub unsafe fn predicateForWorkoutActivitiesWithOperatorType_duration(
578            operator_type: NSPredicateOperatorType,
579            duration: NSTimeInterval,
580        ) -> Retained<NSPredicate>;
581
582        /// Creates a predicate for use with HKQuery subclasses.
583        ///
584        /// Creates a query predicate that matches HKWorkoutActivity objects with a startDate and an endDate that lie inside of a
585        /// given time interval. The resulting predicate should be wrapped using predicateForWorkoutsWithActivityPredicate:
586        /// before being used in a query.
587        ///
588        ///
589        /// Parameter `startDate`: The start date of the predicate's time interval.
590        ///
591        /// Parameter `endDate`: The end date of the predicate's time interval.
592        ///
593        /// Parameter `options`: The rules for how a activity's time interval overlaps with the predicate's time interval.
594        #[unsafe(method(predicateForWorkoutActivitiesWithStartDate:endDate:options:))]
595        #[unsafe(method_family = none)]
596        pub unsafe fn predicateForWorkoutActivitiesWithStartDate_endDate_options(
597            start_date: Option<&NSDate>,
598            end_date: Option<&NSDate>,
599            options: HKQueryOptions,
600        ) -> Retained<NSPredicate>;
601
602        #[cfg(all(feature = "HKObjectType", feature = "HKQuantity"))]
603        /// Creates a predicate for use with HKQuery subclasses.
604        ///
605        /// Creates a query predicate that matches HKWorkoutActivity objetcs by the given operator type and sumQuantity in the
606        /// statistics for the specified type. The resulting predicate should be wrapped using predicateForWorkoutsWithActivityPredicate:
607        /// before being used in a query.
608        ///
609        ///
610        /// Parameter `operatorType`: The operator type for the expression.
611        ///
612        /// Parameter `quantityType`: The quantity type to compare statistics for. Should be a cumulative quantity type.
613        ///
614        /// Parameter `sumQuantity`: The sum value that the activity statistics are being compared to. The unit for this value should
615        /// match the allowed values for the quantityType.
616        #[unsafe(method(predicateForWorkoutActivitiesWithOperatorType:quantityType:sumQuantity:))]
617        #[unsafe(method_family = none)]
618        pub unsafe fn predicateForWorkoutActivitiesWithOperatorType_quantityType_sumQuantity(
619            operator_type: NSPredicateOperatorType,
620            quantity_type: &HKQuantityType,
621            sum_quantity: &HKQuantity,
622        ) -> Retained<NSPredicate>;
623
624        #[cfg(all(feature = "HKObjectType", feature = "HKQuantity"))]
625        /// Creates a predicate for use with HKQuery subclasses.
626        ///
627        /// Creates a query predicate that matches HKWorkoutActivity objetcs  by the given operator type and minimumQuantity in the
628        /// statistics for the specified type. The resulting predicate should be wrapped using predicateForWorkoutsWithActivityPredicate:
629        /// before being used in a query.
630        ///
631        ///
632        /// Parameter `operatorType`: The operator type for the expression.
633        ///
634        /// Parameter `quantityType`: The quantity type to compare statistics for. Should be a discrete quantity type.
635        ///
636        /// Parameter `minimumQuantity`: The minumum value that the activty statistics are being compared to. The unit for this value should
637        /// match the allowed values for the quantityType.
638        #[unsafe(method(predicateForWorkoutActivitiesWithOperatorType:quantityType:minimumQuantity:))]
639        #[unsafe(method_family = none)]
640        pub unsafe fn predicateForWorkoutActivitiesWithOperatorType_quantityType_minimumQuantity(
641            operator_type: NSPredicateOperatorType,
642            quantity_type: &HKQuantityType,
643            minimum_quantity: &HKQuantity,
644        ) -> Retained<NSPredicate>;
645
646        #[cfg(all(feature = "HKObjectType", feature = "HKQuantity"))]
647        /// Creates a predicate for use with HKQuery subclasses.
648        ///
649        /// Creates a query predicate that matches HKWorkoutActivity objetcs by the given operator type and maximumQuantity in the
650        /// statistics for the specified type. The resulting predicate should be wrapped using predicateForWorkoutsWithActivityPredicate:
651        /// before being used in a query.
652        ///
653        ///
654        /// Parameter `operatorType`: The operator type for the expression.
655        ///
656        /// Parameter `quantityType`: The quantity type to compare statistics for. Should be a discrete quantity type.
657        ///
658        /// Parameter `maximumQuantity`: The maximum value that the activity statistics are being compared to. The unit for this value should
659        /// match the allowed values for the quantityType.
660        #[unsafe(method(predicateForWorkoutActivitiesWithOperatorType:quantityType:maximumQuantity:))]
661        #[unsafe(method_family = none)]
662        pub unsafe fn predicateForWorkoutActivitiesWithOperatorType_quantityType_maximumQuantity(
663            operator_type: NSPredicateOperatorType,
664            quantity_type: &HKQuantityType,
665            maximum_quantity: &HKQuantity,
666        ) -> Retained<NSPredicate>;
667
668        #[cfg(all(feature = "HKObjectType", feature = "HKQuantity"))]
669        /// Creates a predicate for use with HKQuery subclasses.
670        ///
671        /// Creates a query predicate that matches HKWorkoutActivity objetcs by the given operator type and averageQuantity in the
672        /// statistics for the specified type. The resulting predicate should be wrapped using predicateForWorkoutsWithActivityPredicate:
673        /// before being used in a query.
674        ///
675        ///
676        /// Parameter `operatorType`: The operator type for the expression.
677        ///
678        /// Parameter `quantityType`: The quantity type to compare statistics for. Should be a discrete quantity type.
679        ///
680        /// Parameter `averageQuantity`: The average value that the activity statistics are being compared to. The unit for this value should
681        /// match the allowed values for the quantityType.
682        #[unsafe(method(predicateForWorkoutActivitiesWithOperatorType:quantityType:averageQuantity:))]
683        #[unsafe(method_family = none)]
684        pub unsafe fn predicateForWorkoutActivitiesWithOperatorType_quantityType_averageQuantity(
685            operator_type: NSPredicateOperatorType,
686            quantity_type: &HKQuantityType,
687            average_quantity: &HKQuantity,
688        ) -> Retained<NSPredicate>;
689
690        /// Creates a predicate for use with HKQuery subclasses.
691        ///
692        /// Creates a query predicate that matches workouts containing an activity matching the passed predicate.
693        ///
694        ///
695        /// Parameter `activityPredicate`: The predicate on the activities of the workout
696        #[unsafe(method(predicateForWorkoutsWithActivityPredicate:))]
697        #[unsafe(method_family = none)]
698        pub unsafe fn predicateForWorkoutsWithActivityPredicate(
699            activity_predicate: &NSPredicate,
700        ) -> Retained<NSPredicate>;
701    );
702}
703
704/// HKActivitySummaryPredicates.
705impl HKQuery {
706    extern_methods!(
707        /// Creates a predicate for use with HKActivitySummaryQuery
708        ///
709        /// Creates a query predicate that matches HKActivitySummaries with the given date components.
710        ///
711        ///
712        /// Parameter `dateComponents`: The date components of the activity summary. These date components should contain era, year, month,
713        /// and day components in the gregorian calendar.
714        #[unsafe(method(predicateForActivitySummaryWithDateComponents:))]
715        #[unsafe(method_family = none)]
716        pub unsafe fn predicateForActivitySummaryWithDateComponents(
717            date_components: &NSDateComponents,
718        ) -> Retained<NSPredicate>;
719
720        /// Creates a predicate for use with HKActivitySummaryQuery
721        ///
722        /// Creates a query predicate that matches HKActivitySummaries that fall between the given date components.
723        ///
724        ///
725        /// Parameter `startDateComponents`: The date components that define the beginning of the range. These date components should contain
726        /// era, year, month, and day components in the gregorian calendar.
727        ///
728        ///
729        /// Parameter `endDateComponents`: The date components that define the end of the range. These date components should contain era,
730        /// year, month, and day components in the gregorian calendar.
731        #[unsafe(method(predicateForActivitySummariesBetweenStartDateComponents:endDateComponents:))]
732        #[unsafe(method_family = none)]
733        pub unsafe fn predicateForActivitySummariesBetweenStartDateComponents_endDateComponents(
734            start_date_components: &NSDateComponents,
735            end_date_components: &NSDateComponents,
736        ) -> Retained<NSPredicate>;
737    );
738}
739
740/// HKClinicalRecordPredicates.
741impl HKQuery {
742    extern_methods!(
743        #[cfg(feature = "HKFHIRResource")]
744        /// Creates a predicate for use with HKQuery subclasses.
745        ///
746        /// Creates a query predicate that matches HKClinicalRecords with a specific FHIR resource type.
747        ///
748        ///
749        /// Parameter `resourceType`: The FHIR resource type.
750        #[unsafe(method(predicateForClinicalRecordsWithFHIRResourceType:))]
751        #[unsafe(method_family = none)]
752        pub unsafe fn predicateForClinicalRecordsWithFHIRResourceType(
753            resource_type: &HKFHIRResourceType,
754        ) -> Retained<NSPredicate>;
755
756        #[cfg(all(feature = "HKFHIRResource", feature = "HKSource"))]
757        /// Creates a predicate for use with HKQuery subclasses.
758        ///
759        /// Creates a query predicate that matches HKClinicalRecords for a given source, FHIR resource type, and FHIR identifier.
760        ///
761        ///
762        /// Parameter `source`: The source.
763        ///
764        /// Parameter `resourceType`: The FHIR resource type.
765        ///
766        /// Parameter `identifier`: The FHIR identifier.
767        #[unsafe(method(predicateForClinicalRecordsFromSource:FHIRResourceType:identifier:))]
768        #[unsafe(method_family = none)]
769        pub unsafe fn predicateForClinicalRecordsFromSource_FHIRResourceType_identifier(
770            source: &HKSource,
771            resource_type: &HKFHIRResourceType,
772            identifier: &NSString,
773        ) -> Retained<NSPredicate>;
774    );
775}
776
777/// HKElectrocardiogramPredicates.
778impl HKQuery {
779    extern_methods!(
780        #[cfg(feature = "HKElectrocardiogram")]
781        /// Creates a predicate for use with HKQuery subclasses.
782        ///
783        /// Creates a query predicate that matches HKElectrocardiograms with a specific classification.
784        ///
785        ///
786        /// Parameter `classification`: The classification for the electrocardiogram.
787        #[unsafe(method(predicateForElectrocardiogramsWithClassification:))]
788        #[unsafe(method_family = none)]
789        pub unsafe fn predicateForElectrocardiogramsWithClassification(
790            classification: HKElectrocardiogramClassification,
791        ) -> Retained<NSPredicate>;
792
793        #[cfg(feature = "HKElectrocardiogram")]
794        /// Creates a predicate for use with HKQuery subclasses.
795        ///
796        /// Creates a query predicate that matches HKElectrocardiograms with a specificied symptoms status.
797        ///
798        ///
799        /// Parameter `symptomsStatus`: The symptoms status for the electrocardiogram.
800        #[unsafe(method(predicateForElectrocardiogramsWithSymptomsStatus:))]
801        #[unsafe(method_family = none)]
802        pub unsafe fn predicateForElectrocardiogramsWithSymptomsStatus(
803            symptoms_status: HKElectrocardiogramSymptomsStatus,
804        ) -> Retained<NSPredicate>;
805    );
806}
807
808/// HKVerifiableClinicalRecordPredicates.
809impl HKQuery {
810    extern_methods!(
811        /// Creates a predicate for use with HKQuery subclasses.
812        ///
813        /// Creates a predicate that matches HKVerifiableClinicalRecords with a relevant date within a date interval.
814        ///
815        ///
816        /// Parameter `dateInterval`: The date interval that the record's relevant date is in.
817        #[unsafe(method(predicateForVerifiableClinicalRecordsWithRelevantDateWithinDateInterval:))]
818        #[unsafe(method_family = none)]
819        pub unsafe fn predicateForVerifiableClinicalRecordsWithRelevantDateWithinDateInterval(
820            date_interval: &NSDateInterval,
821        ) -> Retained<NSPredicate>;
822    );
823}
824
825/// HKStateOfMind.
826impl HKQuery {
827    extern_methods!(
828        /// Creates a predicate for use with HKStateOfMind
829        ///
830        /// Creates a query predicate that matches HKStateOfMind samples that have a valence property matching the operator type and valence.
831        ///
832        ///
833        /// Parameter `valence`: The value to be compared against.
834        ///
835        /// Parameter `operatorType`: The comparison operator type for the expression.
836        #[unsafe(method(predicateForStatesOfMindWithValence:operatorType:))]
837        #[unsafe(method_family = none)]
838        pub unsafe fn predicateForStatesOfMindWithValence_operatorType(
839            valence: c_double,
840            operator_type: NSPredicateOperatorType,
841        ) -> Retained<NSPredicate>;
842
843        #[cfg(feature = "HKStateOfMind")]
844        /// Creates a predicate for use with HKStateOfMind
845        ///
846        /// Creates a query predicate that matches HKStateOfMind samples that have the specified kind of feeling type.
847        ///
848        ///
849        /// Parameter `kind`: The kind of feeling type to be compared against.
850        #[unsafe(method(predicateForStatesOfMindWithKind:))]
851        #[unsafe(method_family = none)]
852        pub unsafe fn predicateForStatesOfMindWithKind(
853            kind: HKStateOfMindKind,
854        ) -> Retained<NSPredicate>;
855
856        #[cfg(feature = "HKStateOfMind")]
857        /// Creates a predicate for use with HKStateOfMind
858        ///
859        /// Creates a query predicate that matches HKStateOfMind samples that have the specified label.
860        ///
861        ///
862        /// Parameter `label`: The label to be compared against.
863        #[unsafe(method(predicateForStatesOfMindWithLabel:))]
864        #[unsafe(method_family = none)]
865        pub unsafe fn predicateForStatesOfMindWithLabel(
866            label: HKStateOfMindLabel,
867        ) -> Retained<NSPredicate>;
868
869        #[cfg(feature = "HKStateOfMind")]
870        /// Creates a predicate for use with HKStateOfMind
871        ///
872        /// Creates a query predicate that matches HKStateOfMind samples that have the specified association.
873        ///
874        ///
875        /// Parameter `association`: The association to be compared against.
876        #[unsafe(method(predicateForStatesOfMindWithAssociation:))]
877        #[unsafe(method_family = none)]
878        pub unsafe fn predicateForStatesOfMindWithAssociation(
879            association: HKStateOfMindAssociation,
880        ) -> Retained<NSPredicate>;
881    );
882}
883
884/// HKMedicationDoseEvent.
885impl HKQuery {
886    extern_methods!(
887        #[cfg(feature = "HKMedicationDoseEvent")]
888        /// Creates a predicate for use with HKQuery subclasses.
889        ///
890        /// Creates a query predicate that matches HKMedicationDoseEvent samples that have the status specified.
891        ///
892        ///
893        /// Parameter `status`: The logged status of the medication dose event to match.
894        #[unsafe(method(predicateForMedicationDoseEventWithStatus:))]
895        #[unsafe(method_family = none)]
896        pub unsafe fn predicateForMedicationDoseEventWithStatus(
897            status: HKMedicationDoseEventLogStatus,
898        ) -> Retained<NSPredicate>;
899
900        /// Creates a predicate for use with HKQuery subclasses.
901        ///
902        /// Creates a query predicate that matches HKMedicationDoseEvent samples that have any of the statuses specified.
903        ///
904        ///
905        /// Parameter `statuses`: The logged statuses of the medication dose event to match.
906        #[unsafe(method(predicateForMedicationDoseEventWithStatuses:))]
907        #[unsafe(method_family = none)]
908        pub unsafe fn predicateForMedicationDoseEventWithStatuses(
909            statuses: &NSSet<NSNumber>,
910        ) -> Retained<NSPredicate>;
911
912        /// Creates a predicate for use with HKQuery subclasses.
913        ///
914        /// Creates a query predicate that matches HKMedicationDoseEvent samples that have the exact scheduled date specified.
915        ///
916        ///
917        /// Parameter `scheduledDate`: The exact scheduled date of the medication dose event to match.
918        #[unsafe(method(predicateForMedicationDoseEventWithScheduledDate:))]
919        #[unsafe(method_family = none)]
920        pub unsafe fn predicateForMedicationDoseEventWithScheduledDate(
921            scheduled_date: &NSDate,
922        ) -> Retained<NSPredicate>;
923
924        /// Creates a predicate for use with HKQuery subclasses.
925        ///
926        /// Creates a query predicate that matches HKMedicationDoseEvent samples that have any of the exact scheduled dates specified.
927        ///
928        ///
929        /// Parameter `scheduledDates`: The exact scheduled dates of any medication dose event to match.
930        #[unsafe(method(predicateForMedicationDoseEventWithScheduledDates:))]
931        #[unsafe(method_family = none)]
932        pub unsafe fn predicateForMedicationDoseEventWithScheduledDates(
933            scheduled_dates: &NSSet<NSDate>,
934        ) -> Retained<NSPredicate>;
935
936        /// Creates a predicate for use with HKQuery subclasses.
937        ///
938        /// 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.
939        ///
940        ///
941        /// Parameter `startDate`: The beginning of the window for scheduled dates of any medication dose event to match.
942        ///
943        /// Parameter `endDate`: The beginning of the window for scheduled dates of any medication dose event to match.
944        #[unsafe(method(predicateForMedicationDoseEventWithScheduledStartDate:endDate:))]
945        #[unsafe(method_family = none)]
946        pub unsafe fn predicateForMedicationDoseEventWithScheduledStartDate_endDate(
947            start_date: Option<&NSDate>,
948            end_date: Option<&NSDate>,
949        ) -> Retained<NSPredicate>;
950
951        #[cfg(feature = "HKHealthConceptIdentifier")]
952        /// Creates a predicate for use with HKQuery subclasses.
953        ///
954        /// Creates a query predicate that matches HKMedicationDoseEvent samples that match a medication's concept identifier.
955        ///
956        ///
957        /// Parameter `medicationConceptIdentifier`: The identifier of the medication that a dose event was created for.
958        #[unsafe(method(predicateForMedicationDoseEventWithMedicationConceptIdentifier:))]
959        #[unsafe(method_family = none)]
960        pub unsafe fn predicateForMedicationDoseEventWithMedicationConceptIdentifier(
961            medication_concept_identifier: &HKHealthConceptIdentifier,
962        ) -> Retained<NSPredicate>;
963
964        #[cfg(feature = "HKHealthConceptIdentifier")]
965        /// Creates a predicate for use with HKQuery subclasses.
966        ///
967        /// Creates a query predicate that matches HKMedicationDoseEvent samples generated by any medication in a set of medication concept identifiers.
968        ///
969        ///
970        /// Parameter `medicationConceptIdentifiers`: Any identifier of a medication that a dose event was created for.
971        #[unsafe(method(predicateForMedicationDoseEventWithMedicationConceptIdentifiers:))]
972        #[unsafe(method_family = none)]
973        pub unsafe fn predicateForMedicationDoseEventWithMedicationConceptIdentifiers(
974            medication_concept_identifiers: &NSSet<HKHealthConceptIdentifier>,
975        ) -> Retained<NSPredicate>;
976    );
977}
978
979/// HKUserAnnotatedMedications.
980impl HKQuery {
981    extern_methods!(
982        /// Creates a predicate for use with HKUserAnnotatedMedicationQuery.
983        ///
984        /// Creates a query predicate that matches HKUserAnnotatedMedication objects that have the archived status specified.
985        ///
986        ///
987        /// Parameter `isArchived`: The archived status of the medication. Ex: True will match medications in the archived section in the Health App.
988        #[unsafe(method(predicateForUserAnnotatedMedicationsWithIsArchived:))]
989        #[unsafe(method_family = none)]
990        pub unsafe fn predicateForUserAnnotatedMedicationsWithIsArchived(
991            is_archived: bool,
992        ) -> Retained<NSPredicate>;
993
994        /// Creates a predicate for use with HKUserAnnotatedMedicationQuery.
995        ///
996        /// Creates a query predicate that matches HKUserAnnotatedMedication objects that match the schedule status specified.
997        ///
998        ///
999        /// Parameter `hasSchedule`: The schedule status of the medication. Ex: True will match medications that have a reminders schedule set up in the Health App.
1000        #[unsafe(method(predicateForUserAnnotatedMedicationsWithHasSchedule:))]
1001        #[unsafe(method_family = none)]
1002        pub unsafe fn predicateForUserAnnotatedMedicationsWithHasSchedule(
1003            has_schedule: bool,
1004        ) -> Retained<NSPredicate>;
1005    );
1006}