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
17unsafe impl NSCoding for CKQueryCursor {}
18
19unsafe impl NSCopying for CKQueryCursor {}
20
21unsafe impl CopyingHelper for CKQueryCursor {
22    type Result = Self;
23}
24
25unsafe impl NSObjectProtocol for CKQueryCursor {}
26
27unsafe impl NSSecureCoding for CKQueryCursor {}
28
29impl CKQueryCursor {
30    extern_methods!(
31        #[unsafe(method(init))]
32        #[unsafe(method_family = init)]
33        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
34
35        #[unsafe(method(new))]
36        #[unsafe(method_family = new)]
37        pub unsafe fn new() -> Retained<Self>;
38    );
39}
40
41extern "C" {
42    /// 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.
43    /// Issue a new query with that cursor to fetch the next batch of results.
44    ///
45    /// See also [Apple's documentation](https://developer.apple.com/documentation/cloudkit/ckqueryoperationmaximumresults?language=objc)
46    pub static CKQueryOperationMaximumResults: NSUInteger;
47}
48
49extern_class!(
50    /// [Apple's documentation](https://developer.apple.com/documentation/cloudkit/ckqueryoperation?language=objc)
51    #[unsafe(super(CKDatabaseOperation, CKOperation, NSOperation, NSObject))]
52    #[derive(Debug, PartialEq, Eq, Hash)]
53    #[cfg(all(feature = "CKDatabaseOperation", feature = "CKOperation"))]
54    pub struct CKQueryOperation;
55);
56
57#[cfg(all(feature = "CKDatabaseOperation", feature = "CKOperation"))]
58unsafe impl NSObjectProtocol for CKQueryOperation {}
59
60#[cfg(all(feature = "CKDatabaseOperation", feature = "CKOperation"))]
61impl CKQueryOperation {
62    extern_methods!(
63        /// Queries invoked within a sharedCloudDatabase must specify a zoneID.  Cross-zone queries are not supported in a sharedCloudDatabase
64        #[unsafe(method(init))]
65        #[unsafe(method_family = init)]
66        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
67
68        #[cfg(feature = "CKQuery")]
69        #[unsafe(method(initWithQuery:))]
70        #[unsafe(method_family = init)]
71        pub unsafe fn initWithQuery(this: Allocated<Self>, query: &CKQuery) -> Retained<Self>;
72
73        #[unsafe(method(initWithCursor:))]
74        #[unsafe(method_family = init)]
75        pub unsafe fn initWithCursor(
76            this: Allocated<Self>,
77            cursor: &CKQueryCursor,
78        ) -> Retained<Self>;
79
80        #[cfg(feature = "CKQuery")]
81        #[unsafe(method(query))]
82        #[unsafe(method_family = none)]
83        pub unsafe fn query(&self) -> Option<Retained<CKQuery>>;
84
85        #[cfg(feature = "CKQuery")]
86        /// Setter for [`query`][Self::query].
87        #[unsafe(method(setQuery:))]
88        #[unsafe(method_family = none)]
89        pub unsafe fn setQuery(&self, query: Option<&CKQuery>);
90
91        #[unsafe(method(cursor))]
92        #[unsafe(method_family = none)]
93        pub unsafe fn cursor(&self) -> Option<Retained<CKQueryCursor>>;
94
95        /// Setter for [`cursor`][Self::cursor].
96        #[unsafe(method(setCursor:))]
97        #[unsafe(method_family = none)]
98        pub unsafe fn setCursor(&self, cursor: Option<&CKQueryCursor>);
99
100        #[cfg(feature = "CKRecordZoneID")]
101        /// Indicates which record zone to query.
102        ///
103        ///
104        /// 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.
105        /// Queries that do not specify a
106        /// `zoneID`will perform a query across all zones in the database.
107        #[unsafe(method(zoneID))]
108        #[unsafe(method_family = none)]
109        pub unsafe fn zoneID(&self) -> Option<Retained<CKRecordZoneID>>;
110
111        #[cfg(feature = "CKRecordZoneID")]
112        /// Setter for [`zoneID`][Self::zoneID].
113        #[unsafe(method(setZoneID:))]
114        #[unsafe(method_family = none)]
115        pub unsafe fn setZoneID(&self, zone_id: Option<&CKRecordZoneID>);
116
117        /// Defaults to
118        /// `CKQueryOperationMaximumResults.`Queries may return fewer than
119        /// `resultsLimit`in some scenarios:
120        /// - There are legitimately fewer than
121        /// `resultsLimit`number of records matching the query (and visible to the current user).
122        /// - During the process of querying and fetching the results, some records were deleted, or became un-readable by the current user.
123        /// When determining if there are more records to fetch, always check for the presence of a cursor in
124        /// `queryCompletionBlock.`
125        #[unsafe(method(resultsLimit))]
126        #[unsafe(method_family = none)]
127        pub unsafe fn resultsLimit(&self) -> NSUInteger;
128
129        /// Setter for [`resultsLimit`][Self::resultsLimit].
130        #[unsafe(method(setResultsLimit:))]
131        #[unsafe(method_family = none)]
132        pub unsafe fn setResultsLimit(&self, results_limit: NSUInteger);
133
134        #[cfg(feature = "CKRecord")]
135        /// Declares which user-defined keys should be fetched and added to the resulting CKRecords.
136        ///
137        ///
138        /// If nil, declares the entire record should be downloaded. If set to an empty array, declares that no user fields should be downloaded.
139        /// Defaults to
140        /// `nil.`
141        #[unsafe(method(desiredKeys))]
142        #[unsafe(method_family = none)]
143        pub unsafe fn desiredKeys(&self) -> Option<Retained<NSArray<CKRecordFieldKey>>>;
144
145        #[cfg(feature = "CKRecord")]
146        /// Setter for [`desiredKeys`][Self::desiredKeys].
147        #[unsafe(method(setDesiredKeys:))]
148        #[unsafe(method_family = none)]
149        pub unsafe fn setDesiredKeys(&self, desired_keys: Option<&NSArray<CKRecordFieldKey>>);
150
151        #[cfg(all(feature = "CKRecord", feature = "block2"))]
152        /// This block will be called once for every record that is returned as a result of the query.
153        ///
154        ///
155        /// The callbacks will happen in the order that the results were sorted in.
156        /// If the replacement callback
157        /// `recordMatchedBlock`is set, this callback block is ignored.
158        /// Each
159        /// `CKOperation`instance has a private serial queue. This queue is used for all callback block invocations.
160        /// This block may share mutable state with other blocks assigned to this operation, but any such mutable state
161        /// should not be concurrently used outside of blocks assigned to this operation.
162        #[deprecated = "Use recordMatchedBlock instead, which surfaces per-record errors"]
163        #[unsafe(method(recordFetchedBlock))]
164        #[unsafe(method_family = none)]
165        pub unsafe fn recordFetchedBlock(&self) -> *mut block2::Block<dyn Fn(NonNull<CKRecord>)>;
166
167        #[cfg(all(feature = "CKRecord", feature = "block2"))]
168        /// Setter for [`recordFetchedBlock`][Self::recordFetchedBlock].
169        #[deprecated = "Use recordMatchedBlock instead, which surfaces per-record errors"]
170        #[unsafe(method(setRecordFetchedBlock:))]
171        #[unsafe(method_family = none)]
172        pub unsafe fn setRecordFetchedBlock(
173            &self,
174            record_fetched_block: Option<&block2::Block<dyn Fn(NonNull<CKRecord>)>>,
175        );
176
177        #[cfg(all(feature = "CKRecord", feature = "CKRecordID", feature = "block2"))]
178        /// This block will be called once for every record that is returned as a result of the query.
179        ///
180        ///
181        /// 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
182        /// `CKAsset`record field), the per-record error will be passed here.
183        /// Each
184        /// `CKOperation`instance has a private serial queue. This queue is used for all callback block invocations.
185        /// This block may share mutable state with other blocks assigned to this operation, but any such mutable state
186        /// should not be concurrently used outside of blocks assigned to this operation.
187        #[unsafe(method(recordMatchedBlock))]
188        #[unsafe(method_family = none)]
189        pub unsafe fn recordMatchedBlock(
190            &self,
191        ) -> *mut block2::Block<dyn Fn(NonNull<CKRecordID>, *mut CKRecord, *mut NSError)>;
192
193        #[cfg(all(feature = "CKRecord", feature = "CKRecordID", feature = "block2"))]
194        /// Setter for [`recordMatchedBlock`][Self::recordMatchedBlock].
195        #[unsafe(method(setRecordMatchedBlock:))]
196        #[unsafe(method_family = none)]
197        pub unsafe fn setRecordMatchedBlock(
198            &self,
199            record_matched_block: Option<
200                &block2::Block<dyn Fn(NonNull<CKRecordID>, *mut CKRecord, *mut NSError)>,
201            >,
202        );
203
204        #[cfg(feature = "block2")]
205        /// This block is called when the operation completes.
206        ///
207        ///
208        /// The
209        ///
210        /// ```text
211        ///  -[NSOperation completionBlock]
212        /// ```
213        ///
214        /// will also be called if both are set.
215        /// If the error is
216        /// `CKErrorPartialFailure,`the error's userInfo dictionary contains a dictionary of recordIDs to errors keyed off of
217        /// `CKPartialErrorsByItemIDKey.`These errors are repeats of those sent back in previous
218        /// `recordMatchedBlock`invocations
219        /// Each
220        /// `CKOperation`instance has a private serial queue. This queue is used for all callback block invocations.
221        /// This block may share mutable state with other blocks assigned to this operation, but any such mutable state
222        /// should not be concurrently used outside of blocks assigned to this operation.
223        #[unsafe(method(queryCompletionBlock))]
224        #[unsafe(method_family = none)]
225        pub unsafe fn queryCompletionBlock(
226            &self,
227        ) -> *mut block2::Block<dyn Fn(*mut CKQueryCursor, *mut NSError)>;
228
229        #[cfg(feature = "block2")]
230        /// Setter for [`queryCompletionBlock`][Self::queryCompletionBlock].
231        #[unsafe(method(setQueryCompletionBlock:))]
232        #[unsafe(method_family = none)]
233        pub unsafe fn setQueryCompletionBlock(
234            &self,
235            query_completion_block: Option<
236                &block2::Block<dyn Fn(*mut CKQueryCursor, *mut NSError)>,
237            >,
238        );
239    );
240}
241
242/// Methods declared on superclass `NSObject`.
243#[cfg(all(feature = "CKDatabaseOperation", feature = "CKOperation"))]
244impl CKQueryOperation {
245    extern_methods!(
246        #[unsafe(method(new))]
247        #[unsafe(method_family = new)]
248        pub unsafe fn new() -> Retained<Self>;
249    );
250}