objc2_foundation/generated/
NSSet.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    /// **************    Immutable Set    ***************
11    ///
12    /// See also [Apple's documentation](https://developer.apple.com/documentation/foundation/nsset?language=objc)
13    #[unsafe(super(NSObject))]
14    #[derive(PartialEq, Eq, Hash)]
15    pub struct NSSet<ObjectType: ?Sized = AnyObject>;
16);
17
18#[cfg(feature = "NSObject")]
19extern_conformance!(
20    unsafe impl<ObjectType: ?Sized + NSCoding> NSCoding for NSSet<ObjectType> {}
21);
22
23#[cfg(feature = "NSObject")]
24extern_conformance!(
25    unsafe impl<ObjectType: ?Sized> NSCopying for NSSet<ObjectType> {}
26);
27
28#[cfg(feature = "NSObject")]
29unsafe impl<ObjectType: ?Sized + Message> CopyingHelper for NSSet<ObjectType> {
30    type Result = Self;
31}
32
33#[cfg(feature = "NSEnumerator")]
34extern_conformance!(
35    unsafe impl<ObjectType: ?Sized> NSFastEnumeration for NSSet<ObjectType> {}
36);
37
38#[cfg(feature = "NSObject")]
39extern_conformance!(
40    unsafe impl<ObjectType: ?Sized> NSMutableCopying for NSSet<ObjectType> {}
41);
42
43#[cfg(feature = "NSObject")]
44unsafe impl<ObjectType: ?Sized + Message> MutableCopyingHelper for NSSet<ObjectType> {
45    type Result = NSMutableSet<ObjectType>;
46}
47
48extern_conformance!(
49    unsafe impl<ObjectType: ?Sized> NSObjectProtocol for NSSet<ObjectType> {}
50);
51
52#[cfg(feature = "NSObject")]
53extern_conformance!(
54    unsafe impl<ObjectType: ?Sized + NSSecureCoding> NSSecureCoding for NSSet<ObjectType> {}
55);
56
57impl<ObjectType: Message> NSSet<ObjectType> {
58    extern_methods!(
59        #[unsafe(method(count))]
60        #[unsafe(method_family = none)]
61        pub fn count(&self) -> NSUInteger;
62
63        #[unsafe(method(member:))]
64        #[unsafe(method_family = none)]
65        pub fn member(&self, object: &ObjectType) -> Option<Retained<ObjectType>>;
66
67        #[cfg(feature = "NSEnumerator")]
68        #[unsafe(method(objectEnumerator))]
69        #[unsafe(method_family = none)]
70        pub unsafe fn objectEnumerator(&self) -> Retained<NSEnumerator<ObjectType>>;
71
72        #[unsafe(method(init))]
73        #[unsafe(method_family = init)]
74        pub fn init(this: Allocated<Self>) -> Retained<Self>;
75
76        #[unsafe(method(initWithObjects:count:))]
77        #[unsafe(method_family = init)]
78        pub unsafe fn initWithObjects_count(
79            this: Allocated<Self>,
80            objects: *mut NonNull<ObjectType>,
81            cnt: NSUInteger,
82        ) -> Retained<Self>;
83
84        #[cfg(feature = "NSCoder")]
85        #[unsafe(method(initWithCoder:))]
86        #[unsafe(method_family = init)]
87        pub unsafe fn initWithCoder(
88            this: Allocated<Self>,
89            coder: &NSCoder,
90        ) -> Option<Retained<Self>>;
91    );
92}
93
94/// Methods declared on superclass `NSObject`.
95impl<ObjectType: Message> NSSet<ObjectType> {
96    extern_methods!(
97        #[unsafe(method(new))]
98        #[unsafe(method_family = new)]
99        pub fn new() -> Retained<Self>;
100    );
101}
102
103impl<ObjectType: Message> DefaultRetained for NSSet<ObjectType> {
104    #[inline]
105    fn default_retained() -> Retained<Self> {
106        Self::new()
107    }
108}
109
110/// NSExtendedSet.
111impl<ObjectType: Message> NSSet<ObjectType> {
112    extern_methods!(
113        #[cfg(feature = "NSArray")]
114        #[unsafe(method(allObjects))]
115        #[unsafe(method_family = none)]
116        pub fn allObjects(&self) -> Retained<NSArray<ObjectType>>;
117
118        #[unsafe(method(anyObject))]
119        #[unsafe(method_family = none)]
120        pub fn anyObject(&self) -> Option<Retained<ObjectType>>;
121
122        #[unsafe(method(containsObject:))]
123        #[unsafe(method_family = none)]
124        pub fn containsObject(&self, an_object: &ObjectType) -> bool;
125
126        #[cfg(feature = "NSString")]
127        #[unsafe(method(description))]
128        #[unsafe(method_family = none)]
129        pub unsafe fn description(&self) -> Retained<NSString>;
130
131        #[cfg(feature = "NSString")]
132        #[unsafe(method(descriptionWithLocale:))]
133        #[unsafe(method_family = none)]
134        pub unsafe fn descriptionWithLocale(
135            &self,
136            locale: Option<&AnyObject>,
137        ) -> Retained<NSString>;
138
139        #[unsafe(method(intersectsSet:))]
140        #[unsafe(method_family = none)]
141        pub fn intersectsSet(&self, other_set: &NSSet<ObjectType>) -> bool;
142
143        #[unsafe(method(isEqualToSet:))]
144        #[unsafe(method_family = none)]
145        pub unsafe fn isEqualToSet(&self, other_set: &NSSet<ObjectType>) -> bool;
146
147        #[unsafe(method(isSubsetOfSet:))]
148        #[unsafe(method_family = none)]
149        pub fn isSubsetOfSet(&self, other_set: &NSSet<ObjectType>) -> bool;
150
151        #[unsafe(method(makeObjectsPerformSelector:))]
152        #[unsafe(method_family = none)]
153        pub unsafe fn makeObjectsPerformSelector(&self, a_selector: Sel);
154
155        #[unsafe(method(makeObjectsPerformSelector:withObject:))]
156        #[unsafe(method_family = none)]
157        pub unsafe fn makeObjectsPerformSelector_withObject(
158            &self,
159            a_selector: Sel,
160            argument: Option<&AnyObject>,
161        );
162
163        #[unsafe(method(setByAddingObject:))]
164        #[unsafe(method_family = none)]
165        pub unsafe fn setByAddingObject(
166            &self,
167            an_object: &ObjectType,
168        ) -> Retained<NSSet<ObjectType>>;
169
170        #[unsafe(method(setByAddingObjectsFromSet:))]
171        #[unsafe(method_family = none)]
172        pub unsafe fn setByAddingObjectsFromSet(
173            &self,
174            other: &NSSet<ObjectType>,
175        ) -> Retained<NSSet<ObjectType>>;
176
177        #[cfg(feature = "NSArray")]
178        #[unsafe(method(setByAddingObjectsFromArray:))]
179        #[unsafe(method_family = none)]
180        pub unsafe fn setByAddingObjectsFromArray(
181            &self,
182            other: &NSArray<ObjectType>,
183        ) -> Retained<NSSet<ObjectType>>;
184
185        #[cfg(feature = "block2")]
186        #[unsafe(method(enumerateObjectsUsingBlock:))]
187        #[unsafe(method_family = none)]
188        pub unsafe fn enumerateObjectsUsingBlock(
189            &self,
190            block: &block2::DynBlock<dyn Fn(NonNull<ObjectType>, NonNull<Bool>) + '_>,
191        );
192
193        #[cfg(all(feature = "NSObjCRuntime", feature = "block2"))]
194        #[unsafe(method(enumerateObjectsWithOptions:usingBlock:))]
195        #[unsafe(method_family = none)]
196        pub unsafe fn enumerateObjectsWithOptions_usingBlock(
197            &self,
198            opts: NSEnumerationOptions,
199            block: &block2::DynBlock<dyn Fn(NonNull<ObjectType>, NonNull<Bool>) + '_>,
200        );
201
202        #[cfg(feature = "block2")]
203        #[unsafe(method(objectsPassingTest:))]
204        #[unsafe(method_family = none)]
205        pub unsafe fn objectsPassingTest(
206            &self,
207            predicate: &block2::DynBlock<dyn Fn(NonNull<ObjectType>, NonNull<Bool>) -> Bool + '_>,
208        ) -> Retained<NSSet<ObjectType>>;
209
210        #[cfg(all(feature = "NSObjCRuntime", feature = "block2"))]
211        #[unsafe(method(objectsWithOptions:passingTest:))]
212        #[unsafe(method_family = none)]
213        pub unsafe fn objectsWithOptions_passingTest(
214            &self,
215            opts: NSEnumerationOptions,
216            predicate: &block2::DynBlock<dyn Fn(NonNull<ObjectType>, NonNull<Bool>) -> Bool + '_>,
217        ) -> Retained<NSSet<ObjectType>>;
218    );
219}
220
221/// NSSetCreation.
222impl<ObjectType: Message> NSSet<ObjectType> {
223    extern_methods!(
224        #[unsafe(method(set))]
225        #[unsafe(method_family = none)]
226        pub unsafe fn set() -> Retained<Self>;
227
228        #[unsafe(method(setWithObject:))]
229        #[unsafe(method_family = none)]
230        pub unsafe fn setWithObject(object: &ObjectType) -> Retained<Self>;
231
232        #[unsafe(method(setWithObjects:count:))]
233        #[unsafe(method_family = none)]
234        pub unsafe fn setWithObjects_count(
235            objects: NonNull<NonNull<ObjectType>>,
236            cnt: NSUInteger,
237        ) -> Retained<Self>;
238
239        #[unsafe(method(setWithSet:))]
240        #[unsafe(method_family = none)]
241        pub unsafe fn setWithSet(set: &NSSet<ObjectType>) -> Retained<Self>;
242
243        #[cfg(feature = "NSArray")]
244        #[unsafe(method(setWithArray:))]
245        #[unsafe(method_family = none)]
246        pub unsafe fn setWithArray(array: &NSArray<ObjectType>) -> Retained<Self>;
247
248        #[unsafe(method(initWithSet:))]
249        #[unsafe(method_family = init)]
250        pub unsafe fn initWithSet(this: Allocated<Self>, set: &NSSet<ObjectType>)
251            -> Retained<Self>;
252
253        #[unsafe(method(initWithSet:copyItems:))]
254        #[unsafe(method_family = init)]
255        pub unsafe fn initWithSet_copyItems(
256            this: Allocated<Self>,
257            set: &NSSet<ObjectType>,
258            flag: bool,
259        ) -> Retained<Self>;
260
261        #[cfg(feature = "NSArray")]
262        #[unsafe(method(initWithArray:))]
263        #[unsafe(method_family = init)]
264        pub unsafe fn initWithArray(
265            this: Allocated<Self>,
266            array: &NSArray<ObjectType>,
267        ) -> Retained<Self>;
268    );
269}
270
271/// Methods declared on superclass `NSSet`.
272///
273/// NSSetCreation.
274impl<ObjectType: Message> NSMutableSet<ObjectType> {
275    extern_methods!(
276        #[unsafe(method(set))]
277        #[unsafe(method_family = none)]
278        pub unsafe fn set() -> Retained<Self>;
279
280        #[unsafe(method(setWithObject:))]
281        #[unsafe(method_family = none)]
282        pub unsafe fn setWithObject(object: &ObjectType) -> Retained<Self>;
283
284        #[unsafe(method(setWithObjects:count:))]
285        #[unsafe(method_family = none)]
286        pub unsafe fn setWithObjects_count(
287            objects: NonNull<NonNull<ObjectType>>,
288            cnt: NSUInteger,
289        ) -> Retained<Self>;
290
291        #[unsafe(method(setWithSet:))]
292        #[unsafe(method_family = none)]
293        pub unsafe fn setWithSet(set: &NSSet<ObjectType>) -> Retained<Self>;
294
295        #[cfg(feature = "NSArray")]
296        #[unsafe(method(setWithArray:))]
297        #[unsafe(method_family = none)]
298        pub unsafe fn setWithArray(array: &NSArray<ObjectType>) -> Retained<Self>;
299
300        #[unsafe(method(initWithSet:))]
301        #[unsafe(method_family = init)]
302        pub unsafe fn initWithSet(this: Allocated<Self>, set: &NSSet<ObjectType>)
303            -> Retained<Self>;
304
305        #[unsafe(method(initWithSet:copyItems:))]
306        #[unsafe(method_family = init)]
307        pub unsafe fn initWithSet_copyItems(
308            this: Allocated<Self>,
309            set: &NSSet<ObjectType>,
310            flag: bool,
311        ) -> Retained<Self>;
312
313        #[cfg(feature = "NSArray")]
314        #[unsafe(method(initWithArray:))]
315        #[unsafe(method_family = init)]
316        pub unsafe fn initWithArray(
317            this: Allocated<Self>,
318            array: &NSArray<ObjectType>,
319        ) -> Retained<Self>;
320    );
321}
322
323extern_class!(
324    /// **************    Mutable Set    ***************
325    ///
326    /// See also [Apple's documentation](https://developer.apple.com/documentation/foundation/nsmutableset?language=objc)
327    #[unsafe(super(NSSet<ObjectType>, NSObject))]
328    #[derive(PartialEq, Eq, Hash)]
329    pub struct NSMutableSet<ObjectType: ?Sized = AnyObject>;
330);
331
332#[cfg(feature = "NSObject")]
333extern_conformance!(
334    unsafe impl<ObjectType: ?Sized + NSCoding> NSCoding for NSMutableSet<ObjectType> {}
335);
336
337#[cfg(feature = "NSObject")]
338extern_conformance!(
339    unsafe impl<ObjectType: ?Sized> NSCopying for NSMutableSet<ObjectType> {}
340);
341
342#[cfg(feature = "NSObject")]
343unsafe impl<ObjectType: ?Sized + Message> CopyingHelper for NSMutableSet<ObjectType> {
344    type Result = NSSet<ObjectType>;
345}
346
347#[cfg(feature = "NSEnumerator")]
348extern_conformance!(
349    unsafe impl<ObjectType: ?Sized> NSFastEnumeration for NSMutableSet<ObjectType> {}
350);
351
352#[cfg(feature = "NSObject")]
353extern_conformance!(
354    unsafe impl<ObjectType: ?Sized> NSMutableCopying for NSMutableSet<ObjectType> {}
355);
356
357#[cfg(feature = "NSObject")]
358unsafe impl<ObjectType: ?Sized + Message> MutableCopyingHelper for NSMutableSet<ObjectType> {
359    type Result = Self;
360}
361
362extern_conformance!(
363    unsafe impl<ObjectType: ?Sized> NSObjectProtocol for NSMutableSet<ObjectType> {}
364);
365
366#[cfg(feature = "NSObject")]
367extern_conformance!(
368    unsafe impl<ObjectType: ?Sized + NSSecureCoding> NSSecureCoding for NSMutableSet<ObjectType> {}
369);
370
371impl<ObjectType: Message> NSMutableSet<ObjectType> {
372    extern_methods!(
373        #[unsafe(method(addObject:))]
374        #[unsafe(method_family = none)]
375        pub fn addObject(&self, object: &ObjectType);
376
377        #[unsafe(method(removeObject:))]
378        #[unsafe(method_family = none)]
379        pub fn removeObject(&self, object: &ObjectType);
380
381        #[cfg(feature = "NSCoder")]
382        #[unsafe(method(initWithCoder:))]
383        #[unsafe(method_family = init)]
384        pub unsafe fn initWithCoder(
385            this: Allocated<Self>,
386            coder: &NSCoder,
387        ) -> Option<Retained<Self>>;
388
389        #[unsafe(method(init))]
390        #[unsafe(method_family = init)]
391        pub fn init(this: Allocated<Self>) -> Retained<Self>;
392
393        #[unsafe(method(initWithCapacity:))]
394        #[unsafe(method_family = init)]
395        pub fn initWithCapacity(this: Allocated<Self>, num_items: NSUInteger) -> Retained<Self>;
396    );
397}
398
399/// Methods declared on superclass `NSSet`.
400impl<ObjectType: Message> NSMutableSet<ObjectType> {
401    extern_methods!(
402        #[unsafe(method(initWithObjects:count:))]
403        #[unsafe(method_family = init)]
404        pub unsafe fn initWithObjects_count(
405            this: Allocated<Self>,
406            objects: *mut NonNull<ObjectType>,
407            cnt: NSUInteger,
408        ) -> Retained<Self>;
409    );
410}
411
412/// Methods declared on superclass `NSObject`.
413impl<ObjectType: Message> NSMutableSet<ObjectType> {
414    extern_methods!(
415        #[unsafe(method(new))]
416        #[unsafe(method_family = new)]
417        pub fn new() -> Retained<Self>;
418    );
419}
420
421impl<ObjectType: Message> DefaultRetained for NSMutableSet<ObjectType> {
422    #[inline]
423    fn default_retained() -> Retained<Self> {
424        Self::new()
425    }
426}
427
428/// NSExtendedMutableSet.
429impl<ObjectType: Message> NSMutableSet<ObjectType> {
430    extern_methods!(
431        #[cfg(feature = "NSArray")]
432        #[unsafe(method(addObjectsFromArray:))]
433        #[unsafe(method_family = none)]
434        pub unsafe fn addObjectsFromArray(&self, array: &NSArray<ObjectType>);
435
436        #[unsafe(method(intersectSet:))]
437        #[unsafe(method_family = none)]
438        pub unsafe fn intersectSet(&self, other_set: &NSSet<ObjectType>);
439
440        #[unsafe(method(minusSet:))]
441        #[unsafe(method_family = none)]
442        pub unsafe fn minusSet(&self, other_set: &NSSet<ObjectType>);
443
444        #[unsafe(method(removeAllObjects))]
445        #[unsafe(method_family = none)]
446        pub fn removeAllObjects(&self);
447
448        #[unsafe(method(unionSet:))]
449        #[unsafe(method_family = none)]
450        pub unsafe fn unionSet(&self, other_set: &NSSet<ObjectType>);
451
452        #[unsafe(method(setSet:))]
453        #[unsafe(method_family = none)]
454        pub unsafe fn setSet(&self, other_set: &NSSet<ObjectType>);
455    );
456}
457
458/// NSMutableSetCreation.
459impl<ObjectType: Message> NSMutableSet<ObjectType> {
460    extern_methods!(
461        #[unsafe(method(setWithCapacity:))]
462        #[unsafe(method_family = none)]
463        pub unsafe fn setWithCapacity(num_items: NSUInteger) -> Retained<Self>;
464    );
465}
466
467extern_class!(
468    /// **************    Counted Set    ***************
469    ///
470    /// See also [Apple's documentation](https://developer.apple.com/documentation/foundation/nscountedset?language=objc)
471    #[unsafe(super(NSMutableSet<ObjectType>, NSSet<ObjectType>, NSObject))]
472    #[derive(PartialEq, Eq, Hash)]
473    pub struct NSCountedSet<ObjectType: ?Sized = AnyObject>;
474);
475
476#[cfg(feature = "NSObject")]
477extern_conformance!(
478    unsafe impl<ObjectType: ?Sized + NSCoding> NSCoding for NSCountedSet<ObjectType> {}
479);
480
481#[cfg(feature = "NSEnumerator")]
482extern_conformance!(
483    unsafe impl<ObjectType: ?Sized> NSFastEnumeration for NSCountedSet<ObjectType> {}
484);
485
486extern_conformance!(
487    unsafe impl<ObjectType: ?Sized> NSObjectProtocol for NSCountedSet<ObjectType> {}
488);
489
490#[cfg(feature = "NSObject")]
491extern_conformance!(
492    unsafe impl<ObjectType: ?Sized + NSSecureCoding> NSSecureCoding for NSCountedSet<ObjectType> {}
493);
494
495impl<ObjectType: Message> NSCountedSet<ObjectType> {
496    extern_methods!(
497        #[unsafe(method(initWithCapacity:))]
498        #[unsafe(method_family = init)]
499        pub unsafe fn initWithCapacity(
500            this: Allocated<Self>,
501            num_items: NSUInteger,
502        ) -> Retained<Self>;
503
504        #[cfg(feature = "NSArray")]
505        #[unsafe(method(initWithArray:))]
506        #[unsafe(method_family = init)]
507        pub unsafe fn initWithArray(
508            this: Allocated<Self>,
509            array: &NSArray<ObjectType>,
510        ) -> Retained<Self>;
511
512        #[unsafe(method(initWithSet:))]
513        #[unsafe(method_family = init)]
514        pub unsafe fn initWithSet(this: Allocated<Self>, set: &NSSet<ObjectType>)
515            -> Retained<Self>;
516
517        #[unsafe(method(countForObject:))]
518        #[unsafe(method_family = none)]
519        pub unsafe fn countForObject(&self, object: &ObjectType) -> NSUInteger;
520
521        #[cfg(feature = "NSEnumerator")]
522        #[unsafe(method(objectEnumerator))]
523        #[unsafe(method_family = none)]
524        pub unsafe fn objectEnumerator(&self) -> Retained<NSEnumerator<ObjectType>>;
525
526        #[unsafe(method(addObject:))]
527        #[unsafe(method_family = none)]
528        pub unsafe fn addObject(&self, object: &ObjectType);
529
530        #[unsafe(method(removeObject:))]
531        #[unsafe(method_family = none)]
532        pub unsafe fn removeObject(&self, object: &ObjectType);
533    );
534}
535
536/// Methods declared on superclass `NSMutableSet`.
537impl<ObjectType: Message> NSCountedSet<ObjectType> {
538    extern_methods!(
539        #[cfg(feature = "NSCoder")]
540        #[unsafe(method(initWithCoder:))]
541        #[unsafe(method_family = init)]
542        pub unsafe fn initWithCoder(
543            this: Allocated<Self>,
544            coder: &NSCoder,
545        ) -> Option<Retained<Self>>;
546
547        #[unsafe(method(init))]
548        #[unsafe(method_family = init)]
549        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
550    );
551}
552
553/// Methods declared on superclass `NSSet`.
554impl<ObjectType: Message> NSCountedSet<ObjectType> {
555    extern_methods!(
556        #[unsafe(method(initWithObjects:count:))]
557        #[unsafe(method_family = init)]
558        pub unsafe fn initWithObjects_count(
559            this: Allocated<Self>,
560            objects: *mut NonNull<ObjectType>,
561            cnt: NSUInteger,
562        ) -> Retained<Self>;
563    );
564}
565
566/// Methods declared on superclass `NSObject`.
567impl<ObjectType: Message> NSCountedSet<ObjectType> {
568    extern_methods!(
569        #[unsafe(method(new))]
570        #[unsafe(method_family = new)]
571        pub unsafe fn new() -> Retained<Self>;
572    );
573}