objc2_foundation/generated/
NSOrderedCollectionDifference.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ptr::NonNull;
4use objc2::__framework_prelude::*;
5
6use crate::*;
7
8/// Options supported by methods that produce difference objects.
9///
10/// See also [Apple's documentation](https://developer.apple.com/documentation/foundation/nsorderedcollectiondifferencecalculationoptions?language=objc)
11// NS_OPTIONS
12#[repr(transparent)]
13#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
14pub struct NSOrderedCollectionDifferenceCalculationOptions(pub NSUInteger);
15bitflags::bitflags! {
16    impl NSOrderedCollectionDifferenceCalculationOptions: NSUInteger {
17/// Insertion changes do not store a reference to the inserted object.
18        #[doc(alias = "NSOrderedCollectionDifferenceCalculationOmitInsertedObjects")]
19        const OmitInsertedObjects = 1<<0;
20/// Insertion changes do not store a reference to the removed object.
21        #[doc(alias = "NSOrderedCollectionDifferenceCalculationOmitRemovedObjects")]
22        const OmitRemovedObjects = 1<<1;
23/// Assume objects that were uniquely removed and inserted were moved.
24/// This is useful when diffing based on identity instead of equality.
25        #[doc(alias = "NSOrderedCollectionDifferenceCalculationInferMoves")]
26        const InferMoves = 1<<2;
27    }
28}
29
30unsafe impl Encode for NSOrderedCollectionDifferenceCalculationOptions {
31    const ENCODING: Encoding = NSUInteger::ENCODING;
32}
33
34unsafe impl RefEncode for NSOrderedCollectionDifferenceCalculationOptions {
35    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
36}
37
38extern_class!(
39    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsorderedcollectiondifference?language=objc)
40    #[unsafe(super(NSObject))]
41    #[derive(Debug, PartialEq, Eq, Hash)]
42    pub struct NSOrderedCollectionDifference<ObjectType: ?Sized = AnyObject>;
43);
44
45#[cfg(feature = "NSEnumerator")]
46unsafe impl<ObjectType: ?Sized> NSFastEnumeration for NSOrderedCollectionDifference<ObjectType> {}
47
48unsafe impl<ObjectType: ?Sized> NSObjectProtocol for NSOrderedCollectionDifference<ObjectType> {}
49
50impl<ObjectType: Message> NSOrderedCollectionDifference<ObjectType> {
51    extern_methods!(
52        #[cfg(all(feature = "NSArray", feature = "NSOrderedCollectionChange"))]
53        /// Creates a new difference representing the changes in the parameter.
54        ///
55        /// For clients interested in the difference between two collections, the
56        /// collection's differenceFrom method should be used instead.
57        ///
58        /// To guarantee that instances are unambiguous and safe for compatible base
59        /// states, this method requires that its parameter conform to the following
60        /// requirements:
61        ///
62        /// 1) All insertion offsets are unique
63        /// 2) All removal offsets are unique
64        /// 3) All associated indexes match a change with the opposite parity.
65        #[unsafe(method(initWithChanges:))]
66        #[unsafe(method_family = init)]
67        pub unsafe fn initWithChanges(
68            this: Allocated<Self>,
69            changes: &NSArray<NSOrderedCollectionChange<ObjectType>>,
70        ) -> Retained<Self>;
71
72        #[cfg(all(
73            feature = "NSArray",
74            feature = "NSIndexSet",
75            feature = "NSOrderedCollectionChange"
76        ))]
77        #[unsafe(method(initWithInsertIndexes:insertedObjects:removeIndexes:removedObjects:additionalChanges:))]
78        #[unsafe(method_family = init)]
79        pub unsafe fn initWithInsertIndexes_insertedObjects_removeIndexes_removedObjects_additionalChanges(
80            this: Allocated<Self>,
81            inserts: &NSIndexSet,
82            inserted_objects: Option<&NSArray<ObjectType>>,
83            removes: &NSIndexSet,
84            removed_objects: Option<&NSArray<ObjectType>>,
85            changes: &NSArray<NSOrderedCollectionChange<ObjectType>>,
86        ) -> Retained<Self>;
87
88        #[cfg(all(feature = "NSArray", feature = "NSIndexSet"))]
89        #[unsafe(method(initWithInsertIndexes:insertedObjects:removeIndexes:removedObjects:))]
90        #[unsafe(method_family = init)]
91        pub unsafe fn initWithInsertIndexes_insertedObjects_removeIndexes_removedObjects(
92            this: Allocated<Self>,
93            inserts: &NSIndexSet,
94            inserted_objects: Option<&NSArray<ObjectType>>,
95            removes: &NSIndexSet,
96            removed_objects: Option<&NSArray<ObjectType>>,
97        ) -> Retained<Self>;
98
99        #[cfg(all(feature = "NSArray", feature = "NSOrderedCollectionChange"))]
100        #[unsafe(method(insertions))]
101        #[unsafe(method_family = none)]
102        pub unsafe fn insertions(&self)
103            -> Retained<NSArray<NSOrderedCollectionChange<ObjectType>>>;
104
105        #[cfg(all(feature = "NSArray", feature = "NSOrderedCollectionChange"))]
106        #[unsafe(method(removals))]
107        #[unsafe(method_family = none)]
108        pub unsafe fn removals(&self) -> Retained<NSArray<NSOrderedCollectionChange<ObjectType>>>;
109
110        #[unsafe(method(hasChanges))]
111        #[unsafe(method_family = none)]
112        pub unsafe fn hasChanges(&self) -> bool;
113
114        #[cfg(all(feature = "NSOrderedCollectionChange", feature = "block2"))]
115        #[unsafe(method(differenceByTransformingChangesWithBlock:))]
116        #[unsafe(method_family = none)]
117        pub unsafe fn differenceByTransformingChangesWithBlock(
118            &self,
119            block: &block2::Block<
120                dyn Fn(
121                        NonNull<NSOrderedCollectionChange<ObjectType>>,
122                    ) -> NonNull<NSOrderedCollectionChange<AnyObject>>
123                    + '_,
124            >,
125        ) -> Retained<NSOrderedCollectionDifference<AnyObject>>;
126
127        #[unsafe(method(inverseDifference))]
128        #[unsafe(method_family = none)]
129        pub unsafe fn inverseDifference(&self) -> Retained<Self>;
130    );
131}
132
133/// Methods declared on superclass `NSObject`.
134impl<ObjectType: Message> NSOrderedCollectionDifference<ObjectType> {
135    extern_methods!(
136        #[unsafe(method(init))]
137        #[unsafe(method_family = init)]
138        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
139
140        #[unsafe(method(new))]
141        #[unsafe(method_family = new)]
142        pub unsafe fn new() -> Retained<Self>;
143    );
144}