asn1_rs/asn1_types/set/iterator.rs
1pub use crate::{Error, SequenceIterator};
2
3/// An Iterator over binary data, parsing elements of type `T`
4///
5/// This helps parsing `SET OF` items of type `T`. The type of parser
6/// (BER/DER) is specified using the generic parameter `F` of this struct.
7///
8/// Note: the iterator must start on the set *contents*, not the set itself.
9///
10/// # Examples
11///
12/// ```rust
13/// use asn1_rs::{DerParser, Integer, SetIterator};
14///
15/// let data = &[0x30, 0x6, 0x2, 0x1, 0x1, 0x2, 0x1, 0x2];
16/// for (idx, item) in SetIterator::<Integer, DerParser>::new(&data[2..]).enumerate() {
17/// let item = item.unwrap(); // parsing could have failed
18/// let i = item.as_u32().unwrap(); // integer can be negative, or too large to fit into u32
19/// assert_eq!(i as usize, idx + 1);
20/// }
21/// ```
22pub type SetIterator<'a, T, F, E = Error> = SequenceIterator<'a, T, F, E>;