diff options
author | Kai Michaelis <kai@sequoia-pgp.org> | 2018-10-18 13:04:56 +0200 |
---|---|---|
committer | Kai Michaelis <kai@sequoia-pgp.org> | 2018-10-18 13:04:56 +0200 |
commit | 42d73fb201555e3ac67ef443da745af89cd2440c (patch) | |
tree | 2a69fe4083bd813fc924ed9f7569d3072f3714aa /openpgp/src | |
parent | a7d33ab7cc3a752b0fe8e996e49ce3248fd2079a (diff) |
openpgp: implement len() for the TPK iterators.
Diffstat (limited to 'openpgp/src')
-rw-r--r-- | openpgp/src/tpk/mod.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/openpgp/src/tpk/mod.rs b/openpgp/src/tpk/mod.rs index 3e210b80..d45760f4 100644 --- a/openpgp/src/tpk/mod.rs +++ b/openpgp/src/tpk/mod.rs @@ -663,6 +663,10 @@ impl<'a> Iterator for KeyIter<'a> { } } +impl<'a> ExactSizeIterator for KeyIter<'a> { + fn len(&self) -> usize { 1 + self.subkey_iter.len() } +} + // A TPKParser can read packets from either an Iterator or a // PacketParser. Ideally, we would just take an iterator, but we // want to be able to handle errors, which iterators hide. @@ -1093,6 +1097,10 @@ impl<'a> Iterator for UserIDBindingIter<'a> { } } +impl<'a> ExactSizeIterator for UserIDBindingIter<'a> { + fn len(&self) -> usize { self.iter.len() } +} + /// An iterator over `UserAttributeBinding`s. pub struct UserAttributeBindingIter<'a> { iter: slice::Iter<'a, UserAttributeBinding>, @@ -1106,6 +1114,10 @@ impl<'a> Iterator for UserAttributeBindingIter<'a> { } } +impl<'a> ExactSizeIterator for UserAttributeBindingIter<'a> { + fn len(&self) -> usize { self.iter.len() } +} + /// An iterator over `SubkeyBinding`s. pub struct SubkeyBindingIter<'a> { iter: slice::Iter<'a, SubkeyBinding>, @@ -1119,6 +1131,10 @@ impl<'a> Iterator for SubkeyBindingIter<'a> { } } +impl<'a> ExactSizeIterator for SubkeyBindingIter<'a> { + fn len(&self) -> usize { self.iter.len() } +} + impl TPK { /// Returns a reference to the primary key. pub fn primary(&self) -> &Key { |