objc2_core_data/generated/
NSManagedObjectContext.rs1use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10extern "C" {
11 pub static NSManagedObjectContextWillSaveNotification: &'static NSString;
13}
14
15extern "C" {
16 pub static NSManagedObjectContextDidSaveNotification: &'static NSString;
18}
19
20extern "C" {
21 pub static NSManagedObjectContextObjectsDidChangeNotification: &'static NSString;
23}
24
25extern "C" {
26 pub static NSManagedObjectContextDidSaveObjectIDsNotification: &'static NSString;
28}
29
30extern "C" {
31 pub static NSManagedObjectContextDidMergeChangesObjectIDsNotification: &'static NSString;
33}
34
35extern "C" {
36 pub static NSInsertedObjectsKey: &'static NSString;
38}
39
40extern "C" {
41 pub static NSUpdatedObjectsKey: &'static NSString;
43}
44
45extern "C" {
46 pub static NSDeletedObjectsKey: &'static NSString;
48}
49
50extern "C" {
51 pub static NSRefreshedObjectsKey: &'static NSString;
53}
54
55extern "C" {
56 pub static NSInvalidatedObjectsKey: &'static NSString;
58}
59
60extern "C" {
61 pub static NSManagedObjectContextQueryGenerationKey: &'static NSString;
63}
64
65extern "C" {
66 pub static NSInvalidatedAllObjectsKey: &'static NSString;
68}
69
70extern "C" {
71 pub static NSInsertedObjectIDsKey: &'static NSString;
73}
74
75extern "C" {
76 pub static NSUpdatedObjectIDsKey: &'static NSString;
78}
79
80extern "C" {
81 pub static NSDeletedObjectIDsKey: &'static NSString;
83}
84
85extern "C" {
86 pub static NSRefreshedObjectIDsKey: &'static NSString;
88}
89
90extern "C" {
91 pub static NSInvalidatedObjectIDsKey: &'static NSString;
93}
94
95#[repr(transparent)]
98#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
99pub struct NSManagedObjectContextConcurrencyType(pub NSUInteger);
100impl NSManagedObjectContextConcurrencyType {
101 #[doc(alias = "NSConfinementConcurrencyType")]
102 #[deprecated = "Use another NSManagedObjectContextConcurrencyType"]
103 pub const ConfinementConcurrencyType: Self = Self(0x00);
104 #[doc(alias = "NSPrivateQueueConcurrencyType")]
105 pub const PrivateQueueConcurrencyType: Self = Self(0x01);
106 #[doc(alias = "NSMainQueueConcurrencyType")]
107 pub const MainQueueConcurrencyType: Self = Self(0x02);
108}
109
110unsafe impl Encode for NSManagedObjectContextConcurrencyType {
111 const ENCODING: Encoding = NSUInteger::ENCODING;
112}
113
114unsafe impl RefEncode for NSManagedObjectContextConcurrencyType {
115 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
116}
117
118extern_class!(
119 #[unsafe(super(NSObject))]
121 #[derive(Debug, PartialEq, Eq, Hash)]
122 pub struct NSManagedObjectContext;
123);
124
125unsafe impl Send for NSManagedObjectContext {}
126
127unsafe impl Sync for NSManagedObjectContext {}
128
129extern_conformance!(
130 unsafe impl NSCoding for NSManagedObjectContext {}
131);
132
133extern_conformance!(
134 unsafe impl NSLocking for NSManagedObjectContext {}
135);
136
137extern_conformance!(
138 unsafe impl NSObjectProtocol for NSManagedObjectContext {}
139);
140
141impl NSManagedObjectContext {
142 extern_methods!(
143 #[deprecated = "Use -initWithConcurrencyType: instead"]
144 #[unsafe(method(new))]
145 #[unsafe(method_family = new)]
146 pub unsafe fn new() -> Retained<Self>;
147
148 #[deprecated = "Use -initWithConcurrencyType: instead"]
149 #[unsafe(method(init))]
150 #[unsafe(method_family = init)]
151 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
152
153 #[unsafe(method(initWithConcurrencyType:))]
154 #[unsafe(method_family = init)]
155 pub unsafe fn initWithConcurrencyType(
156 this: Allocated<Self>,
157 ct: NSManagedObjectContextConcurrencyType,
158 ) -> Retained<Self>;
159
160 #[cfg(feature = "block2")]
161 #[unsafe(method(performBlock:))]
165 #[unsafe(method_family = none)]
166 pub unsafe fn performBlock(&self, block: &block2::DynBlock<dyn Fn()>);
167
168 #[cfg(feature = "block2")]
169 #[unsafe(method(performBlockAndWait:))]
173 #[unsafe(method_family = none)]
174 pub unsafe fn performBlockAndWait(&self, block: &block2::DynBlock<dyn Fn() + '_>);
175
176 #[cfg(feature = "NSPersistentStoreCoordinator")]
177 #[unsafe(method(persistentStoreCoordinator))]
178 #[unsafe(method_family = none)]
179 pub unsafe fn persistentStoreCoordinator(
180 &self,
181 ) -> Option<Retained<NSPersistentStoreCoordinator>>;
182
183 #[cfg(feature = "NSPersistentStoreCoordinator")]
184 #[unsafe(method(setPersistentStoreCoordinator:))]
186 #[unsafe(method_family = none)]
187 pub unsafe fn setPersistentStoreCoordinator(
188 &self,
189 persistent_store_coordinator: Option<&NSPersistentStoreCoordinator>,
190 );
191
192 #[unsafe(method(parentContext))]
193 #[unsafe(method_family = none)]
194 pub unsafe fn parentContext(&self) -> Option<Retained<NSManagedObjectContext>>;
195
196 #[unsafe(method(setParentContext:))]
198 #[unsafe(method_family = none)]
199 pub unsafe fn setParentContext(&self, parent_context: Option<&NSManagedObjectContext>);
200
201 #[unsafe(method(name))]
202 #[unsafe(method_family = none)]
203 pub unsafe fn name(&self) -> Option<Retained<NSString>>;
204
205 #[unsafe(method(setName:))]
209 #[unsafe(method_family = none)]
210 pub unsafe fn setName(&self, name: Option<&NSString>);
211
212 #[unsafe(method(undoManager))]
218 #[unsafe(method_family = none)]
219 pub unsafe fn undoManager(&self, mtm: MainThreadMarker) -> Option<Retained<NSUndoManager>>;
220
221 #[unsafe(method(setUndoManager:))]
227 #[unsafe(method_family = none)]
228 pub unsafe fn setUndoManager(&self, undo_manager: Option<&NSUndoManager>);
229
230 #[unsafe(method(hasChanges))]
236 #[unsafe(method_family = none)]
237 pub unsafe fn hasChanges(&self) -> bool;
238
239 #[unsafe(method(userInfo))]
246 #[unsafe(method_family = none)]
247 pub unsafe fn userInfo(&self) -> Retained<NSMutableDictionary>;
248
249 #[unsafe(method(concurrencyType))]
250 #[unsafe(method_family = none)]
251 pub unsafe fn concurrencyType(&self) -> NSManagedObjectContextConcurrencyType;
252
253 #[cfg(all(feature = "NSManagedObject", feature = "NSManagedObjectID"))]
254 #[unsafe(method(objectRegisteredForID:))]
255 #[unsafe(method_family = none)]
256 pub unsafe fn objectRegisteredForID(
257 &self,
258 object_id: &NSManagedObjectID,
259 ) -> Option<Retained<NSManagedObject>>;
260
261 #[cfg(all(feature = "NSManagedObject", feature = "NSManagedObjectID"))]
262 #[unsafe(method(objectWithID:))]
263 #[unsafe(method_family = none)]
264 pub unsafe fn objectWithID(
265 &self,
266 object_id: &NSManagedObjectID,
267 ) -> Retained<NSManagedObject>;
268
269 #[cfg(all(feature = "NSManagedObject", feature = "NSManagedObjectID"))]
270 #[unsafe(method(existingObjectWithID:error:_))]
271 #[unsafe(method_family = none)]
272 pub unsafe fn existingObjectWithID_error(
273 &self,
274 object_id: &NSManagedObjectID,
275 ) -> Result<Retained<NSManagedObject>, Retained<NSError>>;
276
277 #[cfg(all(feature = "NSFetchRequest", feature = "NSPersistentStoreRequest"))]
278 #[unsafe(method(executeFetchRequest:error:_))]
282 #[unsafe(method_family = none)]
283 pub unsafe fn executeFetchRequest_error(
284 &self,
285 request: &NSFetchRequest,
286 ) -> Result<Retained<NSArray>, Retained<NSError>>;
287
288 #[cfg(all(
289 feature = "NSPersistentStoreRequest",
290 feature = "NSPersistentStoreResult"
291 ))]
292 #[unsafe(method(executeRequest:error:_))]
293 #[unsafe(method_family = none)]
294 pub unsafe fn executeRequest_error(
295 &self,
296 request: &NSPersistentStoreRequest,
297 ) -> Result<Retained<NSPersistentStoreResult>, Retained<NSError>>;
298
299 #[cfg(feature = "NSManagedObject")]
300 #[unsafe(method(insertObject:))]
301 #[unsafe(method_family = none)]
302 pub unsafe fn insertObject(&self, object: &NSManagedObject);
303
304 #[cfg(feature = "NSManagedObject")]
305 #[unsafe(method(deleteObject:))]
306 #[unsafe(method_family = none)]
307 pub unsafe fn deleteObject(&self, object: &NSManagedObject);
308
309 #[cfg(feature = "NSManagedObject")]
310 #[unsafe(method(refreshObject:mergeChanges:))]
311 #[unsafe(method_family = none)]
312 pub unsafe fn refreshObject_mergeChanges(&self, object: &NSManagedObject, flag: bool);
313
314 #[cfg(feature = "NSManagedObject")]
315 #[unsafe(method(detectConflictsForObject:))]
316 #[unsafe(method_family = none)]
317 pub unsafe fn detectConflictsForObject(&self, object: &NSManagedObject);
318
319 #[unsafe(method(observeValueForKeyPath:ofObject:change:context:))]
325 #[unsafe(method_family = none)]
326 pub unsafe fn observeValueForKeyPath_ofObject_change_context(
327 &self,
328 key_path: Option<&NSString>,
329 object: Option<&AnyObject>,
330 change: Option<&NSDictionary<NSString, AnyObject>>,
331 context: *mut c_void,
332 );
333
334 #[unsafe(method(processPendingChanges))]
335 #[unsafe(method_family = none)]
336 pub unsafe fn processPendingChanges(&self);
337
338 #[cfg(feature = "NSPersistentStore")]
339 #[unsafe(method(assignObject:toPersistentStore:))]
343 #[unsafe(method_family = none)]
344 pub unsafe fn assignObject_toPersistentStore(
345 &self,
346 object: &AnyObject,
347 store: &NSPersistentStore,
348 );
349
350 #[cfg(feature = "NSManagedObject")]
351 #[unsafe(method(insertedObjects))]
357 #[unsafe(method_family = none)]
358 pub unsafe fn insertedObjects(&self) -> Retained<NSSet<NSManagedObject>>;
359
360 #[cfg(feature = "NSManagedObject")]
361 #[unsafe(method(updatedObjects))]
367 #[unsafe(method_family = none)]
368 pub unsafe fn updatedObjects(&self) -> Retained<NSSet<NSManagedObject>>;
369
370 #[cfg(feature = "NSManagedObject")]
371 #[unsafe(method(deletedObjects))]
377 #[unsafe(method_family = none)]
378 pub unsafe fn deletedObjects(&self) -> Retained<NSSet<NSManagedObject>>;
379
380 #[cfg(feature = "NSManagedObject")]
381 #[unsafe(method(registeredObjects))]
387 #[unsafe(method_family = none)]
388 pub unsafe fn registeredObjects(&self) -> Retained<NSSet<NSManagedObject>>;
389
390 #[unsafe(method(undo))]
391 #[unsafe(method_family = none)]
392 pub unsafe fn undo(&self);
393
394 #[unsafe(method(redo))]
395 #[unsafe(method_family = none)]
396 pub unsafe fn redo(&self);
397
398 #[unsafe(method(reset))]
399 #[unsafe(method_family = none)]
400 pub unsafe fn reset(&self);
401
402 #[unsafe(method(rollback))]
403 #[unsafe(method_family = none)]
404 pub unsafe fn rollback(&self);
405
406 #[unsafe(method(save:_))]
407 #[unsafe(method_family = none)]
408 pub unsafe fn save(&self) -> Result<(), Retained<NSError>>;
409
410 #[unsafe(method(refreshAllObjects))]
411 #[unsafe(method_family = none)]
412 pub unsafe fn refreshAllObjects(&self);
413
414 #[deprecated = "Use a queue style context and -performBlockAndWait: instead"]
415 #[unsafe(method(lock))]
416 #[unsafe(method_family = none)]
417 pub unsafe fn lock(&self);
418
419 #[deprecated = "Use a queue style context and -performBlockAndWait: instead"]
420 #[unsafe(method(unlock))]
421 #[unsafe(method_family = none)]
422 pub unsafe fn unlock(&self);
423
424 #[deprecated = "Use a queue style context and -performBlock: instead"]
425 #[unsafe(method(tryLock))]
426 #[unsafe(method_family = none)]
427 pub unsafe fn tryLock(&self) -> bool;
428
429 #[unsafe(method(propagatesDeletesAtEndOfEvent))]
435 #[unsafe(method_family = none)]
436 pub unsafe fn propagatesDeletesAtEndOfEvent(&self) -> bool;
437
438 #[unsafe(method(setPropagatesDeletesAtEndOfEvent:))]
444 #[unsafe(method_family = none)]
445 pub unsafe fn setPropagatesDeletesAtEndOfEvent(
446 &self,
447 propagates_deletes_at_end_of_event: bool,
448 );
449
450 #[unsafe(method(retainsRegisteredObjects))]
456 #[unsafe(method_family = none)]
457 pub unsafe fn retainsRegisteredObjects(&self) -> bool;
458
459 #[unsafe(method(setRetainsRegisteredObjects:))]
465 #[unsafe(method_family = none)]
466 pub unsafe fn setRetainsRegisteredObjects(&self, retains_registered_objects: bool);
467
468 #[unsafe(method(shouldDeleteInaccessibleFaults))]
469 #[unsafe(method_family = none)]
470 pub unsafe fn shouldDeleteInaccessibleFaults(&self) -> bool;
471
472 #[unsafe(method(setShouldDeleteInaccessibleFaults:))]
474 #[unsafe(method_family = none)]
475 pub unsafe fn setShouldDeleteInaccessibleFaults(
476 &self,
477 should_delete_inaccessible_faults: bool,
478 );
479
480 #[cfg(all(
481 feature = "NSManagedObject",
482 feature = "NSManagedObjectID",
483 feature = "NSPropertyDescription"
484 ))]
485 #[unsafe(method(shouldHandleInaccessibleFault:forObjectID:triggeredByProperty:))]
486 #[unsafe(method_family = none)]
487 pub unsafe fn shouldHandleInaccessibleFault_forObjectID_triggeredByProperty(
488 &self,
489 fault: &NSManagedObject,
490 oid: &NSManagedObjectID,
491 property: Option<&NSPropertyDescription>,
492 ) -> bool;
493
494 #[unsafe(method(stalenessInterval))]
495 #[unsafe(method_family = none)]
496 pub unsafe fn stalenessInterval(&self) -> NSTimeInterval;
497
498 #[unsafe(method(setStalenessInterval:))]
500 #[unsafe(method_family = none)]
501 pub unsafe fn setStalenessInterval(&self, staleness_interval: NSTimeInterval);
502
503 #[unsafe(method(mergePolicy))]
504 #[unsafe(method_family = none)]
505 pub unsafe fn mergePolicy(&self) -> Retained<AnyObject>;
506
507 #[unsafe(method(setMergePolicy:))]
513 #[unsafe(method_family = none)]
514 pub unsafe fn setMergePolicy(&self, merge_policy: &AnyObject);
515
516 #[cfg(feature = "NSManagedObject")]
517 #[unsafe(method(obtainPermanentIDsForObjects:error:_))]
518 #[unsafe(method_family = none)]
519 pub unsafe fn obtainPermanentIDsForObjects_error(
520 &self,
521 objects: &NSArray<NSManagedObject>,
522 ) -> Result<(), Retained<NSError>>;
523
524 #[unsafe(method(mergeChangesFromContextDidSaveNotification:))]
525 #[unsafe(method_family = none)]
526 pub unsafe fn mergeChangesFromContextDidSaveNotification(
527 &self,
528 notification: &NSNotification,
529 );
530
531 #[unsafe(method(mergeChangesFromRemoteContextSave:intoContexts:))]
535 #[unsafe(method_family = none)]
536 pub unsafe fn mergeChangesFromRemoteContextSave_intoContexts(
537 change_notification_data: &NSDictionary,
538 contexts: &NSArray<NSManagedObjectContext>,
539 );
540
541 #[cfg(feature = "NSQueryGenerationToken")]
542 #[unsafe(method(queryGenerationToken))]
548 #[unsafe(method_family = none)]
549 pub unsafe fn queryGenerationToken(&self) -> Option<Retained<NSQueryGenerationToken>>;
550
551 #[cfg(feature = "NSQueryGenerationToken")]
552 #[unsafe(method(setQueryGenerationFromToken:error:_))]
553 #[unsafe(method_family = none)]
554 pub unsafe fn setQueryGenerationFromToken_error(
555 &self,
556 generation: Option<&NSQueryGenerationToken>,
557 ) -> Result<(), Retained<NSError>>;
558
559 #[unsafe(method(automaticallyMergesChangesFromParent))]
565 #[unsafe(method_family = none)]
566 pub unsafe fn automaticallyMergesChangesFromParent(&self) -> bool;
567
568 #[unsafe(method(setAutomaticallyMergesChangesFromParent:))]
574 #[unsafe(method_family = none)]
575 pub unsafe fn setAutomaticallyMergesChangesFromParent(
576 &self,
577 automatically_merges_changes_from_parent: bool,
578 );
579
580 #[unsafe(method(transactionAuthor))]
581 #[unsafe(method_family = none)]
582 pub unsafe fn transactionAuthor(&self) -> Option<Retained<NSString>>;
583
584 #[unsafe(method(setTransactionAuthor:))]
588 #[unsafe(method_family = none)]
589 pub unsafe fn setTransactionAuthor(&self, transaction_author: Option<&NSString>);
590 );
591}