rust_macios/foundation/
ns_enumerator.rs1use std::marker::PhantomData;
2
3use objc::{msg_send, sel, sel_impl};
4
5use crate::{
6 object,
7 objective_c_runtime::traits::{FromId, PNSObject},
8};
9
10use super::NSArray;
11
12object! {
13 unsafe pub struct NSEnumerator<ObjectType> {
15 marker: PhantomData<ObjectType>,
16 }
17}
18
19pub trait INSEnumerator<ObjectType>: PNSObject
21where
22 ObjectType: PNSObject + FromId,
23{
24 fn m_next_object(&self) -> ObjectType {
26 unsafe { ObjectType::from_id(msg_send![self.m_self(), nextObject]) }
27 }
28
29 fn m_all_objects(&self) -> NSArray<ObjectType> {
31 unsafe { NSArray::from_id(msg_send![self.m_self(), allObjects]) }
32 }
33}
34
35impl<ObjectType> INSEnumerator<ObjectType> for NSEnumerator<ObjectType> where
36 ObjectType: PNSObject + FromId
37{
38}