objc2_core_data/generated/
NSPersistentContainer.rs1use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10extern_class!(
11 #[unsafe(super(NSObject))]
13 #[derive(Debug, PartialEq, Eq, Hash)]
14 pub struct NSPersistentContainer;
15);
16
17unsafe impl Send for NSPersistentContainer {}
18
19unsafe impl Sync for NSPersistentContainer {}
20
21extern_conformance!(
22 unsafe impl NSObjectProtocol for NSPersistentContainer {}
23);
24
25impl NSPersistentContainer {
26 extern_methods!(
27 #[unsafe(method(persistentContainerWithName:))]
28 #[unsafe(method_family = none)]
29 pub unsafe fn persistentContainerWithName(name: &NSString) -> Retained<Self>;
30
31 #[cfg(feature = "NSManagedObjectModel")]
32 #[unsafe(method(persistentContainerWithName:managedObjectModel:))]
33 #[unsafe(method_family = none)]
34 pub unsafe fn persistentContainerWithName_managedObjectModel(
35 name: &NSString,
36 model: &NSManagedObjectModel,
37 ) -> Retained<Self>;
38
39 #[unsafe(method(defaultDirectoryURL))]
40 #[unsafe(method_family = none)]
41 pub unsafe fn defaultDirectoryURL() -> Retained<NSURL>;
42
43 #[unsafe(method(name))]
44 #[unsafe(method_family = none)]
45 pub unsafe fn name(&self) -> Retained<NSString>;
46
47 #[cfg(feature = "NSManagedObjectContext")]
48 #[unsafe(method(viewContext))]
49 #[unsafe(method_family = none)]
50 pub unsafe fn viewContext(&self) -> Retained<NSManagedObjectContext>;
51
52 #[cfg(feature = "NSManagedObjectModel")]
53 #[unsafe(method(managedObjectModel))]
54 #[unsafe(method_family = none)]
55 pub unsafe fn managedObjectModel(&self) -> Retained<NSManagedObjectModel>;
56
57 #[cfg(feature = "NSPersistentStoreCoordinator")]
58 #[unsafe(method(persistentStoreCoordinator))]
59 #[unsafe(method_family = none)]
60 pub unsafe fn persistentStoreCoordinator(&self) -> Retained<NSPersistentStoreCoordinator>;
61
62 #[cfg(feature = "NSPersistentStoreDescription")]
63 #[unsafe(method(persistentStoreDescriptions))]
64 #[unsafe(method_family = none)]
65 pub unsafe fn persistentStoreDescriptions(
66 &self,
67 ) -> Retained<NSArray<NSPersistentStoreDescription>>;
68
69 #[cfg(feature = "NSPersistentStoreDescription")]
70 #[unsafe(method(setPersistentStoreDescriptions:))]
72 #[unsafe(method_family = none)]
73 pub unsafe fn setPersistentStoreDescriptions(
74 &self,
75 persistent_store_descriptions: &NSArray<NSPersistentStoreDescription>,
76 );
77
78 #[unsafe(method(initWithName:))]
79 #[unsafe(method_family = init)]
80 pub unsafe fn initWithName(this: Allocated<Self>, name: &NSString) -> Retained<Self>;
81
82 #[cfg(feature = "NSManagedObjectModel")]
83 #[unsafe(method(initWithName:managedObjectModel:))]
84 #[unsafe(method_family = init)]
85 pub unsafe fn initWithName_managedObjectModel(
86 this: Allocated<Self>,
87 name: &NSString,
88 model: &NSManagedObjectModel,
89 ) -> Retained<Self>;
90
91 #[cfg(all(feature = "NSPersistentStoreDescription", feature = "block2"))]
92 #[unsafe(method(loadPersistentStoresWithCompletionHandler:))]
93 #[unsafe(method_family = none)]
94 pub unsafe fn loadPersistentStoresWithCompletionHandler(
95 &self,
96 block: &block2::DynBlock<dyn Fn(NonNull<NSPersistentStoreDescription>, *mut NSError)>,
97 );
98
99 #[cfg(feature = "NSManagedObjectContext")]
100 #[unsafe(method(newBackgroundContext))]
101 #[unsafe(method_family = new)]
102 pub unsafe fn newBackgroundContext(&self) -> Retained<NSManagedObjectContext>;
103
104 #[cfg(all(feature = "NSManagedObjectContext", feature = "block2"))]
105 #[unsafe(method(performBackgroundTask:))]
106 #[unsafe(method_family = none)]
107 pub unsafe fn performBackgroundTask(
108 &self,
109 block: &block2::DynBlock<dyn Fn(NonNull<NSManagedObjectContext>)>,
110 );
111 );
112}
113
114impl NSPersistentContainer {
116 extern_methods!(
117 #[unsafe(method(init))]
118 #[unsafe(method_family = init)]
119 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
120
121 #[unsafe(method(new))]
122 #[unsafe(method_family = new)]
123 pub unsafe fn new() -> Retained<Self>;
124 );
125}