objc2_foundation/generated/
NSSet.rs1use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6#[cfg(feature = "objc2-core-foundation")]
7use objc2_core_foundation::*;
8
9use crate::*;
10
11extern_class!(
12 #[unsafe(super(NSObject))]
16 #[derive(PartialEq, Eq, Hash)]
17 pub struct NSSet<ObjectType: ?Sized = AnyObject>;
18);
19
20#[cfg(feature = "objc2-core-foundation")]
21impl<ObjectType: ?Sized + Message> AsRef<NSSet<ObjectType>> for CFSet<ObjectType> {
22 #[inline]
23 fn as_ref(&self) -> &NSSet<ObjectType> {
24 unsafe { &*((self as *const Self).cast()) }
25 }
26}
27
28#[cfg(feature = "objc2-core-foundation")]
29impl<ObjectType: ?Sized + Message> AsRef<CFSet<ObjectType>> for NSSet<ObjectType> {
30 #[inline]
31 fn as_ref(&self) -> &CFSet<ObjectType> {
32 unsafe { &*((self as *const Self).cast()) }
33 }
34}
35
36impl<ObjectType: ?Sized + Message> NSSet<ObjectType> {
37 #[inline]
43 pub unsafe fn cast_unchecked<NewObjectType: ?Sized + Message>(&self) -> &NSSet<NewObjectType> {
44 unsafe { &*((self as *const Self).cast()) }
45 }
46}
47
48#[cfg(feature = "NSObject")]
49extern_conformance!(
50 unsafe impl<ObjectType: ?Sized + NSCoding> NSCoding for NSSet<ObjectType> {}
51);
52
53#[cfg(feature = "NSObject")]
54extern_conformance!(
55 unsafe impl<ObjectType: ?Sized> NSCopying for NSSet<ObjectType> {}
56);
57
58#[cfg(feature = "NSObject")]
59unsafe impl<ObjectType: ?Sized + Message> CopyingHelper for NSSet<ObjectType> {
60 type Result = Self;
61}
62
63#[cfg(feature = "NSEnumerator")]
64extern_conformance!(
65 unsafe impl<ObjectType: ?Sized> NSFastEnumeration for NSSet<ObjectType> {}
66);
67
68#[cfg(feature = "NSObject")]
69extern_conformance!(
70 unsafe impl<ObjectType: ?Sized> NSMutableCopying for NSSet<ObjectType> {}
71);
72
73#[cfg(feature = "NSObject")]
74unsafe impl<ObjectType: ?Sized + Message> MutableCopyingHelper for NSSet<ObjectType> {
75 type Result = NSMutableSet<ObjectType>;
76}
77
78extern_conformance!(
79 unsafe impl<ObjectType: ?Sized> NSObjectProtocol for NSSet<ObjectType> {}
80);
81
82#[cfg(feature = "NSObject")]
83extern_conformance!(
84 unsafe impl<ObjectType: ?Sized + NSSecureCoding> NSSecureCoding for NSSet<ObjectType> {}
85);
86
87impl<ObjectType: Message> NSSet<ObjectType> {
88 extern_methods!(
89 #[unsafe(method(count))]
90 #[unsafe(method_family = none)]
91 pub fn count(&self) -> NSUInteger;
92
93 #[unsafe(method(member:))]
94 #[unsafe(method_family = none)]
95 pub fn member(&self, object: &ObjectType) -> Option<Retained<ObjectType>>;
96
97 #[cfg(feature = "NSEnumerator")]
98 #[unsafe(method(objectEnumerator))]
102 #[unsafe(method_family = none)]
103 pub unsafe fn objectEnumerator(&self) -> Retained<NSEnumerator<ObjectType>>;
104
105 #[unsafe(method(init))]
106 #[unsafe(method_family = init)]
107 pub fn init(this: Allocated<Self>) -> Retained<Self>;
108
109 #[unsafe(method(initWithObjects:count:))]
113 #[unsafe(method_family = init)]
114 pub unsafe fn initWithObjects_count(
115 this: Allocated<Self>,
116 objects: *mut NonNull<ObjectType>,
117 cnt: NSUInteger,
118 ) -> Retained<Self>;
119
120 #[cfg(feature = "NSCoder")]
121 #[unsafe(method(initWithCoder:))]
125 #[unsafe(method_family = init)]
126 pub unsafe fn initWithCoder(
127 this: Allocated<Self>,
128 coder: &NSCoder,
129 ) -> Option<Retained<Self>>;
130 );
131}
132
133impl<ObjectType: Message> NSSet<ObjectType> {
135 extern_methods!(
136 #[unsafe(method(new))]
137 #[unsafe(method_family = new)]
138 pub fn new() -> Retained<Self>;
139 );
140}
141
142impl<ObjectType: Message> DefaultRetained for NSSet<ObjectType> {
143 #[inline]
144 fn default_retained() -> Retained<Self> {
145 Self::new()
146 }
147}
148
149impl<ObjectType: Message> NSSet<ObjectType> {
151 extern_methods!(
152 #[cfg(feature = "NSArray")]
153 #[unsafe(method(allObjects))]
154 #[unsafe(method_family = none)]
155 pub fn allObjects(&self) -> Retained<NSArray<ObjectType>>;
156
157 #[unsafe(method(anyObject))]
158 #[unsafe(method_family = none)]
159 pub fn anyObject(&self) -> Option<Retained<ObjectType>>;
160
161 #[unsafe(method(containsObject:))]
162 #[unsafe(method_family = none)]
163 pub fn containsObject(&self, an_object: &ObjectType) -> bool;
164
165 #[cfg(feature = "NSString")]
166 #[unsafe(method(description))]
167 #[unsafe(method_family = none)]
168 pub fn description(&self) -> Retained<NSString>;
169
170 #[cfg(feature = "NSString")]
171 #[unsafe(method(descriptionWithLocale:))]
175 #[unsafe(method_family = none)]
176 pub unsafe fn descriptionWithLocale(
177 &self,
178 locale: Option<&AnyObject>,
179 ) -> Retained<NSString>;
180
181 #[unsafe(method(intersectsSet:))]
182 #[unsafe(method_family = none)]
183 pub fn intersectsSet(&self, other_set: &NSSet<ObjectType>) -> bool;
184
185 #[unsafe(method(isEqualToSet:))]
186 #[unsafe(method_family = none)]
187 pub fn isEqualToSet(&self, other_set: &NSSet<ObjectType>) -> bool;
188
189 #[unsafe(method(isSubsetOfSet:))]
190 #[unsafe(method_family = none)]
191 pub fn isSubsetOfSet(&self, other_set: &NSSet<ObjectType>) -> bool;
192
193 #[unsafe(method(makeObjectsPerformSelector:))]
197 #[unsafe(method_family = none)]
198 pub unsafe fn makeObjectsPerformSelector(&self, a_selector: Sel);
199
200 #[unsafe(method(makeObjectsPerformSelector:withObject:))]
205 #[unsafe(method_family = none)]
206 pub unsafe fn makeObjectsPerformSelector_withObject(
207 &self,
208 a_selector: Sel,
209 argument: Option<&AnyObject>,
210 );
211
212 #[unsafe(method(setByAddingObject:))]
213 #[unsafe(method_family = none)]
214 pub fn setByAddingObject(&self, an_object: &ObjectType) -> Retained<NSSet<ObjectType>>;
215
216 #[unsafe(method(setByAddingObjectsFromSet:))]
217 #[unsafe(method_family = none)]
218 pub fn setByAddingObjectsFromSet(
219 &self,
220 other: &NSSet<ObjectType>,
221 ) -> Retained<NSSet<ObjectType>>;
222
223 #[cfg(feature = "NSArray")]
224 #[unsafe(method(setByAddingObjectsFromArray:))]
225 #[unsafe(method_family = none)]
226 pub fn setByAddingObjectsFromArray(
227 &self,
228 other: &NSArray<ObjectType>,
229 ) -> Retained<NSSet<ObjectType>>;
230
231 #[cfg(feature = "block2")]
232 #[unsafe(method(enumerateObjectsUsingBlock:))]
233 #[unsafe(method_family = none)]
234 pub fn enumerateObjectsUsingBlock(
235 &self,
236 block: &block2::DynBlock<dyn Fn(NonNull<ObjectType>, NonNull<Bool>) + '_>,
237 );
238
239 #[cfg(all(feature = "NSObjCRuntime", feature = "block2"))]
240 #[unsafe(method(enumerateObjectsWithOptions:usingBlock:))]
241 #[unsafe(method_family = none)]
242 pub fn enumerateObjectsWithOptions_usingBlock(
243 &self,
244 opts: NSEnumerationOptions,
245 block: &block2::DynBlock<dyn Fn(NonNull<ObjectType>, NonNull<Bool>) + '_>,
246 );
247
248 #[cfg(feature = "block2")]
249 #[unsafe(method(objectsPassingTest:))]
250 #[unsafe(method_family = none)]
251 pub fn objectsPassingTest(
252 &self,
253 predicate: &block2::DynBlock<dyn Fn(NonNull<ObjectType>, NonNull<Bool>) -> Bool + '_>,
254 ) -> Retained<NSSet<ObjectType>>;
255
256 #[cfg(all(feature = "NSObjCRuntime", feature = "block2"))]
257 #[unsafe(method(objectsWithOptions:passingTest:))]
258 #[unsafe(method_family = none)]
259 pub fn objectsWithOptions_passingTest(
260 &self,
261 opts: NSEnumerationOptions,
262 predicate: &block2::DynBlock<dyn Fn(NonNull<ObjectType>, NonNull<Bool>) -> Bool + '_>,
263 ) -> Retained<NSSet<ObjectType>>;
264 );
265}
266
267impl<ObjectType: Message> NSSet<ObjectType> {
269 extern_methods!(
270 #[unsafe(method(set))]
271 #[unsafe(method_family = none)]
272 pub fn set() -> Retained<Self>;
273
274 #[unsafe(method(setWithObject:))]
275 #[unsafe(method_family = none)]
276 pub fn setWithObject(object: &ObjectType) -> Retained<Self>;
277
278 #[unsafe(method(setWithObjects:count:))]
282 #[unsafe(method_family = none)]
283 pub unsafe fn setWithObjects_count(
284 objects: NonNull<NonNull<ObjectType>>,
285 cnt: NSUInteger,
286 ) -> Retained<Self>;
287
288 #[unsafe(method(setWithSet:))]
289 #[unsafe(method_family = none)]
290 pub fn setWithSet(set: &NSSet<ObjectType>) -> Retained<Self>;
291
292 #[cfg(feature = "NSArray")]
293 #[unsafe(method(setWithArray:))]
294 #[unsafe(method_family = none)]
295 pub fn setWithArray(array: &NSArray<ObjectType>) -> Retained<Self>;
296
297 #[unsafe(method(initWithSet:))]
298 #[unsafe(method_family = init)]
299 pub fn initWithSet(this: Allocated<Self>, set: &NSSet<ObjectType>) -> Retained<Self>;
300
301 #[unsafe(method(initWithSet:copyItems:))]
302 #[unsafe(method_family = init)]
303 pub unsafe fn initWithSet_copyItems(
304 this: Allocated<Self>,
305 set: &NSSet<ObjectType>,
306 flag: bool,
307 ) -> Retained<Self>;
308
309 #[cfg(feature = "NSArray")]
310 #[unsafe(method(initWithArray:))]
311 #[unsafe(method_family = init)]
312 pub fn initWithArray(this: Allocated<Self>, array: &NSArray<ObjectType>) -> Retained<Self>;
313 );
314}
315
316impl<ObjectType: Message> NSMutableSet<ObjectType> {
320 extern_methods!(
321 #[unsafe(method(set))]
322 #[unsafe(method_family = none)]
323 pub fn set() -> Retained<Self>;
324
325 #[unsafe(method(setWithObject:))]
326 #[unsafe(method_family = none)]
327 pub fn setWithObject(object: &ObjectType) -> Retained<Self>;
328
329 #[unsafe(method(setWithObjects:count:))]
333 #[unsafe(method_family = none)]
334 pub unsafe fn setWithObjects_count(
335 objects: NonNull<NonNull<ObjectType>>,
336 cnt: NSUInteger,
337 ) -> Retained<Self>;
338
339 #[unsafe(method(setWithSet:))]
340 #[unsafe(method_family = none)]
341 pub fn setWithSet(set: &NSSet<ObjectType>) -> Retained<Self>;
342
343 #[cfg(feature = "NSArray")]
344 #[unsafe(method(setWithArray:))]
345 #[unsafe(method_family = none)]
346 pub fn setWithArray(array: &NSArray<ObjectType>) -> Retained<Self>;
347
348 #[unsafe(method(initWithSet:))]
349 #[unsafe(method_family = init)]
350 pub fn initWithSet(this: Allocated<Self>, set: &NSSet<ObjectType>) -> Retained<Self>;
351
352 #[unsafe(method(initWithSet:copyItems:))]
353 #[unsafe(method_family = init)]
354 pub unsafe fn initWithSet_copyItems(
355 this: Allocated<Self>,
356 set: &NSSet<ObjectType>,
357 flag: bool,
358 ) -> Retained<Self>;
359
360 #[cfg(feature = "NSArray")]
361 #[unsafe(method(initWithArray:))]
362 #[unsafe(method_family = init)]
363 pub fn initWithArray(this: Allocated<Self>, array: &NSArray<ObjectType>) -> Retained<Self>;
364 );
365}
366
367extern_class!(
368 #[unsafe(super(NSSet<ObjectType>, NSObject))]
372 #[derive(PartialEq, Eq, Hash)]
373 pub struct NSMutableSet<ObjectType: ?Sized = AnyObject>;
374);
375
376#[cfg(feature = "objc2-core-foundation")]
377impl<ObjectType: ?Sized + Message> AsRef<NSMutableSet<ObjectType>> for CFMutableSet<ObjectType> {
378 #[inline]
379 fn as_ref(&self) -> &NSMutableSet<ObjectType> {
380 unsafe { &*((self as *const Self).cast()) }
381 }
382}
383
384#[cfg(feature = "objc2-core-foundation")]
385impl<ObjectType: ?Sized + Message> AsRef<CFMutableSet<ObjectType>> for NSMutableSet<ObjectType> {
386 #[inline]
387 fn as_ref(&self) -> &CFMutableSet<ObjectType> {
388 unsafe { &*((self as *const Self).cast()) }
389 }
390}
391
392impl<ObjectType: ?Sized + Message> NSMutableSet<ObjectType> {
393 #[inline]
399 pub unsafe fn cast_unchecked<NewObjectType: ?Sized + Message>(
400 &self,
401 ) -> &NSMutableSet<NewObjectType> {
402 unsafe { &*((self as *const Self).cast()) }
403 }
404}
405
406#[cfg(feature = "NSObject")]
407extern_conformance!(
408 unsafe impl<ObjectType: ?Sized + NSCoding> NSCoding for NSMutableSet<ObjectType> {}
409);
410
411#[cfg(feature = "NSObject")]
412extern_conformance!(
413 unsafe impl<ObjectType: ?Sized> NSCopying for NSMutableSet<ObjectType> {}
414);
415
416#[cfg(feature = "NSObject")]
417unsafe impl<ObjectType: ?Sized + Message> CopyingHelper for NSMutableSet<ObjectType> {
418 type Result = NSSet<ObjectType>;
419}
420
421#[cfg(feature = "NSEnumerator")]
422extern_conformance!(
423 unsafe impl<ObjectType: ?Sized> NSFastEnumeration for NSMutableSet<ObjectType> {}
424);
425
426#[cfg(feature = "NSObject")]
427extern_conformance!(
428 unsafe impl<ObjectType: ?Sized> NSMutableCopying for NSMutableSet<ObjectType> {}
429);
430
431#[cfg(feature = "NSObject")]
432unsafe impl<ObjectType: ?Sized + Message> MutableCopyingHelper for NSMutableSet<ObjectType> {
433 type Result = Self;
434}
435
436extern_conformance!(
437 unsafe impl<ObjectType: ?Sized> NSObjectProtocol for NSMutableSet<ObjectType> {}
438);
439
440#[cfg(feature = "NSObject")]
441extern_conformance!(
442 unsafe impl<ObjectType: ?Sized + NSSecureCoding> NSSecureCoding for NSMutableSet<ObjectType> {}
443);
444
445impl<ObjectType: Message> NSMutableSet<ObjectType> {
446 extern_methods!(
447 #[unsafe(method(addObject:))]
448 #[unsafe(method_family = none)]
449 pub fn addObject(&self, object: &ObjectType);
450
451 #[unsafe(method(removeObject:))]
452 #[unsafe(method_family = none)]
453 pub fn removeObject(&self, object: &ObjectType);
454
455 #[cfg(feature = "NSCoder")]
456 #[unsafe(method(initWithCoder:))]
460 #[unsafe(method_family = init)]
461 pub unsafe fn initWithCoder(
462 this: Allocated<Self>,
463 coder: &NSCoder,
464 ) -> Option<Retained<Self>>;
465
466 #[unsafe(method(init))]
467 #[unsafe(method_family = init)]
468 pub fn init(this: Allocated<Self>) -> Retained<Self>;
469
470 #[unsafe(method(initWithCapacity:))]
471 #[unsafe(method_family = init)]
472 pub fn initWithCapacity(this: Allocated<Self>, num_items: NSUInteger) -> Retained<Self>;
473 );
474}
475
476impl<ObjectType: Message> NSMutableSet<ObjectType> {
478 extern_methods!(
479 #[unsafe(method(initWithObjects:count:))]
483 #[unsafe(method_family = init)]
484 pub unsafe fn initWithObjects_count(
485 this: Allocated<Self>,
486 objects: *mut NonNull<ObjectType>,
487 cnt: NSUInteger,
488 ) -> Retained<Self>;
489 );
490}
491
492impl<ObjectType: Message> NSMutableSet<ObjectType> {
494 extern_methods!(
495 #[unsafe(method(new))]
496 #[unsafe(method_family = new)]
497 pub fn new() -> Retained<Self>;
498 );
499}
500
501impl<ObjectType: Message> DefaultRetained for NSMutableSet<ObjectType> {
502 #[inline]
503 fn default_retained() -> Retained<Self> {
504 Self::new()
505 }
506}
507
508impl<ObjectType: Message> NSMutableSet<ObjectType> {
510 extern_methods!(
511 #[cfg(feature = "NSArray")]
512 #[unsafe(method(addObjectsFromArray:))]
513 #[unsafe(method_family = none)]
514 pub fn addObjectsFromArray(&self, array: &NSArray<ObjectType>);
515
516 #[unsafe(method(intersectSet:))]
517 #[unsafe(method_family = none)]
518 pub fn intersectSet(&self, other_set: &NSSet<ObjectType>);
519
520 #[unsafe(method(minusSet:))]
521 #[unsafe(method_family = none)]
522 pub fn minusSet(&self, other_set: &NSSet<ObjectType>);
523
524 #[unsafe(method(removeAllObjects))]
525 #[unsafe(method_family = none)]
526 pub fn removeAllObjects(&self);
527
528 #[unsafe(method(unionSet:))]
529 #[unsafe(method_family = none)]
530 pub fn unionSet(&self, other_set: &NSSet<ObjectType>);
531
532 #[unsafe(method(setSet:))]
533 #[unsafe(method_family = none)]
534 pub fn setSet(&self, other_set: &NSSet<ObjectType>);
535 );
536}
537
538impl<ObjectType: Message> NSMutableSet<ObjectType> {
540 extern_methods!(
541 #[unsafe(method(setWithCapacity:))]
542 #[unsafe(method_family = none)]
543 pub fn setWithCapacity(num_items: NSUInteger) -> Retained<Self>;
544 );
545}
546
547extern_class!(
548 #[unsafe(super(NSMutableSet<ObjectType>, NSSet<ObjectType>, NSObject))]
552 #[derive(PartialEq, Eq, Hash)]
553 pub struct NSCountedSet<ObjectType: ?Sized = AnyObject>;
554);
555
556impl<ObjectType: ?Sized + Message> NSCountedSet<ObjectType> {
557 #[inline]
563 pub unsafe fn cast_unchecked<NewObjectType: ?Sized + Message>(
564 &self,
565 ) -> &NSCountedSet<NewObjectType> {
566 unsafe { &*((self as *const Self).cast()) }
567 }
568}
569
570#[cfg(feature = "NSObject")]
571extern_conformance!(
572 unsafe impl<ObjectType: ?Sized + NSCoding> NSCoding for NSCountedSet<ObjectType> {}
573);
574
575#[cfg(feature = "NSEnumerator")]
576extern_conformance!(
577 unsafe impl<ObjectType: ?Sized> NSFastEnumeration for NSCountedSet<ObjectType> {}
578);
579
580extern_conformance!(
581 unsafe impl<ObjectType: ?Sized> NSObjectProtocol for NSCountedSet<ObjectType> {}
582);
583
584#[cfg(feature = "NSObject")]
585extern_conformance!(
586 unsafe impl<ObjectType: ?Sized + NSSecureCoding> NSSecureCoding for NSCountedSet<ObjectType> {}
587);
588
589impl<ObjectType: Message> NSCountedSet<ObjectType> {
590 extern_methods!(
591 #[unsafe(method(initWithCapacity:))]
592 #[unsafe(method_family = init)]
593 pub fn initWithCapacity(this: Allocated<Self>, num_items: NSUInteger) -> Retained<Self>;
594
595 #[cfg(feature = "NSArray")]
596 #[unsafe(method(initWithArray:))]
597 #[unsafe(method_family = init)]
598 pub fn initWithArray(this: Allocated<Self>, array: &NSArray<ObjectType>) -> Retained<Self>;
599
600 #[unsafe(method(initWithSet:))]
601 #[unsafe(method_family = init)]
602 pub fn initWithSet(this: Allocated<Self>, set: &NSSet<ObjectType>) -> Retained<Self>;
603
604 #[unsafe(method(countForObject:))]
605 #[unsafe(method_family = none)]
606 pub fn countForObject(&self, object: &ObjectType) -> NSUInteger;
607
608 #[cfg(feature = "NSEnumerator")]
609 #[unsafe(method(objectEnumerator))]
613 #[unsafe(method_family = none)]
614 pub unsafe fn objectEnumerator(&self) -> Retained<NSEnumerator<ObjectType>>;
615
616 #[unsafe(method(addObject:))]
617 #[unsafe(method_family = none)]
618 pub fn addObject(&self, object: &ObjectType);
619
620 #[unsafe(method(removeObject:))]
621 #[unsafe(method_family = none)]
622 pub fn removeObject(&self, object: &ObjectType);
623 );
624}
625
626impl<ObjectType: Message> NSCountedSet<ObjectType> {
628 extern_methods!(
629 #[cfg(feature = "NSCoder")]
630 #[unsafe(method(initWithCoder:))]
634 #[unsafe(method_family = init)]
635 pub unsafe fn initWithCoder(
636 this: Allocated<Self>,
637 coder: &NSCoder,
638 ) -> Option<Retained<Self>>;
639
640 #[unsafe(method(init))]
641 #[unsafe(method_family = init)]
642 pub fn init(this: Allocated<Self>) -> Retained<Self>;
643 );
644}
645
646impl<ObjectType: Message> NSCountedSet<ObjectType> {
648 extern_methods!(
649 #[unsafe(method(initWithObjects:count:))]
653 #[unsafe(method_family = init)]
654 pub unsafe fn initWithObjects_count(
655 this: Allocated<Self>,
656 objects: *mut NonNull<ObjectType>,
657 cnt: NSUInteger,
658 ) -> Retained<Self>;
659 );
660}
661
662impl<ObjectType: Message> NSCountedSet<ObjectType> {
664 extern_methods!(
665 #[unsafe(method(new))]
666 #[unsafe(method_family = new)]
667 pub fn new() -> Retained<Self>;
668 );
669}
670
671impl<ObjectType: Message> DefaultRetained for NSCountedSet<ObjectType> {
672 #[inline]
673 fn default_retained() -> Retained<Self> {
674 Self::new()
675 }
676}