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 #[unsafe(method(query))]
92 #[unsafe(method_family = none)]
93 pub unsafe fn query(&self) -> Option<Retained<CKQuery>>;
94
95 #[cfg(feature = "CKQuery")]
96 /// Setter for [`query`][Self::query].
97 #[unsafe(method(setQuery:))]
98 #[unsafe(method_family = none)]
99 pub unsafe fn setQuery(&self, query: Option<&CKQuery>);
100
101 #[unsafe(method(cursor))]
102 #[unsafe(method_family = none)]
103 pub unsafe fn cursor(&self) -> Option<Retained<CKQueryCursor>>;
104
105 /// Setter for [`cursor`][Self::cursor].
106 #[unsafe(method(setCursor:))]
107 #[unsafe(method_family = none)]
108 pub unsafe fn setCursor(&self, cursor: Option<&CKQueryCursor>);
109
110 #[cfg(feature = "CKRecordZoneID")]
111 /// Indicates which record zone to query.
112 ///
113 ///
114 /// 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.
115 /// Queries that do not specify a
116 /// `zoneID`will perform a query across all zones in the database.
117 #[unsafe(method(zoneID))]
118 #[unsafe(method_family = none)]
119 pub unsafe fn zoneID(&self) -> Option<Retained<CKRecordZoneID>>;
120
121 #[cfg(feature = "CKRecordZoneID")]
122 /// Setter for [`zoneID`][Self::zoneID].
123 #[unsafe(method(setZoneID:))]
124 #[unsafe(method_family = none)]
125 pub unsafe fn setZoneID(&self, zone_id: Option<&CKRecordZoneID>);
126
127 /// Defaults to
128 /// `CKQueryOperationMaximumResults.`Queries may return fewer than
129 /// `resultsLimit`in some scenarios:
130 /// - There are legitimately fewer than
131 /// `resultsLimit`number of records matching the query (and visible to the current user).
132 /// - During the process of querying and fetching the results, some records were deleted, or became un-readable by the current user.
133 /// When determining if there are more records to fetch, always check for the presence of a cursor in
134 /// `queryCompletionBlock.`
135 #[unsafe(method(resultsLimit))]
136 #[unsafe(method_family = none)]
137 pub unsafe fn resultsLimit(&self) -> NSUInteger;
138
139 /// Setter for [`resultsLimit`][Self::resultsLimit].
140 #[unsafe(method(setResultsLimit:))]
141 #[unsafe(method_family = none)]
142 pub unsafe fn setResultsLimit(&self, results_limit: NSUInteger);
143
144 #[cfg(feature = "CKRecord")]
145 /// Declares which user-defined keys should be fetched and added to the resulting CKRecords.
146 ///
147 ///
148 /// If nil, declares the entire record should be downloaded. If set to an empty array, declares that no user fields should be downloaded.
149 /// Defaults to
150 /// `nil.`
151 #[unsafe(method(desiredKeys))]
152 #[unsafe(method_family = none)]
153 pub unsafe fn desiredKeys(&self) -> Option<Retained<NSArray<CKRecordFieldKey>>>;
154
155 #[cfg(feature = "CKRecord")]
156 /// Setter for [`desiredKeys`][Self::desiredKeys].
157 #[unsafe(method(setDesiredKeys:))]
158 #[unsafe(method_family = none)]
159 pub unsafe fn setDesiredKeys(&self, desired_keys: Option<&NSArray<CKRecordFieldKey>>);
160
161 #[cfg(all(feature = "CKRecord", feature = "block2"))]
162 /// This block will be called once for every record that is returned as a result of the query.
163 ///
164 ///
165 /// The callbacks will happen in the order that the results were sorted in.
166 /// If the replacement callback
167 /// `recordMatchedBlock`is set, this callback block is ignored.
168 /// Each
169 /// `CKOperation`instance has a private serial queue. This queue is used for all callback block invocations.
170 /// This block may share mutable state with other blocks assigned to this operation, but any such mutable state
171 /// should not be concurrently used outside of blocks assigned to this operation.
172 #[deprecated = "Use recordMatchedBlock instead, which surfaces per-record errors"]
173 #[unsafe(method(recordFetchedBlock))]
174 #[unsafe(method_family = none)]
175 pub unsafe fn recordFetchedBlock(&self)
176 -> *mut block2::DynBlock<dyn Fn(NonNull<CKRecord>)>;
177
178 #[cfg(all(feature = "CKRecord", feature = "block2"))]
179 /// Setter for [`recordFetchedBlock`][Self::recordFetchedBlock].
180 #[deprecated = "Use recordMatchedBlock instead, which surfaces per-record errors"]
181 #[unsafe(method(setRecordFetchedBlock:))]
182 #[unsafe(method_family = none)]
183 pub unsafe fn setRecordFetchedBlock(
184 &self,
185 record_fetched_block: Option<&block2::DynBlock<dyn Fn(NonNull<CKRecord>)>>,
186 );
187
188 #[cfg(all(feature = "CKRecord", feature = "CKRecordID", feature = "block2"))]
189 /// This block will be called once for every record that is returned as a result of the query.
190 ///
191 ///
192 /// 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
193 /// `CKAsset`record field), the per-record error will be passed here.
194 /// Each
195 /// `CKOperation`instance has a private serial queue. This queue is used for all callback block invocations.
196 /// This block may share mutable state with other blocks assigned to this operation, but any such mutable state
197 /// should not be concurrently used outside of blocks assigned to this operation.
198 #[unsafe(method(recordMatchedBlock))]
199 #[unsafe(method_family = none)]
200 pub unsafe fn recordMatchedBlock(
201 &self,
202 ) -> *mut block2::DynBlock<dyn Fn(NonNull<CKRecordID>, *mut CKRecord, *mut NSError)>;
203
204 #[cfg(all(feature = "CKRecord", feature = "CKRecordID", feature = "block2"))]
205 /// Setter for [`recordMatchedBlock`][Self::recordMatchedBlock].
206 #[unsafe(method(setRecordMatchedBlock:))]
207 #[unsafe(method_family = none)]
208 pub unsafe fn setRecordMatchedBlock(
209 &self,
210 record_matched_block: Option<
211 &block2::DynBlock<dyn Fn(NonNull<CKRecordID>, *mut CKRecord, *mut NSError)>,
212 >,
213 );
214
215 #[cfg(feature = "block2")]
216 /// This block is called when the operation completes.
217 ///
218 ///
219 /// The
220 ///
221 /// ```text
222 /// -[NSOperation completionBlock]
223 /// ```
224 ///
225 /// will also be called if both are set.
226 /// If the error is
227 /// `CKErrorPartialFailure,`the error's userInfo dictionary contains a dictionary of recordIDs to errors keyed off of
228 /// `CKPartialErrorsByItemIDKey.`These errors are repeats of those sent back in previous
229 /// `recordMatchedBlock`invocations
230 /// Each
231 /// `CKOperation`instance has a private serial queue. This queue is used for all callback block invocations.
232 /// This block may share mutable state with other blocks assigned to this operation, but any such mutable state
233 /// should not be concurrently used outside of blocks assigned to this operation.
234 #[unsafe(method(queryCompletionBlock))]
235 #[unsafe(method_family = none)]
236 pub unsafe fn queryCompletionBlock(
237 &self,
238 ) -> *mut block2::DynBlock<dyn Fn(*mut CKQueryCursor, *mut NSError)>;
239
240 #[cfg(feature = "block2")]
241 /// Setter for [`queryCompletionBlock`][Self::queryCompletionBlock].
242 #[unsafe(method(setQueryCompletionBlock:))]
243 #[unsafe(method_family = none)]
244 pub unsafe fn setQueryCompletionBlock(
245 &self,
246 query_completion_block: Option<
247 &block2::DynBlock<dyn Fn(*mut CKQueryCursor, *mut NSError)>,
248 >,
249 );
250 );
251}
252
253/// Methods declared on superclass `NSObject`.
254#[cfg(all(feature = "CKDatabaseOperation", feature = "CKOperation"))]
255impl CKQueryOperation {
256 extern_methods!(
257 #[unsafe(method(new))]
258 #[unsafe(method_family = new)]
259 pub unsafe fn new() -> Retained<Self>;
260 );
261}