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