objc2_core_data/generated/
NSFetchedResultsController.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/coredata/nsfetchedresultscontroller?language=objc)
12    #[unsafe(super(NSObject))]
13    #[derive(Debug, PartialEq, Eq, Hash)]
14    pub struct NSFetchedResultsController<ResultType: ?Sized = AnyObject>;
15);
16
17extern_conformance!(
18    unsafe impl<ResultType: ?Sized> NSObjectProtocol for NSFetchedResultsController<ResultType> {}
19);
20
21impl<ResultType: Message> NSFetchedResultsController<ResultType> {
22    extern_methods!(
23        #[cfg(all(
24            feature = "NSFetchRequest",
25            feature = "NSManagedObjectContext",
26            feature = "NSPersistentStoreRequest"
27        ))]
28        #[unsafe(method(initWithFetchRequest:managedObjectContext:sectionNameKeyPath:cacheName:))]
29        #[unsafe(method_family = init)]
30        pub unsafe fn initWithFetchRequest_managedObjectContext_sectionNameKeyPath_cacheName(
31            this: Allocated<Self>,
32            fetch_request: &NSFetchRequest<ResultType>,
33            context: &NSManagedObjectContext,
34            section_name_key_path: Option<&NSString>,
35            name: Option<&NSString>,
36        ) -> Retained<Self>;
37
38        #[unsafe(method(performFetch:_))]
39        #[unsafe(method_family = none)]
40        pub unsafe fn performFetch(&self) -> Result<(), Retained<NSError>>;
41
42        #[cfg(all(feature = "NSFetchRequest", feature = "NSPersistentStoreRequest"))]
43        #[unsafe(method(fetchRequest))]
44        #[unsafe(method_family = none)]
45        pub unsafe fn fetchRequest(&self) -> Retained<NSFetchRequest<ResultType>>;
46
47        #[cfg(feature = "NSManagedObjectContext")]
48        #[unsafe(method(managedObjectContext))]
49        #[unsafe(method_family = none)]
50        pub unsafe fn managedObjectContext(&self) -> Retained<NSManagedObjectContext>;
51
52        #[unsafe(method(sectionNameKeyPath))]
53        #[unsafe(method_family = none)]
54        pub unsafe fn sectionNameKeyPath(&self) -> Option<Retained<NSString>>;
55
56        #[unsafe(method(cacheName))]
57        #[unsafe(method_family = none)]
58        pub unsafe fn cacheName(&self) -> Option<Retained<NSString>>;
59
60        #[unsafe(method(delegate))]
61        #[unsafe(method_family = none)]
62        pub unsafe fn delegate(
63            &self,
64        ) -> Option<Retained<ProtocolObject<dyn NSFetchedResultsControllerDelegate>>>;
65
66        /// Setter for [`delegate`][Self::delegate].
67        #[unsafe(method(setDelegate:))]
68        #[unsafe(method_family = none)]
69        pub unsafe fn setDelegate(
70            &self,
71            delegate: Option<&ProtocolObject<dyn NSFetchedResultsControllerDelegate>>,
72        );
73
74        #[unsafe(method(deleteCacheWithName:))]
75        #[unsafe(method_family = none)]
76        pub unsafe fn deleteCacheWithName(name: Option<&NSString>);
77
78        #[unsafe(method(fetchedObjects))]
79        #[unsafe(method_family = none)]
80        pub unsafe fn fetchedObjects(&self) -> Option<Retained<NSArray<ResultType>>>;
81
82        #[unsafe(method(objectAtIndexPath:))]
83        #[unsafe(method_family = none)]
84        pub unsafe fn objectAtIndexPath(&self, index_path: &NSIndexPath) -> Retained<ResultType>;
85
86        #[unsafe(method(indexPathForObject:))]
87        #[unsafe(method_family = none)]
88        pub unsafe fn indexPathForObject(
89            &self,
90            object: &ResultType,
91        ) -> Option<Retained<NSIndexPath>>;
92
93        #[unsafe(method(sectionIndexTitleForSectionName:))]
94        #[unsafe(method_family = none)]
95        pub unsafe fn sectionIndexTitleForSectionName(
96            &self,
97            section_name: &NSString,
98        ) -> Option<Retained<NSString>>;
99
100        #[unsafe(method(sectionIndexTitles))]
101        #[unsafe(method_family = none)]
102        pub unsafe fn sectionIndexTitles(&self) -> Retained<NSArray<NSString>>;
103
104        #[unsafe(method(sections))]
105        #[unsafe(method_family = none)]
106        pub unsafe fn sections(
107            &self,
108        ) -> Option<Retained<NSArray<ProtocolObject<dyn NSFetchedResultsSectionInfo>>>>;
109
110        #[unsafe(method(sectionForSectionIndexTitle:atIndex:))]
111        #[unsafe(method_family = none)]
112        pub unsafe fn sectionForSectionIndexTitle_atIndex(
113            &self,
114            title: &NSString,
115            section_index: NSInteger,
116        ) -> NSInteger;
117    );
118}
119
120/// Methods declared on superclass `NSObject`.
121impl<ResultType: Message> NSFetchedResultsController<ResultType> {
122    extern_methods!(
123        #[unsafe(method(init))]
124        #[unsafe(method_family = init)]
125        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
126
127        #[unsafe(method(new))]
128        #[unsafe(method_family = new)]
129        pub unsafe fn new() -> Retained<Self>;
130    );
131}
132
133extern_protocol!(
134    /// [Apple's documentation](https://developer.apple.com/documentation/coredata/nsfetchedresultssectioninfo?language=objc)
135    pub unsafe trait NSFetchedResultsSectionInfo {
136        #[unsafe(method(name))]
137        #[unsafe(method_family = none)]
138        unsafe fn name(&self) -> Retained<NSString>;
139
140        #[unsafe(method(indexTitle))]
141        #[unsafe(method_family = none)]
142        unsafe fn indexTitle(&self) -> Option<Retained<NSString>>;
143
144        #[unsafe(method(numberOfObjects))]
145        #[unsafe(method_family = none)]
146        unsafe fn numberOfObjects(&self) -> NSUInteger;
147
148        #[unsafe(method(objects))]
149        #[unsafe(method_family = none)]
150        unsafe fn objects(&self) -> Option<Retained<NSArray>>;
151    }
152);
153
154/// [Apple's documentation](https://developer.apple.com/documentation/coredata/nsfetchedresultschangetype?language=objc)
155// NS_ENUM
156#[repr(transparent)]
157#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
158pub struct NSFetchedResultsChangeType(pub NSUInteger);
159impl NSFetchedResultsChangeType {
160    #[doc(alias = "NSFetchedResultsChangeInsert")]
161    pub const Insert: Self = Self(1);
162    #[doc(alias = "NSFetchedResultsChangeDelete")]
163    pub const Delete: Self = Self(2);
164    #[doc(alias = "NSFetchedResultsChangeMove")]
165    pub const Move: Self = Self(3);
166    #[doc(alias = "NSFetchedResultsChangeUpdate")]
167    pub const Update: Self = Self(4);
168}
169
170unsafe impl Encode for NSFetchedResultsChangeType {
171    const ENCODING: Encoding = NSUInteger::ENCODING;
172}
173
174unsafe impl RefEncode for NSFetchedResultsChangeType {
175    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
176}
177
178extern_protocol!(
179    /// [Apple's documentation](https://developer.apple.com/documentation/coredata/nsfetchedresultscontrollerdelegate?language=objc)
180    pub unsafe trait NSFetchedResultsControllerDelegate: NSObjectProtocol {
181        #[cfg(feature = "NSManagedObjectID")]
182        #[optional]
183        #[unsafe(method(controller:didChangeContentWithDifference:))]
184        #[unsafe(method_family = none)]
185        unsafe fn controller_didChangeContentWithDifference(
186            &self,
187            controller: &NSFetchedResultsController,
188            diff: &NSOrderedCollectionDifference<NSManagedObjectID>,
189        );
190
191        #[optional]
192        #[unsafe(method(controller:didChangeObject:atIndexPath:forChangeType:newIndexPath:))]
193        #[unsafe(method_family = none)]
194        unsafe fn controller_didChangeObject_atIndexPath_forChangeType_newIndexPath(
195            &self,
196            controller: &NSFetchedResultsController,
197            an_object: &AnyObject,
198            index_path: Option<&NSIndexPath>,
199            r#type: NSFetchedResultsChangeType,
200            new_index_path: Option<&NSIndexPath>,
201        );
202
203        #[optional]
204        #[unsafe(method(controller:didChangeSection:atIndex:forChangeType:))]
205        #[unsafe(method_family = none)]
206        unsafe fn controller_didChangeSection_atIndex_forChangeType(
207            &self,
208            controller: &NSFetchedResultsController,
209            section_info: &ProtocolObject<dyn NSFetchedResultsSectionInfo>,
210            section_index: NSUInteger,
211            r#type: NSFetchedResultsChangeType,
212        );
213
214        #[optional]
215        #[unsafe(method(controllerWillChangeContent:))]
216        #[unsafe(method_family = none)]
217        unsafe fn controllerWillChangeContent(&self, controller: &NSFetchedResultsController);
218
219        #[optional]
220        #[unsafe(method(controllerDidChangeContent:))]
221        #[unsafe(method_family = none)]
222        unsafe fn controllerDidChangeContent(&self, controller: &NSFetchedResultsController);
223
224        #[optional]
225        #[unsafe(method(controller:sectionIndexTitleForSectionName:))]
226        #[unsafe(method_family = none)]
227        unsafe fn controller_sectionIndexTitleForSectionName(
228            &self,
229            controller: &NSFetchedResultsController,
230            section_name: &NSString,
231        ) -> Option<Retained<NSString>>;
232    }
233);