objc2_foundation/generated/
NSEnumerator.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ptr::NonNull;
4use objc2::__framework_prelude::*;
5
6use crate::*;
7
8extern_protocol!(
9    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsfastenumeration?language=objc)
10    pub unsafe trait NSFastEnumeration {
11        /// # Safety
12        ///
13        /// - `state` must be a valid pointer.
14        /// - `buffer` must be a valid pointer.
15        #[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    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsenumerator?language=objc)
28    #[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    /// Unchecked conversion of the generic parameter.
35    ///
36    /// # Safety
37    ///
38    /// The generic must be valid to reinterpret as the given type.
39    #[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
63/// Methods declared on superclass `NSObject`.
64impl<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
83/// NSExtendedEnumerator.
84impl<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}