objc2_core_data/generated/
NSFetchRequest.rs1use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10#[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 pub unsafe trait NSFetchRequestResult: NSObjectProtocol {}
39);
40
41unsafe impl NSFetchRequestResult for NSNumber {}
42
43unsafe impl NSFetchRequestResult for NSDictionary {}
44
45#[cfg(feature = "NSManagedObject")]
47impl NSManagedObject {
48 extern_methods!();
49}
50
51#[cfg(feature = "NSManagedObject")]
52unsafe impl NSFetchRequestResult for NSManagedObject {}
53
54#[cfg(feature = "NSManagedObjectID")]
56impl NSManagedObjectID {
57 extern_methods!();
58}
59
60#[cfg(feature = "NSManagedObjectID")]
61unsafe impl NSFetchRequestResult for NSManagedObjectID {}
62
63extern_class!(
64 #[unsafe(super(NSPersistentStoreRequest, NSObject))]
66 #[derive(Debug, PartialEq, Eq, Hash)]
67 #[cfg(feature = "NSPersistentStoreRequest")]
68 pub struct NSFetchRequest<ResultType: ?Sized = AnyObject>;
69);
70
71#[cfg(feature = "NSPersistentStoreRequest")]
72unsafe impl<ResultType: ?Sized + NSCoding> NSCoding for NSFetchRequest<ResultType> {}
73
74#[cfg(feature = "NSPersistentStoreRequest")]
75unsafe impl<ResultType: ?Sized> NSCopying for NSFetchRequest<ResultType> {}
76
77#[cfg(feature = "NSPersistentStoreRequest")]
78unsafe impl<ResultType: ?Sized + Message> CopyingHelper for NSFetchRequest<ResultType> {
79 type Result = Self;
80}
81
82#[cfg(feature = "NSPersistentStoreRequest")]
83unsafe impl<ResultType: ?Sized> NSObjectProtocol for NSFetchRequest<ResultType> {}
84
85#[cfg(feature = "NSPersistentStoreRequest")]
86impl<ResultType: Message> NSFetchRequest<ResultType> {
87 extern_methods!(
88 #[unsafe(method(fetchRequestWithEntityName:))]
89 #[unsafe(method_family = none)]
90 pub unsafe fn fetchRequestWithEntityName(entity_name: &NSString) -> Retained<Self>;
91
92 #[unsafe(method(init))]
93 #[unsafe(method_family = init)]
94 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
95
96 #[unsafe(method(initWithEntityName:))]
97 #[unsafe(method_family = init)]
98 pub unsafe fn initWithEntityName(
99 this: Allocated<Self>,
100 entity_name: &NSString,
101 ) -> Retained<Self>;
102
103 #[unsafe(method(execute:_))]
104 #[unsafe(method_family = none)]
105 pub unsafe fn execute(&self) -> Result<Retained<NSArray<ResultType>>, Retained<NSError>>;
106
107 #[cfg(feature = "NSEntityDescription")]
108 #[unsafe(method(entity))]
109 #[unsafe(method_family = none)]
110 pub unsafe fn entity(&self) -> Option<Retained<NSEntityDescription>>;
111
112 #[cfg(feature = "NSEntityDescription")]
113 #[unsafe(method(setEntity:))]
115 #[unsafe(method_family = none)]
116 pub unsafe fn setEntity(&self, entity: Option<&NSEntityDescription>);
117
118 #[unsafe(method(entityName))]
119 #[unsafe(method_family = none)]
120 pub unsafe fn entityName(&self) -> Option<Retained<NSString>>;
121
122 #[unsafe(method(predicate))]
123 #[unsafe(method_family = none)]
124 pub unsafe fn predicate(&self) -> Option<Retained<NSPredicate>>;
125
126 #[unsafe(method(setPredicate:))]
128 #[unsafe(method_family = none)]
129 pub unsafe fn setPredicate(&self, predicate: Option<&NSPredicate>);
130
131 #[unsafe(method(sortDescriptors))]
132 #[unsafe(method_family = none)]
133 pub unsafe fn sortDescriptors(&self) -> Option<Retained<NSArray<NSSortDescriptor>>>;
134
135 #[unsafe(method(setSortDescriptors:))]
137 #[unsafe(method_family = none)]
138 pub unsafe fn setSortDescriptors(
139 &self,
140 sort_descriptors: Option<&NSArray<NSSortDescriptor>>,
141 );
142
143 #[unsafe(method(fetchLimit))]
144 #[unsafe(method_family = none)]
145 pub unsafe fn fetchLimit(&self) -> NSUInteger;
146
147 #[unsafe(method(setFetchLimit:))]
149 #[unsafe(method_family = none)]
150 pub unsafe fn setFetchLimit(&self, fetch_limit: NSUInteger);
151
152 #[cfg(feature = "NSPersistentStore")]
153 #[unsafe(method(affectedStores))]
154 #[unsafe(method_family = none)]
155 pub unsafe fn affectedStores(&self) -> Option<Retained<NSArray<NSPersistentStore>>>;
156
157 #[cfg(feature = "NSPersistentStore")]
158 #[unsafe(method(setAffectedStores:))]
160 #[unsafe(method_family = none)]
161 pub unsafe fn setAffectedStores(
162 &self,
163 affected_stores: Option<&NSArray<NSPersistentStore>>,
164 );
165
166 #[unsafe(method(resultType))]
167 #[unsafe(method_family = none)]
168 pub unsafe fn resultType(&self) -> NSFetchRequestResultType;
169
170 #[unsafe(method(setResultType:))]
172 #[unsafe(method_family = none)]
173 pub unsafe fn setResultType(&self, result_type: NSFetchRequestResultType);
174
175 #[unsafe(method(includesSubentities))]
176 #[unsafe(method_family = none)]
177 pub unsafe fn includesSubentities(&self) -> bool;
178
179 #[unsafe(method(setIncludesSubentities:))]
181 #[unsafe(method_family = none)]
182 pub unsafe fn setIncludesSubentities(&self, includes_subentities: bool);
183
184 #[unsafe(method(includesPropertyValues))]
185 #[unsafe(method_family = none)]
186 pub unsafe fn includesPropertyValues(&self) -> bool;
187
188 #[unsafe(method(setIncludesPropertyValues:))]
190 #[unsafe(method_family = none)]
191 pub unsafe fn setIncludesPropertyValues(&self, includes_property_values: bool);
192
193 #[unsafe(method(returnsObjectsAsFaults))]
194 #[unsafe(method_family = none)]
195 pub unsafe fn returnsObjectsAsFaults(&self) -> bool;
196
197 #[unsafe(method(setReturnsObjectsAsFaults:))]
199 #[unsafe(method_family = none)]
200 pub unsafe fn setReturnsObjectsAsFaults(&self, returns_objects_as_faults: bool);
201
202 #[unsafe(method(relationshipKeyPathsForPrefetching))]
203 #[unsafe(method_family = none)]
204 pub unsafe fn relationshipKeyPathsForPrefetching(
205 &self,
206 ) -> Option<Retained<NSArray<NSString>>>;
207
208 #[unsafe(method(setRelationshipKeyPathsForPrefetching:))]
210 #[unsafe(method_family = none)]
211 pub unsafe fn setRelationshipKeyPathsForPrefetching(
212 &self,
213 relationship_key_paths_for_prefetching: Option<&NSArray<NSString>>,
214 );
215
216 #[unsafe(method(includesPendingChanges))]
217 #[unsafe(method_family = none)]
218 pub unsafe fn includesPendingChanges(&self) -> bool;
219
220 #[unsafe(method(setIncludesPendingChanges:))]
222 #[unsafe(method_family = none)]
223 pub unsafe fn setIncludesPendingChanges(&self, includes_pending_changes: bool);
224
225 #[unsafe(method(returnsDistinctResults))]
226 #[unsafe(method_family = none)]
227 pub unsafe fn returnsDistinctResults(&self) -> bool;
228
229 #[unsafe(method(setReturnsDistinctResults:))]
231 #[unsafe(method_family = none)]
232 pub unsafe fn setReturnsDistinctResults(&self, returns_distinct_results: bool);
233
234 #[unsafe(method(propertiesToFetch))]
235 #[unsafe(method_family = none)]
236 pub unsafe fn propertiesToFetch(&self) -> Option<Retained<NSArray>>;
237
238 #[unsafe(method(setPropertiesToFetch:))]
240 #[unsafe(method_family = none)]
241 pub unsafe fn setPropertiesToFetch(&self, properties_to_fetch: Option<&NSArray>);
242
243 #[unsafe(method(fetchOffset))]
244 #[unsafe(method_family = none)]
245 pub unsafe fn fetchOffset(&self) -> NSUInteger;
246
247 #[unsafe(method(setFetchOffset:))]
249 #[unsafe(method_family = none)]
250 pub unsafe fn setFetchOffset(&self, fetch_offset: NSUInteger);
251
252 #[unsafe(method(fetchBatchSize))]
253 #[unsafe(method_family = none)]
254 pub unsafe fn fetchBatchSize(&self) -> NSUInteger;
255
256 #[unsafe(method(setFetchBatchSize:))]
258 #[unsafe(method_family = none)]
259 pub unsafe fn setFetchBatchSize(&self, fetch_batch_size: NSUInteger);
260
261 #[unsafe(method(shouldRefreshRefetchedObjects))]
262 #[unsafe(method_family = none)]
263 pub unsafe fn shouldRefreshRefetchedObjects(&self) -> bool;
264
265 #[unsafe(method(setShouldRefreshRefetchedObjects:))]
267 #[unsafe(method_family = none)]
268 pub unsafe fn setShouldRefreshRefetchedObjects(
269 &self,
270 should_refresh_refetched_objects: bool,
271 );
272
273 #[unsafe(method(propertiesToGroupBy))]
274 #[unsafe(method_family = none)]
275 pub unsafe fn propertiesToGroupBy(&self) -> Option<Retained<NSArray>>;
276
277 #[unsafe(method(setPropertiesToGroupBy:))]
279 #[unsafe(method_family = none)]
280 pub unsafe fn setPropertiesToGroupBy(&self, properties_to_group_by: Option<&NSArray>);
281
282 #[unsafe(method(havingPredicate))]
283 #[unsafe(method_family = none)]
284 pub unsafe fn havingPredicate(&self) -> Option<Retained<NSPredicate>>;
285
286 #[unsafe(method(setHavingPredicate:))]
288 #[unsafe(method_family = none)]
289 pub unsafe fn setHavingPredicate(&self, having_predicate: Option<&NSPredicate>);
290 );
291}
292
293#[cfg(feature = "NSPersistentStoreRequest")]
295impl<ResultType: Message> NSFetchRequest<ResultType> {
296 extern_methods!(
297 #[unsafe(method(new))]
298 #[unsafe(method_family = new)]
299 pub unsafe fn new() -> Retained<Self>;
300 );
301}
302
303#[cfg(all(feature = "NSPersistentStoreResult", feature = "block2"))]
305pub type NSPersistentStoreAsynchronousFetchResultCompletionBlock =
306 *mut block2::Block<dyn Fn(NonNull<NSAsynchronousFetchResult>)>;
307
308extern_class!(
309 #[unsafe(super(NSPersistentStoreRequest, NSObject))]
311 #[derive(Debug, PartialEq, Eq, Hash)]
312 #[cfg(feature = "NSPersistentStoreRequest")]
313 pub struct NSAsynchronousFetchRequest<ResultType: ?Sized = AnyObject>;
314);
315
316#[cfg(feature = "NSPersistentStoreRequest")]
317unsafe impl<ResultType: ?Sized> NSCopying for NSAsynchronousFetchRequest<ResultType> {}
318
319#[cfg(feature = "NSPersistentStoreRequest")]
320unsafe impl<ResultType: ?Sized + Message> CopyingHelper for NSAsynchronousFetchRequest<ResultType> {
321 type Result = Self;
322}
323
324#[cfg(feature = "NSPersistentStoreRequest")]
325unsafe impl<ResultType: ?Sized> NSObjectProtocol for NSAsynchronousFetchRequest<ResultType> {}
326
327#[cfg(feature = "NSPersistentStoreRequest")]
328impl<ResultType: Message> NSAsynchronousFetchRequest<ResultType> {
329 extern_methods!(
330 #[unsafe(method(fetchRequest))]
331 #[unsafe(method_family = none)]
332 pub unsafe fn fetchRequest(&self) -> Retained<NSFetchRequest<ResultType>>;
333
334 #[cfg(all(feature = "NSPersistentStoreResult", feature = "block2"))]
335 #[unsafe(method(completionBlock))]
336 #[unsafe(method_family = none)]
337 pub unsafe fn completionBlock(
338 &self,
339 ) -> NSPersistentStoreAsynchronousFetchResultCompletionBlock;
340
341 #[unsafe(method(estimatedResultCount))]
342 #[unsafe(method_family = none)]
343 pub unsafe fn estimatedResultCount(&self) -> NSInteger;
344
345 #[unsafe(method(setEstimatedResultCount:))]
347 #[unsafe(method_family = none)]
348 pub unsafe fn setEstimatedResultCount(&self, estimated_result_count: NSInteger);
349
350 #[cfg(all(feature = "NSPersistentStoreResult", feature = "block2"))]
351 #[unsafe(method(initWithFetchRequest:completionBlock:))]
352 #[unsafe(method_family = init)]
353 pub unsafe fn initWithFetchRequest_completionBlock(
354 this: Allocated<Self>,
355 request: &NSFetchRequest<ResultType>,
356 blk: Option<&block2::Block<dyn Fn(NonNull<NSAsynchronousFetchResult<ResultType>>)>>,
357 ) -> Retained<Self>;
358 );
359}
360
361#[cfg(feature = "NSPersistentStoreRequest")]
363impl<ResultType: Message> NSAsynchronousFetchRequest<ResultType> {
364 extern_methods!(
365 #[unsafe(method(init))]
366 #[unsafe(method_family = init)]
367 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
368
369 #[unsafe(method(new))]
370 #[unsafe(method_family = new)]
371 pub unsafe fn new() -> Retained<Self>;
372 );
373}