objc2_cloud_kit/generated/
CKQueryOperation.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/cloudkit/ckquerycursor?language=objc)
12    #[unsafe(super(NSObject))]
13    #[derive(Debug, PartialEq, Eq, Hash)]
14    pub struct CKQueryCursor;
15);
16
17extern_conformance!(
18    unsafe impl NSCoding for CKQueryCursor {}
19);
20
21extern_conformance!(
22    unsafe impl NSCopying for CKQueryCursor {}
23);
24
25unsafe impl CopyingHelper for CKQueryCursor {
26    type Result = Self;
27}
28
29extern_conformance!(
30    unsafe impl NSObjectProtocol for CKQueryCursor {}
31);
32
33extern_conformance!(
34    unsafe impl NSSecureCoding for CKQueryCursor {}
35);
36
37impl CKQueryCursor {
38    extern_methods!(
39        #[unsafe(method(init))]
40        #[unsafe(method_family = init)]
41        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
42
43        #[unsafe(method(new))]
44        #[unsafe(method_family = new)]
45        pub unsafe fn new() -> Retained<Self>;
46    );
47}
48
49extern "C" {
50    /// Query operations have a dynamically defined maximum number of results.  If the results of a query exceed this max, your completion block will invoked with a cursor.
51    /// Issue a new query with that cursor to fetch the next batch of results.
52    ///
53    /// See also [Apple's documentation](https://developer.apple.com/documentation/cloudkit/ckqueryoperationmaximumresults?language=objc)
54    pub static CKQueryOperationMaximumResults: NSUInteger;
55}
56
57extern_class!(
58    /// [Apple's documentation](https://developer.apple.com/documentation/cloudkit/ckqueryoperation?language=objc)
59    #[unsafe(super(CKDatabaseOperation, CKOperation, NSOperation, NSObject))]
60    #[derive(Debug, PartialEq, Eq, Hash)]
61    #[cfg(all(feature = "CKDatabaseOperation", feature = "CKOperation"))]
62    pub struct CKQueryOperation;
63);
64
65#[cfg(all(feature = "CKDatabaseOperation", feature = "CKOperation"))]
66extern_conformance!(
67    unsafe impl NSObjectProtocol for CKQueryOperation {}
68);
69
70#[cfg(all(feature = "CKDatabaseOperation", feature = "CKOperation"))]
71impl CKQueryOperation {
72    extern_methods!(
73        /// Queries invoked within a sharedCloudDatabase must specify a zoneID.  Cross-zone queries are not supported in a sharedCloudDatabase
74        #[unsafe(method(init))]
75        #[unsafe(method_family = init)]
76        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
77
78        #[cfg(feature = "CKQuery")]
79        #[unsafe(method(initWithQuery:))]
80        #[unsafe(method_family = init)]
81        pub unsafe fn initWithQuery(this: Allocated<Self>, query: &CKQuery) -> Retained<Self>;
82
83        #[unsafe(method(initWithCursor:))]
84        #[unsafe(method_family = init)]
85        pub unsafe fn initWithCursor(
86            this: Allocated<Self>,
87            cursor: &CKQueryCursor,
88        ) -> Retained<Self>;
89
90        #[cfg(feature = "CKQuery")]
91        /// This property is not atomic.
92        ///
93        /// # Safety
94        ///
95        /// This might not be thread-safe.
96        #[unsafe(method(query))]
97        #[unsafe(method_family = none)]
98        pub unsafe fn query(&self) -> Option<Retained<CKQuery>>;
99
100        #[cfg(feature = "CKQuery")]
101        /// Setter for [`query`][Self::query].
102        ///
103        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
104        ///
105        /// # Safety
106        ///
107        /// This might not be thread-safe.
108        #[unsafe(method(setQuery:))]
109        #[unsafe(method_family = none)]
110        pub unsafe fn setQuery(&self, query: Option<&CKQuery>);
111
112        /// This property is not atomic.
113        ///
114        /// # Safety
115        ///
116        /// This might not be thread-safe.
117        #[unsafe(method(cursor))]
118        #[unsafe(method_family = none)]
119        pub unsafe fn cursor(&self) -> Option<Retained<CKQueryCursor>>;
120
121        /// Setter for [`cursor`][Self::cursor].
122        ///
123        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
124        ///
125        /// # Safety
126        ///
127        /// This might not be thread-safe.
128        #[unsafe(method(setCursor:))]
129        #[unsafe(method_family = none)]
130        pub unsafe fn setCursor(&self, cursor: Option<&CKQueryCursor>);
131
132        #[cfg(feature = "CKRecordZoneID")]
133        /// Indicates which record zone to query.
134        ///
135        ///
136        /// For query operations constructed using a cursor, this property is ignored and instead will be evaluated in the record zone in which the cursor was originally created.
137        /// Queries that do not specify a
138        /// `zoneID`will perform a query across all zones in the database.
139        ///
140        /// This property is not atomic.
141        ///
142        /// # Safety
143        ///
144        /// This might not be thread-safe.
145        #[unsafe(method(zoneID))]
146        #[unsafe(method_family = none)]
147        pub unsafe fn zoneID(&self) -> Option<Retained<CKRecordZoneID>>;
148
149        #[cfg(feature = "CKRecordZoneID")]
150        /// Setter for [`zoneID`][Self::zoneID].
151        ///
152        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
153        ///
154        /// # Safety
155        ///
156        /// This might not be thread-safe.
157        #[unsafe(method(setZoneID:))]
158        #[unsafe(method_family = none)]
159        pub unsafe fn setZoneID(&self, zone_id: Option<&CKRecordZoneID>);
160
161        /// Defaults to
162        /// `CKQueryOperationMaximumResults.`Queries may return fewer than
163        /// `resultsLimit`in some scenarios:
164        /// - There are legitimately fewer than
165        /// `resultsLimit`number of records matching the query (and visible to the current user).
166        /// - During the process of querying and fetching the results, some records were deleted, or became un-readable by the current user.
167        /// When determining if there are more records to fetch, always check for the presence of a cursor in
168        /// `queryCompletionBlock.`
169        ///
170        /// This property is not atomic.
171        ///
172        /// # Safety
173        ///
174        /// This might not be thread-safe.
175        #[unsafe(method(resultsLimit))]
176        #[unsafe(method_family = none)]
177        pub unsafe fn resultsLimit(&self) -> NSUInteger;
178
179        /// Setter for [`resultsLimit`][Self::resultsLimit].
180        ///
181        /// # Safety
182        ///
183        /// This might not be thread-safe.
184        #[unsafe(method(setResultsLimit:))]
185        #[unsafe(method_family = none)]
186        pub unsafe fn setResultsLimit(&self, results_limit: NSUInteger);
187
188        #[cfg(feature = "CKRecord")]
189        /// Declares which user-defined keys should be fetched and added to the resulting CKRecords.
190        ///
191        ///
192        /// If nil, declares the entire record should be downloaded. If set to an empty array, declares that no user fields should be downloaded.
193        /// Defaults to
194        /// `nil.`
195        ///
196        /// This property is not atomic.
197        ///
198        /// # Safety
199        ///
200        /// This might not be thread-safe.
201        #[unsafe(method(desiredKeys))]
202        #[unsafe(method_family = none)]
203        pub unsafe fn desiredKeys(&self) -> Option<Retained<NSArray<CKRecordFieldKey>>>;
204
205        #[cfg(feature = "CKRecord")]
206        /// Setter for [`desiredKeys`][Self::desiredKeys].
207        ///
208        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
209        ///
210        /// # Safety
211        ///
212        /// This might not be thread-safe.
213        #[unsafe(method(setDesiredKeys:))]
214        #[unsafe(method_family = none)]
215        pub unsafe fn setDesiredKeys(&self, desired_keys: Option<&NSArray<CKRecordFieldKey>>);
216
217        #[cfg(all(feature = "CKRecord", feature = "block2"))]
218        /// This block will be called once for every record that is returned as a result of the query.
219        ///
220        ///
221        /// The callbacks will happen in the order that the results were sorted in.
222        /// If the replacement callback
223        /// `recordMatchedBlock`is set, this callback block is ignored.
224        /// Each
225        /// `CKOperation`instance has a private serial queue. This queue is used for all callback block invocations.
226        /// This block may share mutable state with other blocks assigned to this operation, but any such mutable state
227        /// should not be concurrently used outside of blocks assigned to this operation.
228        ///
229        /// This property is not atomic.
230        ///
231        /// # Safety
232        ///
233        /// - The returned block's argument must be a valid pointer.
234        /// - This might not be thread-safe.
235        #[deprecated = "Use recordMatchedBlock instead, which surfaces per-record errors"]
236        #[unsafe(method(recordFetchedBlock))]
237        #[unsafe(method_family = none)]
238        pub unsafe fn recordFetchedBlock(&self)
239            -> *mut block2::DynBlock<dyn Fn(NonNull<CKRecord>)>;
240
241        #[cfg(all(feature = "CKRecord", feature = "block2"))]
242        /// Setter for [`recordFetchedBlock`][Self::recordFetchedBlock].
243        ///
244        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
245        ///
246        /// # Safety
247        ///
248        /// This might not be thread-safe.
249        #[deprecated = "Use recordMatchedBlock instead, which surfaces per-record errors"]
250        #[unsafe(method(setRecordFetchedBlock:))]
251        #[unsafe(method_family = none)]
252        pub unsafe fn setRecordFetchedBlock(
253            &self,
254            record_fetched_block: Option<&block2::DynBlock<dyn Fn(NonNull<CKRecord>)>>,
255        );
256
257        #[cfg(all(feature = "CKRecord", feature = "CKRecordID", feature = "block2"))]
258        /// This block will be called once for every record that is returned as a result of the query.
259        ///
260        ///
261        /// The callbacks will happen in the order that the results were sorted in.  If a record fails in post-processing (say, a network failure materializing a
262        /// `CKAsset`record field), the per-record error will be passed here.
263        /// Each
264        /// `CKOperation`instance has a private serial queue. This queue is used for all callback block invocations.
265        /// This block may share mutable state with other blocks assigned to this operation, but any such mutable state
266        /// should not be concurrently used outside of blocks assigned to this operation.
267        ///
268        /// This property is not atomic.
269        ///
270        /// # Safety
271        ///
272        /// - The returned block's argument 1 must be a valid pointer.
273        /// - The returned block's argument 2 must be a valid pointer or null.
274        /// - The returned block's argument 3 must be a valid pointer or null.
275        /// - This might not be thread-safe.
276        #[unsafe(method(recordMatchedBlock))]
277        #[unsafe(method_family = none)]
278        pub unsafe fn recordMatchedBlock(
279            &self,
280        ) -> *mut block2::DynBlock<dyn Fn(NonNull<CKRecordID>, *mut CKRecord, *mut NSError)>;
281
282        #[cfg(all(feature = "CKRecord", feature = "CKRecordID", feature = "block2"))]
283        /// Setter for [`recordMatchedBlock`][Self::recordMatchedBlock].
284        ///
285        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
286        ///
287        /// # Safety
288        ///
289        /// This might not be thread-safe.
290        #[unsafe(method(setRecordMatchedBlock:))]
291        #[unsafe(method_family = none)]
292        pub unsafe fn setRecordMatchedBlock(
293            &self,
294            record_matched_block: Option<
295                &block2::DynBlock<dyn Fn(NonNull<CKRecordID>, *mut CKRecord, *mut NSError)>,
296            >,
297        );
298
299        #[cfg(feature = "block2")]
300        /// This block is called when the operation completes.
301        ///
302        ///
303        /// The
304        ///
305        /// ```text
306        ///  -[NSOperation completionBlock]
307        /// ```
308        ///
309        /// will also be called if both are set.
310        /// If the error is
311        /// `CKErrorPartialFailure,`the error's userInfo dictionary contains a dictionary of recordIDs to errors keyed off of
312        /// `CKPartialErrorsByItemIDKey.`These errors are repeats of those sent back in previous
313        /// `recordMatchedBlock`invocations
314        /// Each
315        /// `CKOperation`instance has a private serial queue. This queue is used for all callback block invocations.
316        /// This block may share mutable state with other blocks assigned to this operation, but any such mutable state
317        /// should not be concurrently used outside of blocks assigned to this operation.
318        ///
319        /// This property is not atomic.
320        ///
321        /// # Safety
322        ///
323        /// - The returned block's argument 1 must be a valid pointer or null.
324        /// - The returned block's argument 2 must be a valid pointer or null.
325        /// - This might not be thread-safe.
326        #[unsafe(method(queryCompletionBlock))]
327        #[unsafe(method_family = none)]
328        pub unsafe fn queryCompletionBlock(
329            &self,
330        ) -> *mut block2::DynBlock<dyn Fn(*mut CKQueryCursor, *mut NSError)>;
331
332        #[cfg(feature = "block2")]
333        /// Setter for [`queryCompletionBlock`][Self::queryCompletionBlock].
334        ///
335        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
336        ///
337        /// # Safety
338        ///
339        /// This might not be thread-safe.
340        #[unsafe(method(setQueryCompletionBlock:))]
341        #[unsafe(method_family = none)]
342        pub unsafe fn setQueryCompletionBlock(
343            &self,
344            query_completion_block: Option<
345                &block2::DynBlock<dyn Fn(*mut CKQueryCursor, *mut NSError)>,
346            >,
347        );
348    );
349}
350
351/// Methods declared on superclass `NSObject`.
352#[cfg(all(feature = "CKDatabaseOperation", feature = "CKOperation"))]
353impl CKQueryOperation {
354    extern_methods!(
355        #[unsafe(method(new))]
356        #[unsafe(method_family = new)]
357        pub unsafe fn new() -> Retained<Self>;
358    );
359}