diff options
author | Neal H. Walfield <neal@pep.foundation> | 2020-04-03 10:45:05 +0200 |
---|---|---|
committer | Neal H. Walfield <neal@pep.foundation> | 2020-04-03 11:34:01 +0200 |
commit | 8ebaf6e4ada1cea0b9e6f6dfee61c22cfdc9748c (patch) | |
tree | c93d8620f2326a642bd7428f69ab53f063f64a62 /openpgp | |
parent | c4fe56a578de532fdcd7ecadb4cf064b061e37e6 (diff) |
openpgp: Rename ComponentIter to ComponentBundleIter
- Rename `ComponentIter` to `ComponentBundleIter`, which is more
accurate.
- Rename the module from `cert/component_iter.rs` to
`cert/bundle/iter.rs`.
Diffstat (limited to 'openpgp')
-rw-r--r-- | openpgp/src/cert/amalgamation.rs | 2 | ||||
-rw-r--r-- | openpgp/src/cert/bundle.rs | 8 | ||||
-rw-r--r-- | openpgp/src/cert/bundle/iter.rs (renamed from openpgp/src/cert/component_iter.rs) | 44 | ||||
-rw-r--r-- | openpgp/src/cert/mod.rs | 21 | ||||
-rw-r--r-- | openpgp/src/cert/prelude.rs | 4 |
5 files changed, 41 insertions, 38 deletions
diff --git a/openpgp/src/cert/amalgamation.rs b/openpgp/src/cert/amalgamation.rs index 79b49dcc..9c4a992d 100644 --- a/openpgp/src/cert/amalgamation.rs +++ b/openpgp/src/cert/amalgamation.rs @@ -566,7 +566,7 @@ impl<'a, C> ValidComponentAmalgamation<'a, C> /// Returns the amalgamated primary component at time `time` /// /// If `time` is None, then the current time is used. - /// `ValidComponentIter` for the definition of a valid component. + /// `ValidComponentBundleIter` for the definition of a valid component. /// /// The primary component is determined by taking the components that /// are alive at time `t`, and sorting them as follows: diff --git a/openpgp/src/cert/bundle.rs b/openpgp/src/cert/bundle.rs index 2912f01d..7a78ae2b 100644 --- a/openpgp/src/cert/bundle.rs +++ b/openpgp/src/cert/bundle.rs @@ -24,9 +24,13 @@ use super::{ canonical_signature_order, }; +mod iter; +pub use iter::{ + ComponentBundleIter, + ValidComponentBundleIter, +}; + pub use super::{ - component_iter::ComponentIter, - component_iter::ValidComponentIter, keyiter::KeyIter, keyiter::ValidKeyIter, }; diff --git a/openpgp/src/cert/component_iter.rs b/openpgp/src/cert/bundle/iter.rs index b71aa2ed..c40c2de9 100644 --- a/openpgp/src/cert/component_iter.rs +++ b/openpgp/src/cert/bundle/iter.rs @@ -10,24 +10,24 @@ use crate::{ /// An iterator over all component bundles of a given type in a certificate. /// -/// `ComponentIter` follows the builder pattern. There is no need to +/// `ComponentBundleIter` follows the builder pattern. There is no need to /// explicitly finalize it, however: it already implements the /// `Iterator` trait. /// -/// By default, `ComponentIter` returns each component in turn. -pub struct ComponentIter<'a, C> { +/// By default, `ComponentBundleIter` returns each component in turn. +pub struct ComponentBundleIter<'a, C> { cert: &'a Cert, iter: slice::Iter<'a, ComponentBundle<C>>, } -impl<'a, C> fmt::Debug for ComponentIter<'a, C> { +impl<'a, C> fmt::Debug for ComponentBundleIter<'a, C> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("ComponentIter") + f.debug_struct("ComponentBundleIter") .finish() } } -impl<'a, C> Iterator for ComponentIter<'a, C> +impl<'a, C> Iterator for ComponentBundleIter<'a, C> { type Item = ComponentAmalgamation<'a, C>; @@ -36,13 +36,13 @@ impl<'a, C> Iterator for ComponentIter<'a, C> } } -impl<'a, C> ComponentIter<'a, C> { - /// Returns a new `ComponentIter` instance. +impl<'a, C> ComponentBundleIter<'a, C> { + /// Returns a new `ComponentBundleIter` instance. pub(crate) fn new(cert: &'a Cert, iter: std::slice::Iter<'a, ComponentBundle<C>>) -> Self where Self: 'a { - ComponentIter { + ComponentBundleIter { cert, iter, } } @@ -52,12 +52,12 @@ impl<'a, C> ComponentIter<'a, C> { /// /// If `time` is None, then the current time is used. /// - /// See `ValidComponentIter` for the definition of a valid component. + /// See `ValidComponentBundleIter` for the definition of a valid component. pub fn with_policy<T>(self, policy: &'a dyn Policy, time: T) - -> ValidComponentIter<'a, C> + -> ValidComponentBundleIter<'a, C> where T: Into<Option<SystemTime>> { - ValidComponentIter { + ValidComponentBundleIter { cert: self.cert, iter: self.iter, time: time.into().unwrap_or_else(SystemTime::now), @@ -73,11 +73,11 @@ impl<'a, C> ComponentIter<'a, C> { /// A component is valid at time `t` if it was not created after `t` /// and it has a live self-signature at time `t`. /// -/// `ValidComponentIter` follows the builder pattern. There is no +/// `ValidComponentBundleIter` follows the builder pattern. There is no /// need to explicitly finalize it, however: it already implements the /// `Iterator` trait. -pub struct ValidComponentIter<'a, C> { - // This is an option to make it easier to create an empty ValidComponentIter. +pub struct ValidComponentBundleIter<'a, C> { + // This is an option to make it easier to create an empty ValidComponentBundleIter. cert: &'a Cert, iter: slice::Iter<'a, ComponentBundle<C>>, @@ -90,23 +90,23 @@ pub struct ValidComponentIter<'a, C> { revoked: Option<bool>, } -impl<'a, C> fmt::Debug for ValidComponentIter<'a, C> { +impl<'a, C> fmt::Debug for ValidComponentBundleIter<'a, C> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("ValidComponentIter") + f.debug_struct("ValidComponentBundleIter") .field("time", &self.time) .field("revoked", &self.revoked) .finish() } } -impl<'a, C> Iterator for ValidComponentIter<'a, C> +impl<'a, C> Iterator for ValidComponentBundleIter<'a, C> where C: std::fmt::Debug { type Item = ValidComponentAmalgamation<'a, C>; fn next(&mut self) -> Option<Self::Item> { - tracer!(false, "ValidComponentIter::next", 0); - t!("ValidComponentIter: {:?}", self); + tracer!(false, "ValidComponentBundleIter::next", 0); + t!("ValidComponentBundleIter: {:?}", self); loop { let ca = ComponentAmalgamation::new(self.cert, self.iter.next()?); @@ -141,14 +141,14 @@ impl<'a, C> Iterator for ValidComponentIter<'a, C> } } -impl<'a, C> ExactSizeIterator for ComponentIter<'a, C> +impl<'a, C> ExactSizeIterator for ComponentBundleIter<'a, C> { fn len(&self) -> usize { self.iter.len() } } -impl<'a, C> ValidComponentIter<'a, C> { +impl<'a, C> ValidComponentBundleIter<'a, C> { /// Filters by whether a component is definitely revoked. /// /// A value of None disables this filter. diff --git a/openpgp/src/cert/mod.rs b/openpgp/src/cert/mod.rs index 41710f32..f1a5519f 100644 --- a/openpgp/src/cert/mod.rs +++ b/openpgp/src/cert/mod.rs @@ -46,7 +46,6 @@ pub mod amalgamation; mod builder; mod bindings; pub mod bundle; -mod component_iter; mod keyiter; pub mod key_amalgamation; mod parser; @@ -641,8 +640,8 @@ impl Cert { } /// Returns an iterator over the Cert's userids. - pub fn userids(&self) -> ComponentIter<UserID> { - ComponentIter::new(self, self.userids.iter()) + pub fn userids(&self) -> ComponentBundleIter<UserID> { + ComponentBundleIter::new(self, self.userids.iter()) } /// Returns the amalgamated primary user attribute at `t`, if any. @@ -656,20 +655,20 @@ impl Cert { } /// Returns an iterator over the Cert's `UserAttributeBundle`s. - pub fn user_attributes(&self) -> ComponentIter<UserAttribute> { - ComponentIter::new(self, self.user_attributes.iter()) + pub fn user_attributes(&self) -> ComponentBundleIter<UserAttribute> { + ComponentBundleIter::new(self, self.user_attributes.iter()) } /// Returns an iterator over the Cert's subkeys. - pub(crate) fn subkeys(&self) -> ComponentIter<Key<key::PublicParts, + pub(crate) fn subkeys(&self) -> ComponentBundleIter<Key<key::PublicParts, key::SubordinateRole>> { - ComponentIter::new(self, self.subkeys.iter()) + ComponentBundleIter::new(self, self.subkeys.iter()) } /// Returns an iterator over the Cert's unknown components. - pub fn unknowns(&self) -> ComponentIter<Unknown> { - ComponentIter::new(self, self.unknowns.iter()) + pub fn unknowns(&self) -> ComponentBundleIter<Unknown> { + ComponentBundleIter::new(self, self.unknowns.iter()) } /// Returns a slice containing all bad signatures. @@ -1478,7 +1477,7 @@ impl<'a> ValidCert<'a> { } /// Returns an iterator over the Cert's userids. - pub fn userids(&self) -> ValidComponentIter<UserID> { + pub fn userids(&self) -> ValidComponentBundleIter<UserID> { self.cert.userids().with_policy(self.policy, self.time) } @@ -1490,7 +1489,7 @@ impl<'a> ValidCert<'a> { } /// Returns an iterator over the Cert's `UserAttributeBundle`s. - pub fn user_attributes(&self) -> ValidComponentIter<UserAttribute> { + pub fn user_attributes(&self) -> ValidComponentBundleIter<UserAttribute> { self.cert.user_attributes().with_policy(self.policy, self.time) } } diff --git a/openpgp/src/cert/prelude.rs b/openpgp/src/cert/prelude.rs index 43738290..32eabf80 100644 --- a/openpgp/src/cert/prelude.rs +++ b/openpgp/src/cert/prelude.rs @@ -33,7 +33,7 @@ pub use crate::cert::{ amalgamation::ValidComponentAmalgamation, amalgamation::ValidateAmalgamation as _, bundle::ComponentBundle, - bundle::ComponentIter, + bundle::ComponentBundleIter, bundle::KeyBundle, bundle::KeyIter, bundle::PrimaryKeyBundle, @@ -41,7 +41,7 @@ pub use crate::cert::{ bundle::UnknownBundle, bundle::UserAttributeBundle, bundle::UserIDBundle, - bundle::ValidComponentIter, + bundle::ValidComponentBundleIter, bundle::ValidKeyIter, key_amalgamation::ErasedKeyAmalgamation, key_amalgamation::KeyAmalgamation, |