objc2_health_kit/generated/
HKSampleQuery.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
10/// [Apple's documentation](https://developer.apple.com/documentation/healthkit/hkobjectquerynolimit?language=objc)
11pub static HKObjectQueryNoLimit: NSUInteger = 0;
12
13extern_class!(
14    /// [Apple's documentation](https://developer.apple.com/documentation/healthkit/hksamplequery?language=objc)
15    #[unsafe(super(HKQuery, NSObject))]
16    #[derive(Debug, PartialEq, Eq, Hash)]
17    #[cfg(feature = "HKQuery")]
18    pub struct HKSampleQuery;
19);
20
21#[cfg(feature = "HKQuery")]
22unsafe impl Send for HKSampleQuery {}
23
24#[cfg(feature = "HKQuery")]
25unsafe impl Sync for HKSampleQuery {}
26
27#[cfg(feature = "HKQuery")]
28extern_conformance!(
29    unsafe impl NSObjectProtocol for HKSampleQuery {}
30);
31
32#[cfg(feature = "HKQuery")]
33impl HKSampleQuery {
34    extern_methods!(
35        /// The maximum number of results the receiver will return upon completion.
36        #[unsafe(method(limit))]
37        #[unsafe(method_family = none)]
38        pub unsafe fn limit(&self) -> NSUInteger;
39
40        /// An array of NSSortDescriptors.
41        #[unsafe(method(sortDescriptors))]
42        #[unsafe(method_family = none)]
43        pub unsafe fn sortDescriptors(&self) -> Option<Retained<NSArray<NSSortDescriptor>>>;
44
45        #[cfg(all(
46            feature = "HKObject",
47            feature = "HKObjectType",
48            feature = "HKSample",
49            feature = "block2"
50        ))]
51        /// Returns a query that will retrieve HKSamples matching the given predicate.
52        ///
53        ///
54        /// Parameter `sampleType`: The type of sample to retrieve.
55        ///
56        /// Parameter `predicate`: The predicate which samples should match.
57        ///
58        /// Parameter `limit`: The maximum number of samples to return.  Pass HKObjectQueryNoLimit for no limit.
59        ///
60        /// Parameter `sortDescriptors`: The sort descriptors to use to order the resulting samples.
61        ///
62        /// Parameter `resultsHandler`: The block to invoke with results when the query has finished executing.
63        ///
64        /// # Safety
65        ///
66        /// `results_handler` block must be sendable.
67        #[unsafe(method(initWithSampleType:predicate:limit:sortDescriptors:resultsHandler:))]
68        #[unsafe(method_family = init)]
69        pub unsafe fn initWithSampleType_predicate_limit_sortDescriptors_resultsHandler(
70            this: Allocated<Self>,
71            sample_type: &HKSampleType,
72            predicate: Option<&NSPredicate>,
73            limit: NSUInteger,
74            sort_descriptors: Option<&NSArray<NSSortDescriptor>>,
75            results_handler: &block2::DynBlock<
76                dyn Fn(NonNull<HKSampleQuery>, *mut NSArray<HKSample>, *mut NSError),
77            >,
78        ) -> Retained<Self>;
79
80        #[cfg(all(
81            feature = "HKObject",
82            feature = "HKQueryDescriptor",
83            feature = "HKSample",
84            feature = "block2"
85        ))]
86        /// Returns a query that will retrieve HKSamples matching any of the given queryDescriptors.
87        ///
88        ///
89        /// Parameter `queryDescriptors`: An array of query descriptors that describes the sample types and predicates
90        /// used for querying.
91        ///
92        /// Parameter `limit`: The maximum number of samples to return. Pass HKObjectQueryNoLimit
93        /// for no limit.
94        ///
95        /// Parameter `resultsHandler`: The block to invoke with results when the query has finished executing. This
96        /// block is invoked once with results, an array of HKSamples matching the
97        /// queryDescriptors passed in, or nil if an error occurred.
98        ///
99        /// # Safety
100        ///
101        /// `results_handler` block must be sendable.
102        #[unsafe(method(initWithQueryDescriptors:limit:resultsHandler:))]
103        #[unsafe(method_family = init)]
104        pub unsafe fn initWithQueryDescriptors_limit_resultsHandler(
105            this: Allocated<Self>,
106            query_descriptors: &NSArray<HKQueryDescriptor>,
107            limit: NSInteger,
108            results_handler: &block2::DynBlock<
109                dyn Fn(NonNull<HKSampleQuery>, *mut NSArray<HKSample>, *mut NSError),
110            >,
111        ) -> Retained<Self>;
112
113        #[cfg(all(
114            feature = "HKObject",
115            feature = "HKQueryDescriptor",
116            feature = "HKSample",
117            feature = "block2"
118        ))]
119        /// Returns a query that will retrieve HKSamples matching any of the given queryDescriptors.
120        ///
121        ///
122        /// Parameter `queryDescriptors`: An array of query descriptors that describes the sample types and predicates
123        /// used for querying.
124        ///
125        /// Parameter `limit`: The maximum number of samples to return. Pass HKObjectQueryNoLimit
126        /// for no limit.
127        ///
128        /// Parameter `sortDescriptors`: The sort descriptors to use to order the resulting samples.
129        ///
130        /// Parameter `resultsHandler`: The block to invoke with results when the query has finished executing. This
131        /// block is invoked once with results, an array of HKSamples matching the
132        /// queryDescriptors passed in, or nil if an error occurred. The HKSamples in the
133        /// array are sorted by the specified sortDescriptors.
134        ///
135        /// # Safety
136        ///
137        /// `results_handler` block must be sendable.
138        #[unsafe(method(initWithQueryDescriptors:limit:sortDescriptors:resultsHandler:))]
139        #[unsafe(method_family = init)]
140        pub unsafe fn initWithQueryDescriptors_limit_sortDescriptors_resultsHandler(
141            this: Allocated<Self>,
142            query_descriptors: &NSArray<HKQueryDescriptor>,
143            limit: NSInteger,
144            sort_descriptors: &NSArray<NSSortDescriptor>,
145            results_handler: &block2::DynBlock<
146                dyn Fn(NonNull<HKSampleQuery>, *mut NSArray<HKSample>, *mut NSError),
147            >,
148        ) -> Retained<Self>;
149    );
150}
151
152/// Methods declared on superclass `HKQuery`.
153#[cfg(feature = "HKQuery")]
154impl HKSampleQuery {
155    extern_methods!(
156        #[unsafe(method(init))]
157        #[unsafe(method_family = init)]
158        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
159    );
160}
161
162/// Methods declared on superclass `NSObject`.
163#[cfg(feature = "HKQuery")]
164impl HKSampleQuery {
165    extern_methods!(
166        #[unsafe(method(new))]
167        #[unsafe(method_family = new)]
168        pub unsafe fn new() -> Retained<Self>;
169    );
170}