objc2_core_data/generated/
NSFetchRequest.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/coredata/nsfetchrequestresulttype?language=objc)
11// NS_OPTIONS
12#[repr(transparent)]
13#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
14pub struct NSFetchRequestResultType(pub NSUInteger);
15bitflags::bitflags! {
16    impl NSFetchRequestResultType: NSUInteger {
17        #[doc(alias = "NSManagedObjectResultType")]
18        const ManagedObjectResultType = 0x00;
19        #[doc(alias = "NSManagedObjectIDResultType")]
20        const ManagedObjectIDResultType = 0x01;
21        #[doc(alias = "NSDictionaryResultType")]
22        const DictionaryResultType = 0x02;
23        #[doc(alias = "NSCountResultType")]
24        const CountResultType = 0x04;
25    }
26}
27
28unsafe impl Encode for NSFetchRequestResultType {
29    const ENCODING: Encoding = NSUInteger::ENCODING;
30}
31
32unsafe impl RefEncode for NSFetchRequestResultType {
33    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
34}
35
36extern_protocol!(
37    /// [Apple's documentation](https://developer.apple.com/documentation/coredata/nsfetchrequestresult?language=objc)
38    pub unsafe trait NSFetchRequestResult: NSObjectProtocol {}
39);
40
41extern_conformance!(
42    unsafe impl NSFetchRequestResult for NSNumber {}
43);
44
45extern_conformance!(
46    unsafe impl NSFetchRequestResult for NSDictionary {}
47);
48
49/// NSFetchedResultSupport.
50#[cfg(feature = "NSManagedObject")]
51impl NSManagedObject {
52    extern_methods!();
53}
54
55#[cfg(feature = "NSManagedObject")]
56extern_conformance!(
57    unsafe impl NSFetchRequestResult for NSManagedObject {}
58);
59
60/// NSFetchedResultSupport.
61#[cfg(feature = "NSManagedObjectID")]
62impl NSManagedObjectID {
63    extern_methods!();
64}
65
66#[cfg(feature = "NSManagedObjectID")]
67extern_conformance!(
68    unsafe impl NSFetchRequestResult for NSManagedObjectID {}
69);
70
71extern_class!(
72    /// [Apple's documentation](https://developer.apple.com/documentation/coredata/nsfetchrequest?language=objc)
73    #[unsafe(super(NSPersistentStoreRequest, NSObject))]
74    #[derive(Debug, PartialEq, Eq, Hash)]
75    #[cfg(feature = "NSPersistentStoreRequest")]
76    pub struct NSFetchRequest<ResultType: ?Sized = AnyObject>;
77);
78
79#[cfg(feature = "NSPersistentStoreRequest")]
80extern_conformance!(
81    unsafe impl<ResultType: ?Sized + NSCoding> NSCoding for NSFetchRequest<ResultType> {}
82);
83
84#[cfg(feature = "NSPersistentStoreRequest")]
85extern_conformance!(
86    unsafe impl<ResultType: ?Sized> NSCopying for NSFetchRequest<ResultType> {}
87);
88
89#[cfg(feature = "NSPersistentStoreRequest")]
90unsafe impl<ResultType: ?Sized + Message> CopyingHelper for NSFetchRequest<ResultType> {
91    type Result = Self;
92}
93
94#[cfg(feature = "NSPersistentStoreRequest")]
95extern_conformance!(
96    unsafe impl<ResultType: ?Sized> NSObjectProtocol for NSFetchRequest<ResultType> {}
97);
98
99#[cfg(feature = "NSPersistentStoreRequest")]
100impl<ResultType: Message> NSFetchRequest<ResultType> {
101    extern_methods!(
102        #[unsafe(method(fetchRequestWithEntityName:))]
103        #[unsafe(method_family = none)]
104        pub unsafe fn fetchRequestWithEntityName(entity_name: &NSString) -> Retained<Self>;
105
106        #[unsafe(method(init))]
107        #[unsafe(method_family = init)]
108        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
109
110        #[unsafe(method(initWithEntityName:))]
111        #[unsafe(method_family = init)]
112        pub unsafe fn initWithEntityName(
113            this: Allocated<Self>,
114            entity_name: &NSString,
115        ) -> Retained<Self>;
116
117        #[unsafe(method(execute:_))]
118        #[unsafe(method_family = none)]
119        pub unsafe fn execute(&self) -> Result<Retained<NSArray<ResultType>>, Retained<NSError>>;
120
121        #[cfg(feature = "NSEntityDescription")]
122        #[unsafe(method(entity))]
123        #[unsafe(method_family = none)]
124        pub unsafe fn entity(&self) -> Option<Retained<NSEntityDescription>>;
125
126        #[cfg(feature = "NSEntityDescription")]
127        /// Setter for [`entity`][Self::entity].
128        #[unsafe(method(setEntity:))]
129        #[unsafe(method_family = none)]
130        pub unsafe fn setEntity(&self, entity: Option<&NSEntityDescription>);
131
132        #[unsafe(method(entityName))]
133        #[unsafe(method_family = none)]
134        pub unsafe fn entityName(&self) -> Option<Retained<NSString>>;
135
136        #[unsafe(method(predicate))]
137        #[unsafe(method_family = none)]
138        pub unsafe fn predicate(&self) -> Option<Retained<NSPredicate>>;
139
140        /// Setter for [`predicate`][Self::predicate].
141        #[unsafe(method(setPredicate:))]
142        #[unsafe(method_family = none)]
143        pub unsafe fn setPredicate(&self, predicate: Option<&NSPredicate>);
144
145        #[unsafe(method(sortDescriptors))]
146        #[unsafe(method_family = none)]
147        pub unsafe fn sortDescriptors(&self) -> Option<Retained<NSArray<NSSortDescriptor>>>;
148
149        /// Setter for [`sortDescriptors`][Self::sortDescriptors].
150        #[unsafe(method(setSortDescriptors:))]
151        #[unsafe(method_family = none)]
152        pub unsafe fn setSortDescriptors(
153            &self,
154            sort_descriptors: Option<&NSArray<NSSortDescriptor>>,
155        );
156
157        #[unsafe(method(fetchLimit))]
158        #[unsafe(method_family = none)]
159        pub unsafe fn fetchLimit(&self) -> NSUInteger;
160
161        /// Setter for [`fetchLimit`][Self::fetchLimit].
162        #[unsafe(method(setFetchLimit:))]
163        #[unsafe(method_family = none)]
164        pub unsafe fn setFetchLimit(&self, fetch_limit: NSUInteger);
165
166        #[cfg(feature = "NSPersistentStore")]
167        #[unsafe(method(affectedStores))]
168        #[unsafe(method_family = none)]
169        pub unsafe fn affectedStores(&self) -> Option<Retained<NSArray<NSPersistentStore>>>;
170
171        #[cfg(feature = "NSPersistentStore")]
172        /// Setter for [`affectedStores`][Self::affectedStores].
173        #[unsafe(method(setAffectedStores:))]
174        #[unsafe(method_family = none)]
175        pub unsafe fn setAffectedStores(
176            &self,
177            affected_stores: Option<&NSArray<NSPersistentStore>>,
178        );
179
180        #[unsafe(method(resultType))]
181        #[unsafe(method_family = none)]
182        pub unsafe fn resultType(&self) -> NSFetchRequestResultType;
183
184        /// Setter for [`resultType`][Self::resultType].
185        #[unsafe(method(setResultType:))]
186        #[unsafe(method_family = none)]
187        pub unsafe fn setResultType(&self, result_type: NSFetchRequestResultType);
188
189        #[unsafe(method(includesSubentities))]
190        #[unsafe(method_family = none)]
191        pub unsafe fn includesSubentities(&self) -> bool;
192
193        /// Setter for [`includesSubentities`][Self::includesSubentities].
194        #[unsafe(method(setIncludesSubentities:))]
195        #[unsafe(method_family = none)]
196        pub unsafe fn setIncludesSubentities(&self, includes_subentities: bool);
197
198        #[unsafe(method(includesPropertyValues))]
199        #[unsafe(method_family = none)]
200        pub unsafe fn includesPropertyValues(&self) -> bool;
201
202        /// Setter for [`includesPropertyValues`][Self::includesPropertyValues].
203        #[unsafe(method(setIncludesPropertyValues:))]
204        #[unsafe(method_family = none)]
205        pub unsafe fn setIncludesPropertyValues(&self, includes_property_values: bool);
206
207        #[unsafe(method(returnsObjectsAsFaults))]
208        #[unsafe(method_family = none)]
209        pub unsafe fn returnsObjectsAsFaults(&self) -> bool;
210
211        /// Setter for [`returnsObjectsAsFaults`][Self::returnsObjectsAsFaults].
212        #[unsafe(method(setReturnsObjectsAsFaults:))]
213        #[unsafe(method_family = none)]
214        pub unsafe fn setReturnsObjectsAsFaults(&self, returns_objects_as_faults: bool);
215
216        #[unsafe(method(relationshipKeyPathsForPrefetching))]
217        #[unsafe(method_family = none)]
218        pub unsafe fn relationshipKeyPathsForPrefetching(
219            &self,
220        ) -> Option<Retained<NSArray<NSString>>>;
221
222        /// Setter for [`relationshipKeyPathsForPrefetching`][Self::relationshipKeyPathsForPrefetching].
223        #[unsafe(method(setRelationshipKeyPathsForPrefetching:))]
224        #[unsafe(method_family = none)]
225        pub unsafe fn setRelationshipKeyPathsForPrefetching(
226            &self,
227            relationship_key_paths_for_prefetching: Option<&NSArray<NSString>>,
228        );
229
230        #[unsafe(method(includesPendingChanges))]
231        #[unsafe(method_family = none)]
232        pub unsafe fn includesPendingChanges(&self) -> bool;
233
234        /// Setter for [`includesPendingChanges`][Self::includesPendingChanges].
235        #[unsafe(method(setIncludesPendingChanges:))]
236        #[unsafe(method_family = none)]
237        pub unsafe fn setIncludesPendingChanges(&self, includes_pending_changes: bool);
238
239        #[unsafe(method(returnsDistinctResults))]
240        #[unsafe(method_family = none)]
241        pub unsafe fn returnsDistinctResults(&self) -> bool;
242
243        /// Setter for [`returnsDistinctResults`][Self::returnsDistinctResults].
244        #[unsafe(method(setReturnsDistinctResults:))]
245        #[unsafe(method_family = none)]
246        pub unsafe fn setReturnsDistinctResults(&self, returns_distinct_results: bool);
247
248        #[unsafe(method(propertiesToFetch))]
249        #[unsafe(method_family = none)]
250        pub unsafe fn propertiesToFetch(&self) -> Option<Retained<NSArray>>;
251
252        /// Setter for [`propertiesToFetch`][Self::propertiesToFetch].
253        #[unsafe(method(setPropertiesToFetch:))]
254        #[unsafe(method_family = none)]
255        pub unsafe fn setPropertiesToFetch(&self, properties_to_fetch: Option<&NSArray>);
256
257        #[unsafe(method(fetchOffset))]
258        #[unsafe(method_family = none)]
259        pub unsafe fn fetchOffset(&self) -> NSUInteger;
260
261        /// Setter for [`fetchOffset`][Self::fetchOffset].
262        #[unsafe(method(setFetchOffset:))]
263        #[unsafe(method_family = none)]
264        pub unsafe fn setFetchOffset(&self, fetch_offset: NSUInteger);
265
266        #[unsafe(method(fetchBatchSize))]
267        #[unsafe(method_family = none)]
268        pub unsafe fn fetchBatchSize(&self) -> NSUInteger;
269
270        /// Setter for [`fetchBatchSize`][Self::fetchBatchSize].
271        #[unsafe(method(setFetchBatchSize:))]
272        #[unsafe(method_family = none)]
273        pub unsafe fn setFetchBatchSize(&self, fetch_batch_size: NSUInteger);
274
275        #[unsafe(method(shouldRefreshRefetchedObjects))]
276        #[unsafe(method_family = none)]
277        pub unsafe fn shouldRefreshRefetchedObjects(&self) -> bool;
278
279        /// Setter for [`shouldRefreshRefetchedObjects`][Self::shouldRefreshRefetchedObjects].
280        #[unsafe(method(setShouldRefreshRefetchedObjects:))]
281        #[unsafe(method_family = none)]
282        pub unsafe fn setShouldRefreshRefetchedObjects(
283            &self,
284            should_refresh_refetched_objects: bool,
285        );
286
287        #[unsafe(method(propertiesToGroupBy))]
288        #[unsafe(method_family = none)]
289        pub unsafe fn propertiesToGroupBy(&self) -> Option<Retained<NSArray>>;
290
291        /// Setter for [`propertiesToGroupBy`][Self::propertiesToGroupBy].
292        #[unsafe(method(setPropertiesToGroupBy:))]
293        #[unsafe(method_family = none)]
294        pub unsafe fn setPropertiesToGroupBy(&self, properties_to_group_by: Option<&NSArray>);
295
296        #[unsafe(method(havingPredicate))]
297        #[unsafe(method_family = none)]
298        pub unsafe fn havingPredicate(&self) -> Option<Retained<NSPredicate>>;
299
300        /// Setter for [`havingPredicate`][Self::havingPredicate].
301        #[unsafe(method(setHavingPredicate:))]
302        #[unsafe(method_family = none)]
303        pub unsafe fn setHavingPredicate(&self, having_predicate: Option<&NSPredicate>);
304    );
305}
306
307/// Methods declared on superclass `NSObject`.
308#[cfg(feature = "NSPersistentStoreRequest")]
309impl<ResultType: Message> NSFetchRequest<ResultType> {
310    extern_methods!(
311        #[unsafe(method(new))]
312        #[unsafe(method_family = new)]
313        pub unsafe fn new() -> Retained<Self>;
314    );
315}
316
317/// [Apple's documentation](https://developer.apple.com/documentation/coredata/nspersistentstoreasynchronousfetchresultcompletionblock?language=objc)
318#[cfg(all(feature = "NSPersistentStoreResult", feature = "block2"))]
319pub type NSPersistentStoreAsynchronousFetchResultCompletionBlock =
320    *mut block2::DynBlock<dyn Fn(NonNull<NSAsynchronousFetchResult>)>;
321
322extern_class!(
323    /// [Apple's documentation](https://developer.apple.com/documentation/coredata/nsasynchronousfetchrequest?language=objc)
324    #[unsafe(super(NSPersistentStoreRequest, NSObject))]
325    #[derive(Debug, PartialEq, Eq, Hash)]
326    #[cfg(feature = "NSPersistentStoreRequest")]
327    pub struct NSAsynchronousFetchRequest<ResultType: ?Sized = AnyObject>;
328);
329
330#[cfg(feature = "NSPersistentStoreRequest")]
331extern_conformance!(
332    unsafe impl<ResultType: ?Sized> NSCopying for NSAsynchronousFetchRequest<ResultType> {}
333);
334
335#[cfg(feature = "NSPersistentStoreRequest")]
336unsafe impl<ResultType: ?Sized + Message> CopyingHelper for NSAsynchronousFetchRequest<ResultType> {
337    type Result = Self;
338}
339
340#[cfg(feature = "NSPersistentStoreRequest")]
341extern_conformance!(
342    unsafe impl<ResultType: ?Sized> NSObjectProtocol for NSAsynchronousFetchRequest<ResultType> {}
343);
344
345#[cfg(feature = "NSPersistentStoreRequest")]
346impl<ResultType: Message> NSAsynchronousFetchRequest<ResultType> {
347    extern_methods!(
348        #[unsafe(method(fetchRequest))]
349        #[unsafe(method_family = none)]
350        pub unsafe fn fetchRequest(&self) -> Retained<NSFetchRequest<ResultType>>;
351
352        #[cfg(all(feature = "NSPersistentStoreResult", feature = "block2"))]
353        #[unsafe(method(completionBlock))]
354        #[unsafe(method_family = none)]
355        pub unsafe fn completionBlock(
356            &self,
357        ) -> NSPersistentStoreAsynchronousFetchResultCompletionBlock;
358
359        #[unsafe(method(estimatedResultCount))]
360        #[unsafe(method_family = none)]
361        pub unsafe fn estimatedResultCount(&self) -> NSInteger;
362
363        /// Setter for [`estimatedResultCount`][Self::estimatedResultCount].
364        #[unsafe(method(setEstimatedResultCount:))]
365        #[unsafe(method_family = none)]
366        pub unsafe fn setEstimatedResultCount(&self, estimated_result_count: NSInteger);
367
368        #[cfg(all(feature = "NSPersistentStoreResult", feature = "block2"))]
369        #[unsafe(method(initWithFetchRequest:completionBlock:))]
370        #[unsafe(method_family = init)]
371        pub unsafe fn initWithFetchRequest_completionBlock(
372            this: Allocated<Self>,
373            request: &NSFetchRequest<ResultType>,
374            blk: Option<&block2::DynBlock<dyn Fn(NonNull<NSAsynchronousFetchResult<ResultType>>)>>,
375        ) -> Retained<Self>;
376    );
377}
378
379/// Methods declared on superclass `NSObject`.
380#[cfg(feature = "NSPersistentStoreRequest")]
381impl<ResultType: Message> NSAsynchronousFetchRequest<ResultType> {
382    extern_methods!(
383        #[unsafe(method(init))]
384        #[unsafe(method_family = init)]
385        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
386
387        #[unsafe(method(new))]
388        #[unsafe(method_family = new)]
389        pub unsafe fn new() -> Retained<Self>;
390    );
391}