objc2_health_kit/generated/HKAnchoredObjectQuery.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/hkanchoredobjectquery?language=objc)
12 #[unsafe(super(HKQuery, NSObject))]
13 #[derive(Debug, PartialEq, Eq, Hash)]
14 #[cfg(feature = "HKQuery")]
15 pub struct HKAnchoredObjectQuery;
16);
17
18#[cfg(feature = "HKQuery")]
19unsafe impl Send for HKAnchoredObjectQuery {}
20
21#[cfg(feature = "HKQuery")]
22unsafe impl Sync for HKAnchoredObjectQuery {}
23
24#[cfg(feature = "HKQuery")]
25extern_conformance!(
26 unsafe impl NSObjectProtocol for HKAnchoredObjectQuery {}
27);
28
29#[cfg(feature = "HKQuery")]
30impl HKAnchoredObjectQuery {
31 extern_methods!(
32 #[cfg(all(
33 feature = "HKDeletedObject",
34 feature = "HKObject",
35 feature = "HKQueryAnchor",
36 feature = "HKSample",
37 feature = "block2"
38 ))]
39 /// An optional handler to be called when samples matching the given predicate are added or deleted.
40 ///
41 /// This property may not be modified once the query has been executed. It may only be set if the query has
42 /// no limit.
43 ///
44 /// This property is not atomic.
45 ///
46 /// # Safety
47 ///
48 /// - The returned block must be sendable.
49 /// - This might not be thread-safe.
50 #[unsafe(method(updateHandler))]
51 #[unsafe(method_family = none)]
52 pub unsafe fn updateHandler(
53 &self,
54 ) -> *mut block2::DynBlock<
55 dyn Fn(
56 NonNull<HKAnchoredObjectQuery>,
57 *mut NSArray<HKSample>,
58 *mut NSArray<HKDeletedObject>,
59 *mut HKQueryAnchor,
60 *mut NSError,
61 ),
62 >;
63
64 #[cfg(all(
65 feature = "HKDeletedObject",
66 feature = "HKObject",
67 feature = "HKQueryAnchor",
68 feature = "HKSample",
69 feature = "block2"
70 ))]
71 /// Setter for [`updateHandler`][Self::updateHandler].
72 ///
73 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
74 ///
75 /// # Safety
76 ///
77 /// - `update_handler` block must be sendable.
78 /// - This might not be thread-safe.
79 #[unsafe(method(setUpdateHandler:))]
80 #[unsafe(method_family = none)]
81 pub unsafe fn setUpdateHandler(
82 &self,
83 update_handler: Option<
84 &block2::DynBlock<
85 dyn Fn(
86 NonNull<HKAnchoredObjectQuery>,
87 *mut NSArray<HKSample>,
88 *mut NSArray<HKDeletedObject>,
89 *mut HKQueryAnchor,
90 *mut NSError,
91 ),
92 >,
93 >,
94 );
95
96 #[cfg(all(
97 feature = "HKDeletedObject",
98 feature = "HKObject",
99 feature = "HKObjectType",
100 feature = "HKQueryAnchor",
101 feature = "HKSample",
102 feature = "block2"
103 ))]
104 /// Returns a query that will retrieve HKSamples and HKDeletedObjects matching the given predicate that are
105 /// newer than the given anchor.
106 ///
107 /// If no updateHandler is set on the query, the query will automatically stop after calling resultsHandler.
108 /// Otherwise, the query continues to run and call updateHandler as samples matching the predicate are
109 /// created or deleted.
110 ///
111 ///
112 /// Parameter `type`: The type of sample to retrieve.
113 ///
114 /// Parameter `predicate`: The predicate which samples should match.
115 ///
116 /// Parameter `anchor`: The anchor which was returned by a previous HKAnchoredObjectQuery result or update
117 /// handler. Pass nil when querying for the first time.
118 ///
119 /// Parameter `limit`: The maximum number of samples and deleted objects to return. Pass HKObjectQueryNoLimit
120 /// for no limit.
121 ///
122 /// Parameter `handler`: The block to invoke with results when the query has finished finding.
123 ///
124 /// # Safety
125 ///
126 /// `handler` block must be sendable.
127 #[unsafe(method(initWithType:predicate:anchor:limit:resultsHandler:))]
128 #[unsafe(method_family = init)]
129 pub unsafe fn initWithType_predicate_anchor_limit_resultsHandler(
130 this: Allocated<Self>,
131 r#type: &HKSampleType,
132 predicate: Option<&NSPredicate>,
133 anchor: Option<&HKQueryAnchor>,
134 limit: NSUInteger,
135 handler: &block2::DynBlock<
136 dyn Fn(
137 NonNull<HKAnchoredObjectQuery>,
138 *mut NSArray<HKSample>,
139 *mut NSArray<HKDeletedObject>,
140 *mut HKQueryAnchor,
141 *mut NSError,
142 ),
143 >,
144 ) -> Retained<Self>;
145
146 #[cfg(all(
147 feature = "HKObject",
148 feature = "HKObjectType",
149 feature = "HKSample",
150 feature = "block2"
151 ))]
152 /// # Safety
153 ///
154 /// `handler` block must be sendable.
155 #[deprecated]
156 #[unsafe(method(initWithType:predicate:anchor:limit:completionHandler:))]
157 #[unsafe(method_family = init)]
158 pub unsafe fn initWithType_predicate_anchor_limit_completionHandler(
159 this: Allocated<Self>,
160 r#type: &HKSampleType,
161 predicate: Option<&NSPredicate>,
162 anchor: NSUInteger,
163 limit: NSUInteger,
164 handler: &block2::DynBlock<
165 dyn Fn(
166 NonNull<HKAnchoredObjectQuery>,
167 *mut NSArray<HKSample>,
168 NSUInteger,
169 *mut NSError,
170 ),
171 >,
172 ) -> Retained<Self>;
173
174 #[cfg(all(
175 feature = "HKDeletedObject",
176 feature = "HKObject",
177 feature = "HKQueryAnchor",
178 feature = "HKQueryDescriptor",
179 feature = "HKSample",
180 feature = "block2"
181 ))]
182 /// Returns a query that will retrieve HKSamples and HKDeletedObjects matching the given query descriptors
183 /// that are newer than the given anchor.
184 ///
185 /// If no updateHandler is set on the query, the query will automatically stop after calling resultsHandler.
186 /// Otherwise, the query continues to run and call updateHandler as samples matching the query descriptors
187 /// are created or deleted.
188 ///
189 ///
190 /// Parameter `queryDescriptors`: An array of query descriptors that describes the sample types and predicates that
191 /// you are interested in getting notified for.
192 ///
193 /// Parameter `anchor`: The anchor which was returned by a previous HKAnchoredObjectQuery result or update
194 /// handler. Pass nil when querying for the first time.
195 ///
196 /// Parameter `limit`: The maximum number of samples and deleted objects to return. Pass
197 /// HKObjectQueryNoLimit for no limit.
198 ///
199 /// Parameter `handler`: The block to invoke with results when the query has finished finding.
200 ///
201 /// # Safety
202 ///
203 /// `handler` block must be sendable.
204 #[unsafe(method(initWithQueryDescriptors:anchor:limit:resultsHandler:))]
205 #[unsafe(method_family = init)]
206 pub unsafe fn initWithQueryDescriptors_anchor_limit_resultsHandler(
207 this: Allocated<Self>,
208 query_descriptors: &NSArray<HKQueryDescriptor>,
209 anchor: Option<&HKQueryAnchor>,
210 limit: NSInteger,
211 handler: &block2::DynBlock<
212 dyn Fn(
213 NonNull<HKAnchoredObjectQuery>,
214 *mut NSArray<HKSample>,
215 *mut NSArray<HKDeletedObject>,
216 *mut HKQueryAnchor,
217 *mut NSError,
218 ),
219 >,
220 ) -> Retained<Self>;
221 );
222}
223
224/// Methods declared on superclass `HKQuery`.
225#[cfg(feature = "HKQuery")]
226impl HKAnchoredObjectQuery {
227 extern_methods!(
228 #[unsafe(method(init))]
229 #[unsafe(method_family = init)]
230 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
231 );
232}
233
234/// Methods declared on superclass `NSObject`.
235#[cfg(feature = "HKQuery")]
236impl HKAnchoredObjectQuery {
237 extern_methods!(
238 #[unsafe(method(new))]
239 #[unsafe(method_family = new)]
240 pub unsafe fn new() -> Retained<Self>;
241 );
242}