objc2_foundation/generated/
NSEnumerator.rs1use core::ptr::NonNull;
4use objc2::__framework_prelude::*;
5
6use crate::*;
7
8extern_protocol!(
9 pub unsafe trait NSFastEnumeration {
11 #[unsafe(method(countByEnumeratingWithState:objects:count:))]
16 #[unsafe(method_family = none)]
17 unsafe fn countByEnumeratingWithState_objects_count(
18 &self,
19 state: NonNull<NSFastEnumerationState>,
20 buffer: NonNull<*mut AnyObject>,
21 len: NSUInteger,
22 ) -> NSUInteger;
23 }
24);
25
26extern_class!(
27 #[unsafe(super(NSObject))]
29 #[derive(Debug, PartialEq, Eq, Hash)]
30 pub struct NSEnumerator<ObjectType: ?Sized = AnyObject>;
31);
32
33impl<ObjectType: ?Sized + Message> NSEnumerator<ObjectType> {
34 #[inline]
40 pub unsafe fn cast_unchecked<NewObjectType: ?Sized + Message>(
41 &self,
42 ) -> &NSEnumerator<NewObjectType> {
43 unsafe { &*((self as *const Self).cast()) }
44 }
45}
46
47extern_conformance!(
48 unsafe impl<ObjectType: ?Sized> NSFastEnumeration for NSEnumerator<ObjectType> {}
49);
50
51extern_conformance!(
52 unsafe impl<ObjectType: ?Sized> NSObjectProtocol for NSEnumerator<ObjectType> {}
53);
54
55impl<ObjectType: Message> NSEnumerator<ObjectType> {
56 extern_methods!(
57 #[unsafe(method(nextObject))]
58 #[unsafe(method_family = none)]
59 pub fn nextObject(&self) -> Option<Retained<ObjectType>>;
60 );
61}
62
63impl<ObjectType: Message> NSEnumerator<ObjectType> {
65 extern_methods!(
66 #[unsafe(method(init))]
67 #[unsafe(method_family = init)]
68 pub fn init(this: Allocated<Self>) -> Retained<Self>;
69
70 #[unsafe(method(new))]
71 #[unsafe(method_family = new)]
72 pub fn new() -> Retained<Self>;
73 );
74}
75
76impl<ObjectType: Message> DefaultRetained for NSEnumerator<ObjectType> {
77 #[inline]
78 fn default_retained() -> Retained<Self> {
79 Self::new()
80 }
81}
82
83impl<ObjectType: Message> NSEnumerator<ObjectType> {
85 extern_methods!(
86 #[cfg(feature = "NSArray")]
87 #[unsafe(method(allObjects))]
88 #[unsafe(method_family = none)]
89 pub fn allObjects(&self) -> Retained<NSArray<ObjectType>>;
90 );
91}