1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
use crate::decl::*;
use crate::prelude::*;

pub(in crate::oleaut) struct IpropertystoreIter<'a, I>
	where I: oleaut_IPropertyStore,
{
	prop_st: &'a I,
	count: u32,
	current: u32,
}

impl<'a, I> Iterator for IpropertystoreIter<'a, I>
	where I: oleaut_IPropertyStore,
{
	type Item = HrResult<PROPERTYKEY>;

	fn next(&mut self) -> Option<Self::Item> {
		if self.current == self.count {
			return None;
		}

		match self.prop_st.GetAt(self.current) {
			Err(e) => {
				self.current = self.count; // no further iterations will be made
				Some(Err(e))
			},
			Ok(ppk) => {
				self.current += 1;
				Some(Ok(ppk))
			},
		}
	}
}

impl<'a, I> IpropertystoreIter<'a, I>
	where I: oleaut_IPropertyStore,
{
	#[must_use]
	pub(in crate::oleaut) fn new(prop_st: &'a I) -> HrResult<Self> {
		let count = prop_st.GetCount()?;
		Ok(Self { prop_st, count, current: 0 })
	}
}