objc2_foundation/generated/
NSIndexPath.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::*;
6
7use crate::*;
8
9extern_class!(
10    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsindexpath?language=objc)
11    #[unsafe(super(NSObject))]
12    #[derive(Debug, PartialEq, Eq, Hash)]
13    pub struct NSIndexPath;
14);
15
16#[cfg(feature = "NSObject")]
17extern_conformance!(
18    unsafe impl NSCoding for NSIndexPath {}
19);
20
21#[cfg(feature = "NSObject")]
22extern_conformance!(
23    unsafe impl NSCopying for NSIndexPath {}
24);
25
26#[cfg(feature = "NSObject")]
27unsafe impl CopyingHelper for NSIndexPath {
28    type Result = Self;
29}
30
31extern_conformance!(
32    unsafe impl NSObjectProtocol for NSIndexPath {}
33);
34
35#[cfg(feature = "NSObject")]
36extern_conformance!(
37    unsafe impl NSSecureCoding for NSIndexPath {}
38);
39
40impl NSIndexPath {
41    extern_methods!(
42        #[unsafe(method(indexPathWithIndex:))]
43        #[unsafe(method_family = none)]
44        pub fn indexPathWithIndex(index: NSUInteger) -> Retained<Self>;
45
46        /// # Safety
47        ///
48        /// `indexes` must be a valid pointer or null.
49        #[unsafe(method(indexPathWithIndexes:length:))]
50        #[unsafe(method_family = none)]
51        pub unsafe fn indexPathWithIndexes_length(
52            indexes: *mut NSUInteger,
53            length: NSUInteger,
54        ) -> Retained<Self>;
55
56        /// # Safety
57        ///
58        /// `indexes` must be a valid pointer or null.
59        #[unsafe(method(initWithIndexes:length:))]
60        #[unsafe(method_family = init)]
61        pub unsafe fn initWithIndexes_length(
62            this: Allocated<Self>,
63            indexes: *mut NSUInteger,
64            length: NSUInteger,
65        ) -> Retained<Self>;
66
67        #[unsafe(method(initWithIndex:))]
68        #[unsafe(method_family = init)]
69        pub fn initWithIndex(this: Allocated<Self>, index: NSUInteger) -> Retained<Self>;
70
71        #[unsafe(method(indexPathByAddingIndex:))]
72        #[unsafe(method_family = none)]
73        pub fn indexPathByAddingIndex(&self, index: NSUInteger) -> Retained<NSIndexPath>;
74
75        #[unsafe(method(indexPathByRemovingLastIndex))]
76        #[unsafe(method_family = none)]
77        pub fn indexPathByRemovingLastIndex(&self) -> Retained<NSIndexPath>;
78
79        #[unsafe(method(indexAtPosition:))]
80        #[unsafe(method_family = none)]
81        pub fn indexAtPosition(&self, position: NSUInteger) -> NSUInteger;
82
83        #[unsafe(method(length))]
84        #[unsafe(method_family = none)]
85        pub fn length(&self) -> NSUInteger;
86
87        #[cfg(feature = "NSRange")]
88        /// Copies the indexes stored in this index path from the positions specified by positionRange into indexes.
89        ///
90        /// Parameter `indexes`: Buffer of at least as many NSUIntegers as specified by the length of positionRange. On return, this memory will hold the index path's indexes.
91        ///
92        /// Parameter `positionRange`: A range of valid positions within this index path.  If the location plus the length of positionRange is greater than the length of this index path, this method raises an NSRangeException.
93        ///
94        /// It is the developer’s responsibility to allocate the memory for the C array.
95        ///
96        /// # Safety
97        ///
98        /// `indexes` must be a valid pointer.
99        #[unsafe(method(getIndexes:range:))]
100        #[unsafe(method_family = none)]
101        pub unsafe fn getIndexes_range(
102            &self,
103            indexes: NonNull<NSUInteger>,
104            position_range: NSRange,
105        );
106
107        #[cfg(feature = "NSObjCRuntime")]
108        #[unsafe(method(compare:))]
109        #[unsafe(method_family = none)]
110        pub fn compare(&self, other_object: &NSIndexPath) -> NSComparisonResult;
111    );
112}
113
114/// Methods declared on superclass `NSObject`.
115impl NSIndexPath {
116    extern_methods!(
117        #[unsafe(method(init))]
118        #[unsafe(method_family = init)]
119        pub fn init(this: Allocated<Self>) -> Retained<Self>;
120
121        #[unsafe(method(new))]
122        #[unsafe(method_family = new)]
123        pub fn new() -> Retained<Self>;
124    );
125}
126
127impl DefaultRetained for NSIndexPath {
128    #[inline]
129    fn default_retained() -> Retained<Self> {
130        Self::new()
131    }
132}
133
134/// NSDeprecated.
135impl NSIndexPath {
136    extern_methods!(
137        /// This method is unsafe because it could potentially cause buffer overruns. You should use -getIndexes:range: instead.
138        ///
139        /// # Safety
140        ///
141        /// `indexes` must be a valid pointer.
142        #[deprecated]
143        #[unsafe(method(getIndexes:))]
144        #[unsafe(method_family = none)]
145        pub unsafe fn getIndexes(&self, indexes: NonNull<NSUInteger>);
146    );
147}