objc2_app_kit/generated/
NSDiffableDataSource.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/appkit/nsdiffabledatasourcesnapshot?language=objc)
12    #[unsafe(super(NSObject))]
13    #[derive(Debug, PartialEq, Eq, Hash)]
14    pub struct NSDiffableDataSourceSnapshot<
15        SectionIdentifierType: ?Sized = AnyObject,
16        ItemIdentifierType: ?Sized = AnyObject,
17    >;
18);
19
20impl<SectionIdentifierType: ?Sized + Message, ItemIdentifierType: ?Sized + Message>
21    NSDiffableDataSourceSnapshot<SectionIdentifierType, ItemIdentifierType>
22{
23    /// Unchecked conversion of the generic parameters.
24    ///
25    /// # Safety
26    ///
27    /// The generics must be valid to reinterpret as the given types.
28    #[inline]
29    pub unsafe fn cast_unchecked<
30        NewSectionIdentifierType: ?Sized + Message,
31        NewItemIdentifierType: ?Sized + Message,
32    >(
33        &self,
34    ) -> &NSDiffableDataSourceSnapshot<NewSectionIdentifierType, NewItemIdentifierType> {
35        unsafe { &*((self as *const Self).cast()) }
36    }
37}
38
39extern_conformance!(
40    unsafe impl<SectionIdentifierType: ?Sized, ItemIdentifierType: ?Sized> NSCopying
41        for NSDiffableDataSourceSnapshot<SectionIdentifierType, ItemIdentifierType>
42    {
43    }
44);
45
46unsafe impl<SectionIdentifierType: ?Sized + Message, ItemIdentifierType: ?Sized + Message>
47    CopyingHelper for NSDiffableDataSourceSnapshot<SectionIdentifierType, ItemIdentifierType>
48{
49    type Result = Self;
50}
51
52extern_conformance!(
53    unsafe impl<SectionIdentifierType: ?Sized, ItemIdentifierType: ?Sized> NSObjectProtocol
54        for NSDiffableDataSourceSnapshot<SectionIdentifierType, ItemIdentifierType>
55    {
56    }
57);
58
59impl<SectionIdentifierType: Message, ItemIdentifierType: Message>
60    NSDiffableDataSourceSnapshot<SectionIdentifierType, ItemIdentifierType>
61{
62    extern_methods!(
63        #[unsafe(method(numberOfItems))]
64        #[unsafe(method_family = none)]
65        pub fn numberOfItems(&self) -> NSInteger;
66
67        #[unsafe(method(numberOfSections))]
68        #[unsafe(method_family = none)]
69        pub fn numberOfSections(&self) -> NSInteger;
70
71        #[unsafe(method(sectionIdentifiers))]
72        #[unsafe(method_family = none)]
73        pub fn sectionIdentifiers(&self) -> Retained<NSArray<SectionIdentifierType>>;
74
75        #[unsafe(method(itemIdentifiers))]
76        #[unsafe(method_family = none)]
77        pub fn itemIdentifiers(&self) -> Retained<NSArray<ItemIdentifierType>>;
78
79        #[unsafe(method(numberOfItemsInSection:))]
80        #[unsafe(method_family = none)]
81        pub fn numberOfItemsInSection(
82            &self,
83            section_identifier: &SectionIdentifierType,
84        ) -> NSInteger;
85
86        #[unsafe(method(itemIdentifiersInSectionWithIdentifier:))]
87        #[unsafe(method_family = none)]
88        pub fn itemIdentifiersInSectionWithIdentifier(
89            &self,
90            section_identifier: &SectionIdentifierType,
91        ) -> Retained<NSArray<ItemIdentifierType>>;
92
93        #[unsafe(method(sectionIdentifierForSectionContainingItemIdentifier:))]
94        #[unsafe(method_family = none)]
95        pub fn sectionIdentifierForSectionContainingItemIdentifier(
96            &self,
97            item_identifier: &ItemIdentifierType,
98        ) -> Option<Retained<SectionIdentifierType>>;
99
100        #[unsafe(method(indexOfItemIdentifier:))]
101        #[unsafe(method_family = none)]
102        pub fn indexOfItemIdentifier(&self, item_identifier: &ItemIdentifierType) -> NSInteger;
103
104        #[unsafe(method(indexOfSectionIdentifier:))]
105        #[unsafe(method_family = none)]
106        pub fn indexOfSectionIdentifier(
107            &self,
108            section_identifier: &SectionIdentifierType,
109        ) -> NSInteger;
110
111        #[unsafe(method(appendItemsWithIdentifiers:))]
112        #[unsafe(method_family = none)]
113        pub fn appendItemsWithIdentifiers(&self, identifiers: &NSArray<ItemIdentifierType>);
114
115        #[unsafe(method(appendItemsWithIdentifiers:intoSectionWithIdentifier:))]
116        #[unsafe(method_family = none)]
117        pub fn appendItemsWithIdentifiers_intoSectionWithIdentifier(
118            &self,
119            identifiers: &NSArray<ItemIdentifierType>,
120            section_identifier: &SectionIdentifierType,
121        );
122
123        #[unsafe(method(insertItemsWithIdentifiers:beforeItemWithIdentifier:))]
124        #[unsafe(method_family = none)]
125        pub fn insertItemsWithIdentifiers_beforeItemWithIdentifier(
126            &self,
127            identifiers: &NSArray<ItemIdentifierType>,
128            item_identifier: &ItemIdentifierType,
129        );
130
131        #[unsafe(method(insertItemsWithIdentifiers:afterItemWithIdentifier:))]
132        #[unsafe(method_family = none)]
133        pub fn insertItemsWithIdentifiers_afterItemWithIdentifier(
134            &self,
135            identifiers: &NSArray<ItemIdentifierType>,
136            item_identifier: &ItemIdentifierType,
137        );
138
139        #[unsafe(method(deleteItemsWithIdentifiers:))]
140        #[unsafe(method_family = none)]
141        pub fn deleteItemsWithIdentifiers(&self, identifiers: &NSArray<ItemIdentifierType>);
142
143        #[unsafe(method(deleteAllItems))]
144        #[unsafe(method_family = none)]
145        pub fn deleteAllItems(&self);
146
147        #[unsafe(method(moveItemWithIdentifier:beforeItemWithIdentifier:))]
148        #[unsafe(method_family = none)]
149        pub fn moveItemWithIdentifier_beforeItemWithIdentifier(
150            &self,
151            from_identifier: &ItemIdentifierType,
152            to_identifier: &ItemIdentifierType,
153        );
154
155        #[unsafe(method(moveItemWithIdentifier:afterItemWithIdentifier:))]
156        #[unsafe(method_family = none)]
157        pub fn moveItemWithIdentifier_afterItemWithIdentifier(
158            &self,
159            from_identifier: &ItemIdentifierType,
160            to_identifier: &ItemIdentifierType,
161        );
162
163        #[unsafe(method(reloadItemsWithIdentifiers:))]
164        #[unsafe(method_family = none)]
165        pub fn reloadItemsWithIdentifiers(&self, identifiers: &NSArray<ItemIdentifierType>);
166
167        #[unsafe(method(appendSectionsWithIdentifiers:))]
168        #[unsafe(method_family = none)]
169        pub fn appendSectionsWithIdentifiers(
170            &self,
171            section_identifiers: &NSArray<SectionIdentifierType>,
172        );
173
174        #[unsafe(method(insertSectionsWithIdentifiers:beforeSectionWithIdentifier:))]
175        #[unsafe(method_family = none)]
176        pub fn insertSectionsWithIdentifiers_beforeSectionWithIdentifier(
177            &self,
178            section_identifiers: &NSArray<SectionIdentifierType>,
179            to_section_identifier: &SectionIdentifierType,
180        );
181
182        #[unsafe(method(insertSectionsWithIdentifiers:afterSectionWithIdentifier:))]
183        #[unsafe(method_family = none)]
184        pub fn insertSectionsWithIdentifiers_afterSectionWithIdentifier(
185            &self,
186            section_identifiers: &NSArray<SectionIdentifierType>,
187            to_section_identifier: &SectionIdentifierType,
188        );
189
190        #[unsafe(method(deleteSectionsWithIdentifiers:))]
191        #[unsafe(method_family = none)]
192        pub fn deleteSectionsWithIdentifiers(
193            &self,
194            section_identifiers: &NSArray<SectionIdentifierType>,
195        );
196
197        #[unsafe(method(moveSectionWithIdentifier:beforeSectionWithIdentifier:))]
198        #[unsafe(method_family = none)]
199        pub fn moveSectionWithIdentifier_beforeSectionWithIdentifier(
200            &self,
201            from_section_identifier: &SectionIdentifierType,
202            to_section_identifier: &SectionIdentifierType,
203        );
204
205        #[unsafe(method(moveSectionWithIdentifier:afterSectionWithIdentifier:))]
206        #[unsafe(method_family = none)]
207        pub fn moveSectionWithIdentifier_afterSectionWithIdentifier(
208            &self,
209            from_section_identifier: &SectionIdentifierType,
210            to_section_identifier: &SectionIdentifierType,
211        );
212
213        #[unsafe(method(reloadSectionsWithIdentifiers:))]
214        #[unsafe(method_family = none)]
215        pub fn reloadSectionsWithIdentifiers(
216            &self,
217            section_identifiers: &NSArray<SectionIdentifierType>,
218        );
219    );
220}
221
222/// Methods declared on superclass `NSObject`.
223impl<SectionIdentifierType: Message, ItemIdentifierType: Message>
224    NSDiffableDataSourceSnapshot<SectionIdentifierType, ItemIdentifierType>
225{
226    extern_methods!(
227        #[unsafe(method(init))]
228        #[unsafe(method_family = init)]
229        pub fn init(this: Allocated<Self>) -> Retained<Self>;
230
231        #[unsafe(method(new))]
232        #[unsafe(method_family = new)]
233        pub fn new() -> Retained<Self>;
234    );
235}
236
237impl<SectionIdentifierType: Message, ItemIdentifierType: Message> DefaultRetained
238    for NSDiffableDataSourceSnapshot<SectionIdentifierType, ItemIdentifierType>
239{
240    #[inline]
241    fn default_retained() -> Retained<Self> {
242        Self::new()
243    }
244}
245
246/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nscollectionviewdiffabledatasourcesupplementaryviewprovider?language=objc)
247#[cfg(all(
248    feature = "NSCollectionView",
249    feature = "NSResponder",
250    feature = "NSView",
251    feature = "block2"
252))]
253pub type NSCollectionViewDiffableDataSourceSupplementaryViewProvider = *mut block2::DynBlock<
254    dyn Fn(NonNull<NSCollectionView>, NonNull<NSString>, NonNull<NSIndexPath>) -> *mut NSView,
255>;
256
257extern_class!(
258    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nscollectionviewdiffabledatasource?language=objc)
259    #[unsafe(super(NSObject))]
260    #[derive(Debug, PartialEq, Eq, Hash)]
261    pub struct NSCollectionViewDiffableDataSource<
262        SectionIdentifierType: ?Sized = AnyObject,
263        ItemIdentifierType: ?Sized = AnyObject,
264    >;
265);
266
267impl<SectionIdentifierType: ?Sized + Message, ItemIdentifierType: ?Sized + Message>
268    NSCollectionViewDiffableDataSource<SectionIdentifierType, ItemIdentifierType>
269{
270    /// Unchecked conversion of the generic parameters.
271    ///
272    /// # Safety
273    ///
274    /// The generics must be valid to reinterpret as the given types.
275    #[inline]
276    pub unsafe fn cast_unchecked<
277        NewSectionIdentifierType: ?Sized + Message,
278        NewItemIdentifierType: ?Sized + Message,
279    >(
280        &self,
281    ) -> &NSCollectionViewDiffableDataSource<NewSectionIdentifierType, NewItemIdentifierType> {
282        unsafe { &*((self as *const Self).cast()) }
283    }
284}
285
286extern_conformance!(
287    unsafe impl<SectionIdentifierType: ?Sized, ItemIdentifierType: ?Sized> NSObjectProtocol
288        for NSCollectionViewDiffableDataSource<SectionIdentifierType, ItemIdentifierType>
289    {
290    }
291);
292
293impl<SectionIdentifierType: Message, ItemIdentifierType: Message>
294    NSCollectionViewDiffableDataSource<SectionIdentifierType, ItemIdentifierType>
295{
296    extern_methods!(
297        #[unsafe(method(init))]
298        #[unsafe(method_family = init)]
299        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
300
301        #[unsafe(method(new))]
302        #[unsafe(method_family = new)]
303        pub unsafe fn new() -> Retained<Self>;
304
305        #[unsafe(method(snapshot))]
306        #[unsafe(method_family = none)]
307        pub fn snapshot(
308            &self,
309        ) -> Retained<NSDiffableDataSourceSnapshot<SectionIdentifierType, ItemIdentifierType>>;
310
311        #[unsafe(method(applySnapshot:animatingDifferences:))]
312        #[unsafe(method_family = none)]
313        pub fn applySnapshot_animatingDifferences(
314            &self,
315            snapshot: &NSDiffableDataSourceSnapshot<SectionIdentifierType, ItemIdentifierType>,
316            animating_differences: bool,
317        );
318
319        #[unsafe(method(itemIdentifierForIndexPath:))]
320        #[unsafe(method_family = none)]
321        pub fn itemIdentifierForIndexPath(
322            &self,
323            index_path: &NSIndexPath,
324        ) -> Option<Retained<ItemIdentifierType>>;
325
326        #[unsafe(method(indexPathForItemIdentifier:))]
327        #[unsafe(method_family = none)]
328        pub fn indexPathForItemIdentifier(
329            &self,
330            identifier: &ItemIdentifierType,
331        ) -> Option<Retained<NSIndexPath>>;
332
333        #[cfg(all(
334            feature = "NSCollectionView",
335            feature = "NSResponder",
336            feature = "NSView",
337            feature = "block2"
338        ))]
339        /// # Safety
340        ///
341        /// - The returned block's argument 1 must be a valid pointer.
342        /// - The returned block's argument 2 must be a valid pointer.
343        /// - The returned block's argument 3 must be a valid pointer.
344        #[unsafe(method(supplementaryViewProvider))]
345        #[unsafe(method_family = none)]
346        pub unsafe fn supplementaryViewProvider(
347            &self,
348            mtm: MainThreadMarker,
349        ) -> NSCollectionViewDiffableDataSourceSupplementaryViewProvider;
350
351        #[cfg(all(
352            feature = "NSCollectionView",
353            feature = "NSResponder",
354            feature = "NSView",
355            feature = "block2"
356        ))]
357        /// Setter for [`supplementaryViewProvider`][Self::supplementaryViewProvider].
358        ///
359        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
360        ///
361        /// # Safety
362        ///
363        /// `supplementary_view_provider` must be a valid pointer or null.
364        #[unsafe(method(setSupplementaryViewProvider:))]
365        #[unsafe(method_family = none)]
366        pub unsafe fn setSupplementaryViewProvider(
367            &self,
368            supplementary_view_provider: NSCollectionViewDiffableDataSourceSupplementaryViewProvider,
369        );
370    );
371}