1use 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 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 #[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(reloadedSectionIdentifiers))]
80 #[unsafe(method_family = none)]
81 pub fn reloadedSectionIdentifiers(&self) -> Retained<NSArray<SectionIdentifierType>>;
82
83 #[unsafe(method(reloadedItemIdentifiers))]
84 #[unsafe(method_family = none)]
85 pub fn reloadedItemIdentifiers(&self) -> Retained<NSArray<ItemIdentifierType>>;
86
87 #[unsafe(method(reconfiguredItemIdentifiers))]
88 #[unsafe(method_family = none)]
89 pub fn reconfiguredItemIdentifiers(&self) -> Retained<NSArray<ItemIdentifierType>>;
90
91 #[unsafe(method(numberOfItemsInSection:))]
92 #[unsafe(method_family = none)]
93 pub fn numberOfItemsInSection(
94 &self,
95 section_identifier: &SectionIdentifierType,
96 ) -> NSInteger;
97
98 #[unsafe(method(itemIdentifiersInSectionWithIdentifier:))]
99 #[unsafe(method_family = none)]
100 pub fn itemIdentifiersInSectionWithIdentifier(
101 &self,
102 section_identifier: &SectionIdentifierType,
103 ) -> Retained<NSArray<ItemIdentifierType>>;
104
105 #[unsafe(method(sectionIdentifierForSectionContainingItemIdentifier:))]
106 #[unsafe(method_family = none)]
107 pub fn sectionIdentifierForSectionContainingItemIdentifier(
108 &self,
109 item_identifier: &ItemIdentifierType,
110 ) -> Option<Retained<SectionIdentifierType>>;
111
112 #[unsafe(method(indexOfItemIdentifier:))]
113 #[unsafe(method_family = none)]
114 pub fn indexOfItemIdentifier(&self, item_identifier: &ItemIdentifierType) -> NSInteger;
115
116 #[unsafe(method(indexOfSectionIdentifier:))]
117 #[unsafe(method_family = none)]
118 pub fn indexOfSectionIdentifier(
119 &self,
120 section_identifier: &SectionIdentifierType,
121 ) -> NSInteger;
122
123 #[unsafe(method(appendItemsWithIdentifiers:))]
124 #[unsafe(method_family = none)]
125 pub fn appendItemsWithIdentifiers(&self, identifiers: &NSArray<ItemIdentifierType>);
126
127 #[unsafe(method(appendItemsWithIdentifiers:intoSectionWithIdentifier:))]
128 #[unsafe(method_family = none)]
129 pub fn appendItemsWithIdentifiers_intoSectionWithIdentifier(
130 &self,
131 identifiers: &NSArray<ItemIdentifierType>,
132 section_identifier: &SectionIdentifierType,
133 );
134
135 #[unsafe(method(insertItemsWithIdentifiers:beforeItemWithIdentifier:))]
136 #[unsafe(method_family = none)]
137 pub fn insertItemsWithIdentifiers_beforeItemWithIdentifier(
138 &self,
139 identifiers: &NSArray<ItemIdentifierType>,
140 item_identifier: &ItemIdentifierType,
141 );
142
143 #[unsafe(method(insertItemsWithIdentifiers:afterItemWithIdentifier:))]
144 #[unsafe(method_family = none)]
145 pub fn insertItemsWithIdentifiers_afterItemWithIdentifier(
146 &self,
147 identifiers: &NSArray<ItemIdentifierType>,
148 item_identifier: &ItemIdentifierType,
149 );
150
151 #[unsafe(method(deleteItemsWithIdentifiers:))]
152 #[unsafe(method_family = none)]
153 pub fn deleteItemsWithIdentifiers(&self, identifiers: &NSArray<ItemIdentifierType>);
154
155 #[unsafe(method(deleteAllItems))]
156 #[unsafe(method_family = none)]
157 pub fn deleteAllItems(&self);
158
159 #[unsafe(method(moveItemWithIdentifier:beforeItemWithIdentifier:))]
160 #[unsafe(method_family = none)]
161 pub fn moveItemWithIdentifier_beforeItemWithIdentifier(
162 &self,
163 from_identifier: &ItemIdentifierType,
164 to_identifier: &ItemIdentifierType,
165 );
166
167 #[unsafe(method(moveItemWithIdentifier:afterItemWithIdentifier:))]
168 #[unsafe(method_family = none)]
169 pub fn moveItemWithIdentifier_afterItemWithIdentifier(
170 &self,
171 from_identifier: &ItemIdentifierType,
172 to_identifier: &ItemIdentifierType,
173 );
174
175 #[unsafe(method(reloadItemsWithIdentifiers:))]
176 #[unsafe(method_family = none)]
177 pub fn reloadItemsWithIdentifiers(&self, identifiers: &NSArray<ItemIdentifierType>);
178
179 #[unsafe(method(reconfigureItemsWithIdentifiers:))]
180 #[unsafe(method_family = none)]
181 pub fn reconfigureItemsWithIdentifiers(&self, identifiers: &NSArray<ItemIdentifierType>);
182
183 #[unsafe(method(appendSectionsWithIdentifiers:))]
184 #[unsafe(method_family = none)]
185 pub fn appendSectionsWithIdentifiers(
186 &self,
187 section_identifiers: &NSArray<SectionIdentifierType>,
188 );
189
190 #[unsafe(method(insertSectionsWithIdentifiers:beforeSectionWithIdentifier:))]
191 #[unsafe(method_family = none)]
192 pub fn insertSectionsWithIdentifiers_beforeSectionWithIdentifier(
193 &self,
194 section_identifiers: &NSArray<SectionIdentifierType>,
195 to_section_identifier: &SectionIdentifierType,
196 );
197
198 #[unsafe(method(insertSectionsWithIdentifiers:afterSectionWithIdentifier:))]
199 #[unsafe(method_family = none)]
200 pub fn insertSectionsWithIdentifiers_afterSectionWithIdentifier(
201 &self,
202 section_identifiers: &NSArray<SectionIdentifierType>,
203 to_section_identifier: &SectionIdentifierType,
204 );
205
206 #[unsafe(method(deleteSectionsWithIdentifiers:))]
207 #[unsafe(method_family = none)]
208 pub fn deleteSectionsWithIdentifiers(
209 &self,
210 section_identifiers: &NSArray<SectionIdentifierType>,
211 );
212
213 #[unsafe(method(moveSectionWithIdentifier:beforeSectionWithIdentifier:))]
214 #[unsafe(method_family = none)]
215 pub fn moveSectionWithIdentifier_beforeSectionWithIdentifier(
216 &self,
217 from_section_identifier: &SectionIdentifierType,
218 to_section_identifier: &SectionIdentifierType,
219 );
220
221 #[unsafe(method(moveSectionWithIdentifier:afterSectionWithIdentifier:))]
222 #[unsafe(method_family = none)]
223 pub fn moveSectionWithIdentifier_afterSectionWithIdentifier(
224 &self,
225 from_section_identifier: &SectionIdentifierType,
226 to_section_identifier: &SectionIdentifierType,
227 );
228
229 #[unsafe(method(reloadSectionsWithIdentifiers:))]
230 #[unsafe(method_family = none)]
231 pub fn reloadSectionsWithIdentifiers(
232 &self,
233 section_identifiers: &NSArray<SectionIdentifierType>,
234 );
235 );
236}
237
238impl<SectionIdentifierType: Message, ItemIdentifierType: Message>
240 NSDiffableDataSourceSnapshot<SectionIdentifierType, ItemIdentifierType>
241{
242 extern_methods!(
243 #[unsafe(method(init))]
244 #[unsafe(method_family = init)]
245 pub fn init(this: Allocated<Self>) -> Retained<Self>;
246
247 #[unsafe(method(new))]
248 #[unsafe(method_family = new)]
249 pub fn new() -> Retained<Self>;
250 );
251}
252
253impl<SectionIdentifierType: Message, ItemIdentifierType: Message> DefaultRetained
254 for NSDiffableDataSourceSnapshot<SectionIdentifierType, ItemIdentifierType>
255{
256 #[inline]
257 fn default_retained() -> Retained<Self> {
258 Self::new()
259 }
260}
261
262#[cfg(all(
264 feature = "UICollectionView",
265 feature = "UICollectionViewCell",
266 feature = "UIResponder",
267 feature = "UIScrollView",
268 feature = "UIView",
269 feature = "block2"
270))]
271pub type UICollectionViewDiffableDataSourceCellProvider = *mut block2::DynBlock<
272 dyn Fn(
273 NonNull<UICollectionView>,
274 NonNull<NSIndexPath>,
275 NonNull<AnyObject>,
276 ) -> *mut UICollectionViewCell,
277>;
278
279#[cfg(all(
281 feature = "UICollectionView",
282 feature = "UICollectionViewCell",
283 feature = "UIResponder",
284 feature = "UIScrollView",
285 feature = "UIView",
286 feature = "block2"
287))]
288pub type UICollectionViewDiffableDataSourceSupplementaryViewProvider = *mut block2::DynBlock<
289 dyn Fn(
290 NonNull<UICollectionView>,
291 NonNull<NSString>,
292 NonNull<NSIndexPath>,
293 ) -> *mut UICollectionReusableView,
294>;
295
296extern_class!(
297 #[unsafe(super(NSObject))]
299 #[derive(Debug, PartialEq, Eq, Hash)]
300 pub struct NSDiffableDataSourceSectionTransaction<
301 SectionIdentifierType: ?Sized = AnyObject,
302 ItemIdentifierType: ?Sized = AnyObject,
303 >;
304);
305
306impl<SectionIdentifierType: ?Sized + Message, ItemIdentifierType: ?Sized + Message>
307 NSDiffableDataSourceSectionTransaction<SectionIdentifierType, ItemIdentifierType>
308{
309 #[inline]
315 pub unsafe fn cast_unchecked<
316 NewSectionIdentifierType: ?Sized + Message,
317 NewItemIdentifierType: ?Sized + Message,
318 >(
319 &self,
320 ) -> &NSDiffableDataSourceSectionTransaction<NewSectionIdentifierType, NewItemIdentifierType>
321 {
322 unsafe { &*((self as *const Self).cast()) }
323 }
324}
325
326extern_conformance!(
327 unsafe impl<SectionIdentifierType: ?Sized, ItemIdentifierType: ?Sized> NSObjectProtocol
328 for NSDiffableDataSourceSectionTransaction<SectionIdentifierType, ItemIdentifierType>
329 {
330 }
331);
332
333impl<SectionIdentifierType: Message, ItemIdentifierType: Message>
334 NSDiffableDataSourceSectionTransaction<SectionIdentifierType, ItemIdentifierType>
335{
336 extern_methods!(
337 #[unsafe(method(sectionIdentifier))]
343 #[unsafe(method_family = none)]
344 pub unsafe fn sectionIdentifier(&self) -> Retained<SectionIdentifierType>;
345
346 #[cfg(feature = "NSDiffableDataSourceSectionSnapshot")]
347 #[unsafe(method(initialSnapshot))]
353 #[unsafe(method_family = none)]
354 pub unsafe fn initialSnapshot(
355 &self,
356 ) -> Retained<NSDiffableDataSourceSectionSnapshot<ItemIdentifierType>>;
357
358 #[cfg(feature = "NSDiffableDataSourceSectionSnapshot")]
359 #[unsafe(method(finalSnapshot))]
365 #[unsafe(method_family = none)]
366 pub unsafe fn finalSnapshot(
367 &self,
368 ) -> Retained<NSDiffableDataSourceSectionSnapshot<ItemIdentifierType>>;
369
370 #[unsafe(method(difference))]
376 #[unsafe(method_family = none)]
377 pub unsafe fn difference(
378 &self,
379 ) -> Retained<NSOrderedCollectionDifference<ItemIdentifierType>>;
380 );
381}
382
383impl<SectionIdentifierType: Message, ItemIdentifierType: Message>
385 NSDiffableDataSourceSectionTransaction<SectionIdentifierType, ItemIdentifierType>
386{
387 extern_methods!(
388 #[unsafe(method(init))]
389 #[unsafe(method_family = init)]
390 pub fn init(this: Allocated<Self>) -> Retained<Self>;
391
392 #[unsafe(method(new))]
393 #[unsafe(method_family = new)]
394 pub fn new() -> Retained<Self>;
395 );
396}
397
398impl<SectionIdentifierType: Message, ItemIdentifierType: Message> DefaultRetained
399 for NSDiffableDataSourceSectionTransaction<SectionIdentifierType, ItemIdentifierType>
400{
401 #[inline]
402 fn default_retained() -> Retained<Self> {
403 Self::new()
404 }
405}
406
407extern_class!(
408 #[unsafe(super(NSObject))]
410 #[derive(Debug, PartialEq, Eq, Hash)]
411 pub struct NSDiffableDataSourceTransaction<
412 SectionIdentifierType: ?Sized = AnyObject,
413 ItemIdentifierType: ?Sized = AnyObject,
414 >;
415);
416
417impl<SectionIdentifierType: ?Sized + Message, ItemIdentifierType: ?Sized + Message>
418 NSDiffableDataSourceTransaction<SectionIdentifierType, ItemIdentifierType>
419{
420 #[inline]
426 pub unsafe fn cast_unchecked<
427 NewSectionIdentifierType: ?Sized + Message,
428 NewItemIdentifierType: ?Sized + Message,
429 >(
430 &self,
431 ) -> &NSDiffableDataSourceTransaction<NewSectionIdentifierType, NewItemIdentifierType> {
432 unsafe { &*((self as *const Self).cast()) }
433 }
434}
435
436extern_conformance!(
437 unsafe impl<SectionIdentifierType: ?Sized, ItemIdentifierType: ?Sized> NSObjectProtocol
438 for NSDiffableDataSourceTransaction<SectionIdentifierType, ItemIdentifierType>
439 {
440 }
441);
442
443impl<SectionIdentifierType: Message, ItemIdentifierType: Message>
444 NSDiffableDataSourceTransaction<SectionIdentifierType, ItemIdentifierType>
445{
446 extern_methods!(
447 #[unsafe(method(initialSnapshot))]
453 #[unsafe(method_family = none)]
454 pub unsafe fn initialSnapshot(
455 &self,
456 ) -> Retained<NSDiffableDataSourceSnapshot<SectionIdentifierType, ItemIdentifierType>>;
457
458 #[unsafe(method(finalSnapshot))]
464 #[unsafe(method_family = none)]
465 pub unsafe fn finalSnapshot(
466 &self,
467 ) -> Retained<NSDiffableDataSourceSnapshot<SectionIdentifierType, ItemIdentifierType>>;
468
469 #[unsafe(method(difference))]
475 #[unsafe(method_family = none)]
476 pub unsafe fn difference(
477 &self,
478 ) -> Retained<NSOrderedCollectionDifference<ItemIdentifierType>>;
479
480 #[unsafe(method(sectionTransactions))]
486 #[unsafe(method_family = none)]
487 pub unsafe fn sectionTransactions(
488 &self,
489 ) -> Retained<
490 NSArray<
491 NSDiffableDataSourceSectionTransaction<SectionIdentifierType, ItemIdentifierType>,
492 >,
493 >;
494 );
495}
496
497impl<SectionIdentifierType: Message, ItemIdentifierType: Message>
499 NSDiffableDataSourceTransaction<SectionIdentifierType, ItemIdentifierType>
500{
501 extern_methods!(
502 #[unsafe(method(init))]
503 #[unsafe(method_family = init)]
504 pub fn init(this: Allocated<Self>) -> Retained<Self>;
505
506 #[unsafe(method(new))]
507 #[unsafe(method_family = new)]
508 pub fn new() -> Retained<Self>;
509 );
510}
511
512impl<SectionIdentifierType: Message, ItemIdentifierType: Message> DefaultRetained
513 for NSDiffableDataSourceTransaction<SectionIdentifierType, ItemIdentifierType>
514{
515 #[inline]
516 fn default_retained() -> Retained<Self> {
517 Self::new()
518 }
519}
520
521extern_class!(
522 #[unsafe(super(NSObject))]
524 #[thread_kind = MainThreadOnly]
525 #[derive(Debug, PartialEq, Eq, Hash)]
526 pub struct UICollectionViewDiffableDataSourceReorderingHandlers<
527 SectionType: ?Sized = AnyObject,
528 ItemType: ?Sized = AnyObject,
529 >;
530);
531
532impl<SectionType: ?Sized + Message, ItemType: ?Sized + Message>
533 UICollectionViewDiffableDataSourceReorderingHandlers<SectionType, ItemType>
534{
535 #[inline]
541 pub unsafe fn cast_unchecked<
542 NewSectionType: ?Sized + Message,
543 NewItemType: ?Sized + Message,
544 >(
545 &self,
546 ) -> &UICollectionViewDiffableDataSourceReorderingHandlers<NewSectionType, NewItemType> {
547 unsafe { &*((self as *const Self).cast()) }
548 }
549}
550
551extern_conformance!(
552 unsafe impl<SectionType: ?Sized, ItemType: ?Sized> NSCopying
553 for UICollectionViewDiffableDataSourceReorderingHandlers<SectionType, ItemType>
554 {
555 }
556);
557
558unsafe impl<SectionType: ?Sized + Message, ItemType: ?Sized + Message> CopyingHelper
559 for UICollectionViewDiffableDataSourceReorderingHandlers<SectionType, ItemType>
560{
561 type Result = Self;
562}
563
564extern_conformance!(
565 unsafe impl<SectionType: ?Sized, ItemType: ?Sized> NSObjectProtocol
566 for UICollectionViewDiffableDataSourceReorderingHandlers<SectionType, ItemType>
567 {
568 }
569);
570
571impl<SectionType: Message, ItemType: Message>
572 UICollectionViewDiffableDataSourceReorderingHandlers<SectionType, ItemType>
573{
574 extern_methods!(
575 #[cfg(feature = "block2")]
576 #[unsafe(method(canReorderItemHandler))]
580 #[unsafe(method_family = none)]
581 pub unsafe fn canReorderItemHandler(
582 &self,
583 ) -> *mut block2::DynBlock<dyn Fn(NonNull<ItemType>) -> Bool>;
584
585 #[cfg(feature = "block2")]
586 #[unsafe(method(setCanReorderItemHandler:))]
590 #[unsafe(method_family = none)]
591 pub fn setCanReorderItemHandler(
592 &self,
593 can_reorder_item_handler: Option<&block2::DynBlock<dyn Fn(NonNull<ItemType>) -> Bool>>,
594 );
595
596 #[cfg(feature = "block2")]
597 #[unsafe(method(willReorderHandler))]
601 #[unsafe(method_family = none)]
602 pub unsafe fn willReorderHandler(
603 &self,
604 ) -> *mut block2::DynBlock<
605 dyn Fn(NonNull<NSDiffableDataSourceTransaction<SectionType, ItemType>>),
606 >;
607
608 #[cfg(feature = "block2")]
609 #[unsafe(method(setWillReorderHandler:))]
613 #[unsafe(method_family = none)]
614 pub fn setWillReorderHandler(
615 &self,
616 will_reorder_handler: Option<
617 &block2::DynBlock<
618 dyn Fn(NonNull<NSDiffableDataSourceTransaction<SectionType, ItemType>>),
619 >,
620 >,
621 );
622
623 #[cfg(feature = "block2")]
624 #[unsafe(method(didReorderHandler))]
628 #[unsafe(method_family = none)]
629 pub unsafe fn didReorderHandler(
630 &self,
631 ) -> *mut block2::DynBlock<
632 dyn Fn(NonNull<NSDiffableDataSourceTransaction<SectionType, ItemType>>),
633 >;
634
635 #[cfg(feature = "block2")]
636 #[unsafe(method(setDidReorderHandler:))]
640 #[unsafe(method_family = none)]
641 pub fn setDidReorderHandler(
642 &self,
643 did_reorder_handler: Option<
644 &block2::DynBlock<
645 dyn Fn(NonNull<NSDiffableDataSourceTransaction<SectionType, ItemType>>),
646 >,
647 >,
648 );
649 );
650}
651
652impl<SectionType: Message, ItemType: Message>
654 UICollectionViewDiffableDataSourceReorderingHandlers<SectionType, ItemType>
655{
656 extern_methods!(
657 #[unsafe(method(init))]
658 #[unsafe(method_family = init)]
659 pub fn init(this: Allocated<Self>) -> Retained<Self>;
660
661 #[unsafe(method(new))]
662 #[unsafe(method_family = new)]
663 pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
664 );
665}
666
667extern_class!(
668 #[unsafe(super(NSObject))]
670 #[thread_kind = MainThreadOnly]
671 #[derive(Debug, PartialEq, Eq, Hash)]
672 pub struct UICollectionViewDiffableDataSourceSectionSnapshotHandlers<
673 ItemType: ?Sized = AnyObject,
674 >;
675);
676
677impl<ItemType: ?Sized + Message>
678 UICollectionViewDiffableDataSourceSectionSnapshotHandlers<ItemType>
679{
680 #[inline]
686 pub unsafe fn cast_unchecked<NewItemType: ?Sized + Message>(
687 &self,
688 ) -> &UICollectionViewDiffableDataSourceSectionSnapshotHandlers<NewItemType> {
689 unsafe { &*((self as *const Self).cast()) }
690 }
691}
692
693extern_conformance!(
694 unsafe impl<ItemType: ?Sized> NSCopying
695 for UICollectionViewDiffableDataSourceSectionSnapshotHandlers<ItemType>
696 {
697 }
698);
699
700unsafe impl<ItemType: ?Sized + Message> CopyingHelper
701 for UICollectionViewDiffableDataSourceSectionSnapshotHandlers<ItemType>
702{
703 type Result = Self;
704}
705
706extern_conformance!(
707 unsafe impl<ItemType: ?Sized> NSObjectProtocol
708 for UICollectionViewDiffableDataSourceSectionSnapshotHandlers<ItemType>
709 {
710 }
711);
712
713impl<ItemType: Message> UICollectionViewDiffableDataSourceSectionSnapshotHandlers<ItemType> {
714 extern_methods!(
715 #[cfg(feature = "block2")]
716 #[unsafe(method(shouldExpandItemHandler))]
720 #[unsafe(method_family = none)]
721 pub unsafe fn shouldExpandItemHandler(
722 &self,
723 ) -> *mut block2::DynBlock<dyn Fn(NonNull<ItemType>) -> Bool>;
724
725 #[cfg(feature = "block2")]
726 #[unsafe(method(setShouldExpandItemHandler:))]
730 #[unsafe(method_family = none)]
731 pub fn setShouldExpandItemHandler(
732 &self,
733 should_expand_item_handler: Option<
734 &block2::DynBlock<dyn Fn(NonNull<ItemType>) -> Bool>,
735 >,
736 );
737
738 #[cfg(feature = "block2")]
739 #[unsafe(method(willExpandItemHandler))]
743 #[unsafe(method_family = none)]
744 pub unsafe fn willExpandItemHandler(
745 &self,
746 ) -> *mut block2::DynBlock<dyn Fn(NonNull<ItemType>)>;
747
748 #[cfg(feature = "block2")]
749 #[unsafe(method(setWillExpandItemHandler:))]
753 #[unsafe(method_family = none)]
754 pub fn setWillExpandItemHandler(
755 &self,
756 will_expand_item_handler: Option<&block2::DynBlock<dyn Fn(NonNull<ItemType>)>>,
757 );
758
759 #[cfg(feature = "block2")]
760 #[unsafe(method(shouldCollapseItemHandler))]
764 #[unsafe(method_family = none)]
765 pub unsafe fn shouldCollapseItemHandler(
766 &self,
767 ) -> *mut block2::DynBlock<dyn Fn(NonNull<ItemType>) -> Bool>;
768
769 #[cfg(feature = "block2")]
770 #[unsafe(method(setShouldCollapseItemHandler:))]
774 #[unsafe(method_family = none)]
775 pub fn setShouldCollapseItemHandler(
776 &self,
777 should_collapse_item_handler: Option<
778 &block2::DynBlock<dyn Fn(NonNull<ItemType>) -> Bool>,
779 >,
780 );
781
782 #[cfg(feature = "block2")]
783 #[unsafe(method(willCollapseItemHandler))]
787 #[unsafe(method_family = none)]
788 pub unsafe fn willCollapseItemHandler(
789 &self,
790 ) -> *mut block2::DynBlock<dyn Fn(NonNull<ItemType>)>;
791
792 #[cfg(feature = "block2")]
793 #[unsafe(method(setWillCollapseItemHandler:))]
797 #[unsafe(method_family = none)]
798 pub fn setWillCollapseItemHandler(
799 &self,
800 will_collapse_item_handler: Option<&block2::DynBlock<dyn Fn(NonNull<ItemType>)>>,
801 );
802
803 #[cfg(all(feature = "NSDiffableDataSourceSectionSnapshot", feature = "block2"))]
804 #[unsafe(method(snapshotForExpandingParentItemHandler))]
809 #[unsafe(method_family = none)]
810 pub unsafe fn snapshotForExpandingParentItemHandler(
811 &self,
812 ) -> *mut block2::DynBlock<
813 dyn Fn(
814 NonNull<ItemType>,
815 NonNull<NSDiffableDataSourceSectionSnapshot<ItemType>>,
816 ) -> NonNull<NSDiffableDataSourceSectionSnapshot<ItemType>>,
817 >;
818
819 #[cfg(all(feature = "NSDiffableDataSourceSectionSnapshot", feature = "block2"))]
820 #[unsafe(method(setSnapshotForExpandingParentItemHandler:))]
828 #[unsafe(method_family = none)]
829 pub unsafe fn setSnapshotForExpandingParentItemHandler(
830 &self,
831 snapshot_for_expanding_parent_item_handler: Option<
832 &block2::DynBlock<
833 dyn Fn(
834 NonNull<ItemType>,
835 NonNull<NSDiffableDataSourceSectionSnapshot<ItemType>>,
836 )
837 -> NonNull<NSDiffableDataSourceSectionSnapshot<ItemType>>,
838 >,
839 >,
840 );
841 );
842}
843
844impl<ItemType: Message> UICollectionViewDiffableDataSourceSectionSnapshotHandlers<ItemType> {
846 extern_methods!(
847 #[unsafe(method(init))]
848 #[unsafe(method_family = init)]
849 pub fn init(this: Allocated<Self>) -> Retained<Self>;
850
851 #[unsafe(method(new))]
852 #[unsafe(method_family = new)]
853 pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
854 );
855}
856
857extern_class!(
858 #[unsafe(super(NSObject))]
860 #[thread_kind = MainThreadOnly]
861 #[derive(Debug, PartialEq, Eq, Hash)]
862 pub struct UICollectionViewDiffableDataSource<
863 SectionIdentifierType: ?Sized = AnyObject,
864 ItemIdentifierType: ?Sized = AnyObject,
865 >;
866);
867
868impl<SectionIdentifierType: ?Sized + Message, ItemIdentifierType: ?Sized + Message>
869 UICollectionViewDiffableDataSource<SectionIdentifierType, ItemIdentifierType>
870{
871 #[inline]
877 pub unsafe fn cast_unchecked<
878 NewSectionIdentifierType: ?Sized + Message,
879 NewItemIdentifierType: ?Sized + Message,
880 >(
881 &self,
882 ) -> &UICollectionViewDiffableDataSource<NewSectionIdentifierType, NewItemIdentifierType> {
883 unsafe { &*((self as *const Self).cast()) }
884 }
885}
886
887extern_conformance!(
888 unsafe impl<SectionIdentifierType: ?Sized, ItemIdentifierType: ?Sized> NSObjectProtocol
889 for UICollectionViewDiffableDataSource<SectionIdentifierType, ItemIdentifierType>
890 {
891 }
892);
893
894#[cfg(feature = "UICollectionView")]
895extern_conformance!(
896 unsafe impl<SectionIdentifierType: ?Sized + Message, ItemIdentifierType: ?Sized + Message>
897 UICollectionViewDataSource
898 for UICollectionViewDiffableDataSource<SectionIdentifierType, ItemIdentifierType>
899 {
900 }
901);
902
903impl<SectionIdentifierType: Message, ItemIdentifierType: Message>
904 UICollectionViewDiffableDataSource<SectionIdentifierType, ItemIdentifierType>
905{
906 extern_methods!(
907 #[cfg(all(
908 feature = "UICollectionView",
909 feature = "UICollectionViewCell",
910 feature = "UIResponder",
911 feature = "UIScrollView",
912 feature = "UIView",
913 feature = "block2"
914 ))]
915 #[unsafe(method(initWithCollectionView:cellProvider:))]
919 #[unsafe(method_family = init)]
920 pub unsafe fn initWithCollectionView_cellProvider(
921 this: Allocated<Self>,
922 collection_view: &UICollectionView,
923 cell_provider: UICollectionViewDiffableDataSourceCellProvider,
924 ) -> Retained<Self>;
925
926 #[unsafe(method(init))]
927 #[unsafe(method_family = init)]
928 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
929
930 #[unsafe(method(new))]
931 #[unsafe(method_family = new)]
932 pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
933
934 #[cfg(all(
935 feature = "UICollectionView",
936 feature = "UICollectionViewCell",
937 feature = "UIResponder",
938 feature = "UIScrollView",
939 feature = "UIView",
940 feature = "block2"
941 ))]
942 #[unsafe(method(supplementaryViewProvider))]
948 #[unsafe(method_family = none)]
949 pub unsafe fn supplementaryViewProvider(
950 &self,
951 ) -> UICollectionViewDiffableDataSourceSupplementaryViewProvider;
952
953 #[cfg(all(
954 feature = "UICollectionView",
955 feature = "UICollectionViewCell",
956 feature = "UIResponder",
957 feature = "UIScrollView",
958 feature = "UIView",
959 feature = "block2"
960 ))]
961 #[unsafe(method(setSupplementaryViewProvider:))]
969 #[unsafe(method_family = none)]
970 pub unsafe fn setSupplementaryViewProvider(
971 &self,
972 supplementary_view_provider: UICollectionViewDiffableDataSourceSupplementaryViewProvider,
973 );
974
975 #[unsafe(method(snapshot))]
976 #[unsafe(method_family = none)]
977 pub fn snapshot(
978 &self,
979 ) -> Retained<NSDiffableDataSourceSnapshot<SectionIdentifierType, ItemIdentifierType>>;
980
981 #[unsafe(method(applySnapshot:animatingDifferences:))]
982 #[unsafe(method_family = none)]
983 pub fn applySnapshot_animatingDifferences(
984 &self,
985 snapshot: &NSDiffableDataSourceSnapshot<SectionIdentifierType, ItemIdentifierType>,
986 animating_differences: bool,
987 );
988
989 #[cfg(feature = "block2")]
990 #[unsafe(method(applySnapshot:animatingDifferences:completion:))]
991 #[unsafe(method_family = none)]
992 pub fn applySnapshot_animatingDifferences_completion(
993 &self,
994 snapshot: &NSDiffableDataSourceSnapshot<SectionIdentifierType, ItemIdentifierType>,
995 animating_differences: bool,
996 completion: Option<&block2::DynBlock<dyn Fn()>>,
997 );
998
999 #[unsafe(method(applySnapshotUsingReloadData:))]
1000 #[unsafe(method_family = none)]
1001 pub fn applySnapshotUsingReloadData(
1002 &self,
1003 snapshot: &NSDiffableDataSourceSnapshot<SectionIdentifierType, ItemIdentifierType>,
1004 );
1005
1006 #[cfg(feature = "block2")]
1007 #[unsafe(method(applySnapshotUsingReloadData:completion:))]
1008 #[unsafe(method_family = none)]
1009 pub fn applySnapshotUsingReloadData_completion(
1010 &self,
1011 snapshot: &NSDiffableDataSourceSnapshot<SectionIdentifierType, ItemIdentifierType>,
1012 completion: Option<&block2::DynBlock<dyn Fn()>>,
1013 );
1014
1015 #[unsafe(method(sectionIdentifierForIndex:))]
1016 #[unsafe(method_family = none)]
1017 pub fn sectionIdentifierForIndex(
1018 &self,
1019 index: NSInteger,
1020 ) -> Option<Retained<SectionIdentifierType>>;
1021
1022 #[unsafe(method(indexForSectionIdentifier:))]
1023 #[unsafe(method_family = none)]
1024 pub fn indexForSectionIdentifier(&self, identifier: &SectionIdentifierType) -> NSInteger;
1025
1026 #[unsafe(method(itemIdentifierForIndexPath:))]
1027 #[unsafe(method_family = none)]
1028 pub fn itemIdentifierForIndexPath(
1029 &self,
1030 index_path: &NSIndexPath,
1031 ) -> Option<Retained<ItemIdentifierType>>;
1032
1033 #[unsafe(method(indexPathForItemIdentifier:))]
1034 #[unsafe(method_family = none)]
1035 pub fn indexPathForItemIdentifier(
1036 &self,
1037 identifier: &ItemIdentifierType,
1038 ) -> Option<Retained<NSIndexPath>>;
1039
1040 #[unsafe(method(reorderingHandlers))]
1041 #[unsafe(method_family = none)]
1042 pub fn reorderingHandlers(
1043 &self,
1044 ) -> Retained<
1045 UICollectionViewDiffableDataSourceReorderingHandlers<
1046 SectionIdentifierType,
1047 ItemIdentifierType,
1048 >,
1049 >;
1050
1051 #[unsafe(method(setReorderingHandlers:))]
1055 #[unsafe(method_family = none)]
1056 pub fn setReorderingHandlers(
1057 &self,
1058 reordering_handlers: &UICollectionViewDiffableDataSourceReorderingHandlers<
1059 SectionIdentifierType,
1060 ItemIdentifierType,
1061 >,
1062 );
1063
1064 #[cfg(feature = "NSDiffableDataSourceSectionSnapshot")]
1065 #[unsafe(method(applySnapshot:toSection:animatingDifferences:))]
1066 #[unsafe(method_family = none)]
1067 pub fn applySnapshot_toSection_animatingDifferences(
1068 &self,
1069 snapshot: &NSDiffableDataSourceSectionSnapshot<ItemIdentifierType>,
1070 section_identifier: &SectionIdentifierType,
1071 animating_differences: bool,
1072 );
1073
1074 #[cfg(all(feature = "NSDiffableDataSourceSectionSnapshot", feature = "block2"))]
1075 #[unsafe(method(applySnapshot:toSection:animatingDifferences:completion:))]
1076 #[unsafe(method_family = none)]
1077 pub fn applySnapshot_toSection_animatingDifferences_completion(
1078 &self,
1079 snapshot: &NSDiffableDataSourceSectionSnapshot<ItemIdentifierType>,
1080 section_identifier: &SectionIdentifierType,
1081 animating_differences: bool,
1082 completion: Option<&block2::DynBlock<dyn Fn()>>,
1083 );
1084
1085 #[cfg(feature = "NSDiffableDataSourceSectionSnapshot")]
1086 #[unsafe(method(snapshotForSection:))]
1087 #[unsafe(method_family = none)]
1088 pub fn snapshotForSection(
1089 &self,
1090 section: &SectionIdentifierType,
1091 ) -> Retained<NSDiffableDataSourceSectionSnapshot<ItemIdentifierType>>;
1092
1093 #[unsafe(method(sectionSnapshotHandlers))]
1094 #[unsafe(method_family = none)]
1095 pub fn sectionSnapshotHandlers(
1096 &self,
1097 ) -> Retained<UICollectionViewDiffableDataSourceSectionSnapshotHandlers<ItemIdentifierType>>;
1098
1099 #[unsafe(method(setSectionSnapshotHandlers:))]
1103 #[unsafe(method_family = none)]
1104 pub fn setSectionSnapshotHandlers(
1105 &self,
1106 section_snapshot_handlers: &UICollectionViewDiffableDataSourceSectionSnapshotHandlers<
1107 ItemIdentifierType,
1108 >,
1109 );
1110 );
1111}
1112
1113#[cfg(all(
1115 feature = "UIResponder",
1116 feature = "UIScrollView",
1117 feature = "UITableView",
1118 feature = "UITableViewCell",
1119 feature = "UIView",
1120 feature = "block2"
1121))]
1122pub type UITableViewDiffableDataSourceCellProvider = *mut block2::DynBlock<
1123 dyn Fn(NonNull<UITableView>, NonNull<NSIndexPath>, NonNull<AnyObject>) -> *mut UITableViewCell,
1124>;
1125
1126extern_class!(
1127 #[unsafe(super(NSObject))]
1129 #[thread_kind = MainThreadOnly]
1130 #[derive(Debug, PartialEq, Eq, Hash)]
1131 pub struct UITableViewDiffableDataSource<
1132 SectionIdentifierType: ?Sized = AnyObject,
1133 ItemIdentifierType: ?Sized = AnyObject,
1134 >;
1135);
1136
1137impl<SectionIdentifierType: ?Sized + Message, ItemIdentifierType: ?Sized + Message>
1138 UITableViewDiffableDataSource<SectionIdentifierType, ItemIdentifierType>
1139{
1140 #[inline]
1146 pub unsafe fn cast_unchecked<
1147 NewSectionIdentifierType: ?Sized + Message,
1148 NewItemIdentifierType: ?Sized + Message,
1149 >(
1150 &self,
1151 ) -> &UITableViewDiffableDataSource<NewSectionIdentifierType, NewItemIdentifierType> {
1152 unsafe { &*((self as *const Self).cast()) }
1153 }
1154}
1155
1156extern_conformance!(
1157 unsafe impl<SectionIdentifierType: ?Sized, ItemIdentifierType: ?Sized> NSObjectProtocol
1158 for UITableViewDiffableDataSource<SectionIdentifierType, ItemIdentifierType>
1159 {
1160 }
1161);
1162
1163#[cfg(feature = "UITableView")]
1164extern_conformance!(
1165 unsafe impl<SectionIdentifierType: ?Sized + Message, ItemIdentifierType: ?Sized + Message>
1166 UITableViewDataSource
1167 for UITableViewDiffableDataSource<SectionIdentifierType, ItemIdentifierType>
1168 {
1169 }
1170);
1171
1172impl<SectionIdentifierType: Message, ItemIdentifierType: Message>
1173 UITableViewDiffableDataSource<SectionIdentifierType, ItemIdentifierType>
1174{
1175 extern_methods!(
1176 #[cfg(all(
1177 feature = "UIResponder",
1178 feature = "UIScrollView",
1179 feature = "UITableView",
1180 feature = "UITableViewCell",
1181 feature = "UIView",
1182 feature = "block2"
1183 ))]
1184 #[unsafe(method(initWithTableView:cellProvider:))]
1188 #[unsafe(method_family = init)]
1189 pub unsafe fn initWithTableView_cellProvider(
1190 this: Allocated<Self>,
1191 table_view: &UITableView,
1192 cell_provider: UITableViewDiffableDataSourceCellProvider,
1193 ) -> Retained<Self>;
1194
1195 #[unsafe(method(init))]
1196 #[unsafe(method_family = init)]
1197 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
1198
1199 #[unsafe(method(new))]
1200 #[unsafe(method_family = new)]
1201 pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
1202
1203 #[unsafe(method(snapshot))]
1204 #[unsafe(method_family = none)]
1205 pub fn snapshot(
1206 &self,
1207 ) -> Retained<NSDiffableDataSourceSnapshot<SectionIdentifierType, ItemIdentifierType>>;
1208
1209 #[unsafe(method(applySnapshot:animatingDifferences:))]
1210 #[unsafe(method_family = none)]
1211 pub fn applySnapshot_animatingDifferences(
1212 &self,
1213 snapshot: &NSDiffableDataSourceSnapshot<SectionIdentifierType, ItemIdentifierType>,
1214 animating_differences: bool,
1215 );
1216
1217 #[cfg(feature = "block2")]
1218 #[unsafe(method(applySnapshot:animatingDifferences:completion:))]
1219 #[unsafe(method_family = none)]
1220 pub fn applySnapshot_animatingDifferences_completion(
1221 &self,
1222 snapshot: &NSDiffableDataSourceSnapshot<SectionIdentifierType, ItemIdentifierType>,
1223 animating_differences: bool,
1224 completion: Option<&block2::DynBlock<dyn Fn()>>,
1225 );
1226
1227 #[unsafe(method(applySnapshotUsingReloadData:))]
1228 #[unsafe(method_family = none)]
1229 pub fn applySnapshotUsingReloadData(
1230 &self,
1231 snapshot: &NSDiffableDataSourceSnapshot<SectionIdentifierType, ItemIdentifierType>,
1232 );
1233
1234 #[cfg(feature = "block2")]
1235 #[unsafe(method(applySnapshotUsingReloadData:completion:))]
1236 #[unsafe(method_family = none)]
1237 pub fn applySnapshotUsingReloadData_completion(
1238 &self,
1239 snapshot: &NSDiffableDataSourceSnapshot<SectionIdentifierType, ItemIdentifierType>,
1240 completion: Option<&block2::DynBlock<dyn Fn()>>,
1241 );
1242
1243 #[unsafe(method(sectionIdentifierForIndex:))]
1244 #[unsafe(method_family = none)]
1245 pub fn sectionIdentifierForIndex(
1246 &self,
1247 index: NSInteger,
1248 ) -> Option<Retained<SectionIdentifierType>>;
1249
1250 #[unsafe(method(indexForSectionIdentifier:))]
1251 #[unsafe(method_family = none)]
1252 pub fn indexForSectionIdentifier(&self, identifier: &SectionIdentifierType) -> NSInteger;
1253
1254 #[unsafe(method(itemIdentifierForIndexPath:))]
1255 #[unsafe(method_family = none)]
1256 pub fn itemIdentifierForIndexPath(
1257 &self,
1258 index_path: &NSIndexPath,
1259 ) -> Option<Retained<ItemIdentifierType>>;
1260
1261 #[unsafe(method(indexPathForItemIdentifier:))]
1262 #[unsafe(method_family = none)]
1263 pub fn indexPathForItemIdentifier(
1264 &self,
1265 identifier: &ItemIdentifierType,
1266 ) -> Option<Retained<NSIndexPath>>;
1267
1268 #[cfg(feature = "UITableView")]
1269 #[unsafe(method(defaultRowAnimation))]
1270 #[unsafe(method_family = none)]
1271 pub fn defaultRowAnimation(&self) -> UITableViewRowAnimation;
1272
1273 #[cfg(feature = "UITableView")]
1274 #[unsafe(method(setDefaultRowAnimation:))]
1276 #[unsafe(method_family = none)]
1277 pub fn setDefaultRowAnimation(&self, default_row_animation: UITableViewRowAnimation);
1278 );
1279}