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")]
46extern_conformance!(
47    unsafe impl<ObjectType: ?Sized> NSFastEnumeration for NSOrderedCollectionDifference<ObjectType> {}
48);
49
50extern_conformance!(
51    unsafe impl<ObjectType: ?Sized> NSObjectProtocol for NSOrderedCollectionDifference<ObjectType> {}
52);
53
54impl<ObjectType: Message> NSOrderedCollectionDifference<ObjectType> {
55    extern_methods!(
56        #[cfg(all(feature = "NSArray", feature = "NSOrderedCollectionChange"))]
57        /// Creates a new difference representing the changes in the parameter.
58        ///
59        /// For clients interested in the difference between two collections, the
60        /// collection's differenceFrom method should be used instead.
61        ///
62        /// To guarantee that instances are unambiguous and safe for compatible base
63        /// states, this method requires that its parameter conform to the following
64        /// requirements:
65        ///
66        /// 1) All insertion offsets are unique
67        /// 2) All removal offsets are unique
68        /// 3) All associated indexes match a change with the opposite parity.
69        #[unsafe(method(initWithChanges:))]
70        #[unsafe(method_family = init)]
71        pub unsafe fn initWithChanges(
72            this: Allocated<Self>,
73            changes: &NSArray<NSOrderedCollectionChange<ObjectType>>,
74        ) -> Retained<Self>;
75
76        #[cfg(all(
77            feature = "NSArray",
78            feature = "NSIndexSet",
79            feature = "NSOrderedCollectionChange"
80        ))]
81        #[unsafe(method(initWithInsertIndexes:insertedObjects:removeIndexes:removedObjects:additionalChanges:))]
82        #[unsafe(method_family = init)]
83        pub unsafe fn initWithInsertIndexes_insertedObjects_removeIndexes_removedObjects_additionalChanges(
84            this: Allocated<Self>,
85            inserts: &NSIndexSet,
86            inserted_objects: Option<&NSArray<ObjectType>>,
87            removes: &NSIndexSet,
88            removed_objects: Option<&NSArray<ObjectType>>,
89            changes: &NSArray<NSOrderedCollectionChange<ObjectType>>,
90        ) -> Retained<Self>;
91
92        #[cfg(all(feature = "NSArray", feature = "NSIndexSet"))]
93        #[unsafe(method(initWithInsertIndexes:insertedObjects:removeIndexes:removedObjects:))]
94        #[unsafe(method_family = init)]
95        pub unsafe fn initWithInsertIndexes_insertedObjects_removeIndexes_removedObjects(
96            this: Allocated<Self>,
97            inserts: &NSIndexSet,
98            inserted_objects: Option<&NSArray<ObjectType>>,
99            removes: &NSIndexSet,
100            removed_objects: Option<&NSArray<ObjectType>>,
101        ) -> Retained<Self>;
102
103        #[cfg(all(feature = "NSArray", feature = "NSOrderedCollectionChange"))]
104        #[unsafe(method(insertions))]
105        #[unsafe(method_family = none)]
106        pub unsafe fn insertions(&self)
107            -> Retained<NSArray<NSOrderedCollectionChange<ObjectType>>>;
108
109        #[cfg(all(feature = "NSArray", feature = "NSOrderedCollectionChange"))]
110        #[unsafe(method(removals))]
111        #[unsafe(method_family = none)]
112        pub unsafe fn removals(&self) -> Retained<NSArray<NSOrderedCollectionChange<ObjectType>>>;
113
114        #[unsafe(method(hasChanges))]
115        #[unsafe(method_family = none)]
116        pub unsafe fn hasChanges(&self) -> bool;
117
118        #[cfg(all(feature = "NSOrderedCollectionChange", feature = "block2"))]
119        #[unsafe(method(differenceByTransformingChangesWithBlock:))]
120        #[unsafe(method_family = none)]
121        pub unsafe fn differenceByTransformingChangesWithBlock(
122            &self,
123            block: &block2::DynBlock<
124                dyn Fn(
125                        NonNull<NSOrderedCollectionChange<ObjectType>>,
126                    ) -> NonNull<NSOrderedCollectionChange<AnyObject>>
127                    + '_,
128            >,
129        ) -> Retained<NSOrderedCollectionDifference<AnyObject>>;
130
131        #[unsafe(method(inverseDifference))]
132        #[unsafe(method_family = none)]
133        pub unsafe fn inverseDifference(&self) -> Retained<Self>;
134    );
135}
136
137/// Methods declared on superclass `NSObject`.
138impl<ObjectType: Message> NSOrderedCollectionDifference<ObjectType> {
139    extern_methods!(
140        #[unsafe(method(init))]
141        #[unsafe(method_family = init)]
142        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
143
144        #[unsafe(method(new))]
145        #[unsafe(method_family = new)]
146        pub unsafe fn new() -> Retained<Self>;
147    );
148}