summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeal H. Walfield <neal@pep.foundation>2020-04-03 21:50:10 +0200
committerNeal H. Walfield <neal@pep.foundation>2020-04-03 21:50:10 +0200
commit488985f8f2e119c553f2d03d8bd87d49f45d8227 (patch)
treecdccc226c38ed65f78a08a73ea5943665d54392f
parent6dfc495afcbb1e376eee7ac62f5e13e9299bc44e (diff)
openpgp: Rename ComponentBundleIter to ComponentAmalgamationIter.
- Rename `ComponentBundleIter` to `ComponentAmalgamationIter` and `ValidComponentBundleIter` to `ValidComponentAmalgamationIter`. - Move module from cert::bundle to cert::amalgamation. - Fixes 8ebaf6e4ada1cea0b9e6f6dfee61c22cfdc9748c.
-rw-r--r--openpgp-ffi/src/cert.rs4
-rw-r--r--openpgp/src/cert/amalgamation.rs10
-rw-r--r--openpgp/src/cert/amalgamation/iter.rs (renamed from openpgp/src/cert/bundle/iter.rs)44
-rw-r--r--openpgp/src/cert/bundle.rs6
-rw-r--r--openpgp/src/cert/mod.rs20
-rw-r--r--openpgp/src/cert/prelude.rs4
6 files changed, 45 insertions, 43 deletions
diff --git a/openpgp-ffi/src/cert.rs b/openpgp-ffi/src/cert.rs
index 2d57677f..9516ad75 100644
--- a/openpgp-ffi/src/cert.rs
+++ b/openpgp-ffi/src/cert.rs
@@ -378,7 +378,7 @@ fn pgp_cert_primary_user_id(cert: *const Cert, policy: *const Policy,
/// Wraps a UserIDIter for export via the FFI.
pub struct UserIDIterWrapper<'a> {
pub(crate) // For serialize.rs.
- iter: Option<ComponentBundleIter<'a, openpgp::packet::UserID>>,
+ iter: Option<ComponentAmalgamationIter<'a, openpgp::packet::UserID>>,
// Whether next has been called.
next_called: bool,
}
@@ -450,7 +450,7 @@ pub extern "C" fn pgp_cert_user_id_iter_next<'a>(
/// Wraps a ValidKeyAmalgamationIter for export via the FFI.
pub struct ValidUserIDIterWrapper<'a> {
pub(crate) // For serialize.rs.
- iter: Option<ValidComponentBundleIter<'a, openpgp::packet::UserID>>,
+ iter: Option<ValidComponentAmalgamationIter<'a, openpgp::packet::UserID>>,
// Whether next has been called.
next_called: bool,
}
diff --git a/openpgp/src/cert/amalgamation.rs b/openpgp/src/cert/amalgamation.rs
index 0ba7a808..8f5c46e9 100644
--- a/openpgp/src/cert/amalgamation.rs
+++ b/openpgp/src/cert/amalgamation.rs
@@ -35,11 +35,19 @@ use crate::{
},
};
+
+mod iter;
+pub use iter::{
+ ComponentAmalgamationIter,
+ ValidComponentAmalgamationIter,
+};
+
mod keyiter;
pub use keyiter::{
KeyAmalgamationIter,
ValidKeyAmalgamationIter,
};
+
mod key;
pub use key::{
ErasedKeyAmalgamation,
@@ -584,7 +592,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.
- /// `ValidComponentBundleIter` for the definition of a valid component.
+ /// `ValidComponentAmalgamationIter` 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/iter.rs b/openpgp/src/cert/amalgamation/iter.rs
index c40c2de9..34eca638 100644
--- a/openpgp/src/cert/bundle/iter.rs
+++ b/openpgp/src/cert/amalgamation/iter.rs
@@ -10,24 +10,24 @@ use crate::{
/// An iterator over all component bundles of a given type in a certificate.
///
-/// `ComponentBundleIter` follows the builder pattern. There is no need to
+/// `ComponentAmalgamationIter` follows the builder pattern. There is no need to
/// explicitly finalize it, however: it already implements the
/// `Iterator` trait.
///
-/// By default, `ComponentBundleIter` returns each component in turn.
-pub struct ComponentBundleIter<'a, C> {
+/// By default, `ComponentAmalgamationIter` returns each component in turn.
+pub struct ComponentAmalgamationIter<'a, C> {
cert: &'a Cert,
iter: slice::Iter<'a, ComponentBundle<C>>,
}
-impl<'a, C> fmt::Debug for ComponentBundleIter<'a, C> {
+impl<'a, C> fmt::Debug for ComponentAmalgamationIter<'a, C> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- f.debug_struct("ComponentBundleIter")
+ f.debug_struct("ComponentAmalgamationIter")
.finish()
}
}
-impl<'a, C> Iterator for ComponentBundleIter<'a, C>
+impl<'a, C> Iterator for ComponentAmalgamationIter<'a, C>
{
type Item = ComponentAmalgamation<'a, C>;
@@ -36,13 +36,13 @@ impl<'a, C> Iterator for ComponentBundleIter<'a, C>
}
}
-impl<'a, C> ComponentBundleIter<'a, C> {
- /// Returns a new `ComponentBundleIter` instance.
+impl<'a, C> ComponentAmalgamationIter<'a, C> {
+ /// Returns a new `ComponentAmalgamationIter` instance.
pub(crate) fn new(cert: &'a Cert,
iter: std::slice::Iter<'a, ComponentBundle<C>>) -> Self
where Self: 'a
{
- ComponentBundleIter {
+ ComponentAmalgamationIter {
cert, iter,
}
}
@@ -52,12 +52,12 @@ impl<'a, C> ComponentBundleIter<'a, C> {
///
/// If `time` is None, then the current time is used.
///
- /// See `ValidComponentBundleIter` for the definition of a valid component.
+ /// See `ValidComponentAmalgamationIter` for the definition of a valid component.
pub fn with_policy<T>(self, policy: &'a dyn Policy, time: T)
- -> ValidComponentBundleIter<'a, C>
+ -> ValidComponentAmalgamationIter<'a, C>
where T: Into<Option<SystemTime>>
{
- ValidComponentBundleIter {
+ ValidComponentAmalgamationIter {
cert: self.cert,
iter: self.iter,
time: time.into().unwrap_or_else(SystemTime::now),
@@ -73,11 +73,11 @@ impl<'a, C> ComponentBundleIter<'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`.
///
-/// `ValidComponentBundleIter` follows the builder pattern. There is no
+/// `ValidComponentAmalgamationIter` follows the builder pattern. There is no
/// need to explicitly finalize it, however: it already implements the
/// `Iterator` trait.
-pub struct ValidComponentBundleIter<'a, C> {
- // This is an option to make it easier to create an empty ValidComponentBundleIter.
+pub struct ValidComponentAmalgamationIter<'a, C> {
+ // This is an option to make it easier to create an empty ValidComponentAmalgamationIter.
cert: &'a Cert,
iter: slice::Iter<'a, ComponentBundle<C>>,
@@ -90,23 +90,23 @@ pub struct ValidComponentBundleIter<'a, C> {
revoked: Option<bool>,
}
-impl<'a, C> fmt::Debug for ValidComponentBundleIter<'a, C> {
+impl<'a, C> fmt::Debug for ValidComponentAmalgamationIter<'a, C> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- f.debug_struct("ValidComponentBundleIter")
+ f.debug_struct("ValidComponentAmalgamationIter")
.field("time", &self.time)
.field("revoked", &self.revoked)
.finish()
}
}
-impl<'a, C> Iterator for ValidComponentBundleIter<'a, C>
+impl<'a, C> Iterator for ValidComponentAmalgamationIter<'a, C>
where C: std::fmt::Debug
{
type Item = ValidComponentAmalgamation<'a, C>;
fn next(&mut self) -> Option<Self::Item> {
- tracer!(false, "ValidComponentBundleIter::next", 0);
- t!("ValidComponentBundleIter: {:?}", self);
+ tracer!(false, "ValidComponentAmalgamationIter::next", 0);
+ t!("ValidComponentAmalgamationIter: {:?}", self);
loop {
let ca = ComponentAmalgamation::new(self.cert, self.iter.next()?);
@@ -141,14 +141,14 @@ impl<'a, C> Iterator for ValidComponentBundleIter<'a, C>
}
}
-impl<'a, C> ExactSizeIterator for ComponentBundleIter<'a, C>
+impl<'a, C> ExactSizeIterator for ComponentAmalgamationIter<'a, C>
{
fn len(&self) -> usize {
self.iter.len()
}
}
-impl<'a, C> ValidComponentBundleIter<'a, C> {
+impl<'a, C> ValidComponentAmalgamationIter<'a, C> {
/// Filters by whether a component is definitely revoked.
///
/// A value of None disables this filter.
diff --git a/openpgp/src/cert/bundle.rs b/openpgp/src/cert/bundle.rs
index 85a36b0e..4bbe9e4f 100644
--- a/openpgp/src/cert/bundle.rs
+++ b/openpgp/src/cert/bundle.rs
@@ -25,12 +25,6 @@ use super::{
canonical_signature_order,
};
-mod iter;
-pub use iter::{
- ComponentBundleIter,
- ValidComponentBundleIter,
-};
-
/// A Cert component binding.
///
/// A Cert component is a primary key, a subkey, a user id, or a user
diff --git a/openpgp/src/cert/mod.rs b/openpgp/src/cert/mod.rs
index 751b4143..3e239e80 100644
--- a/openpgp/src/cert/mod.rs
+++ b/openpgp/src/cert/mod.rs
@@ -640,8 +640,8 @@ impl Cert {
}
/// Returns an iterator over the Cert's userids.
- pub fn userids(&self) -> ComponentBundleIter<UserID> {
- ComponentBundleIter::new(self, self.userids.iter())
+ pub fn userids(&self) -> ComponentAmalgamationIter<UserID> {
+ ComponentAmalgamationIter::new(self, self.userids.iter())
}
/// Returns the amalgamated primary user attribute at `t`, if any.
@@ -655,20 +655,20 @@ impl Cert {
}
/// Returns an iterator over the Cert's `UserAttributeBundle`s.
- pub fn user_attributes(&self) -> ComponentBundleIter<UserAttribute> {
- ComponentBundleIter::new(self, self.user_attributes.iter())
+ pub fn user_attributes(&self) -> ComponentAmalgamationIter<UserAttribute> {
+ ComponentAmalgamationIter::new(self, self.user_attributes.iter())
}
/// Returns an iterator over the Cert's subkeys.
- pub(crate) fn subkeys(&self) -> ComponentBundleIter<Key<key::PublicParts,
+ pub(crate) fn subkeys(&self) -> ComponentAmalgamationIter<Key<key::PublicParts,
key::SubordinateRole>>
{
- ComponentBundleIter::new(self, self.subkeys.iter())
+ ComponentAmalgamationIter::new(self, self.subkeys.iter())
}
/// Returns an iterator over the Cert's unknown components.
- pub fn unknowns(&self) -> ComponentBundleIter<Unknown> {
- ComponentBundleIter::new(self, self.unknowns.iter())
+ pub fn unknowns(&self) -> ComponentAmalgamationIter<Unknown> {
+ ComponentAmalgamationIter::new(self, self.unknowns.iter())
}
/// Returns a slice containing all bad signatures.
@@ -1481,7 +1481,7 @@ impl<'a> ValidCert<'a> {
}
/// Returns an iterator over the Cert's userids.
- pub fn userids(&self) -> ValidComponentBundleIter<UserID> {
+ pub fn userids(&self) -> ValidComponentAmalgamationIter<UserID> {
self.cert.userids().with_policy(self.policy, self.time)
}
@@ -1493,7 +1493,7 @@ impl<'a> ValidCert<'a> {
}
/// Returns an iterator over the Cert's `UserAttributeBundle`s.
- pub fn user_attributes(&self) -> ValidComponentBundleIter<UserAttribute> {
+ pub fn user_attributes(&self) -> ValidComponentAmalgamationIter<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 fdb71436..15e06129 100644
--- a/openpgp/src/cert/prelude.rs
+++ b/openpgp/src/cert/prelude.rs
@@ -29,6 +29,7 @@ pub use crate::cert::{
UserIDRevocationBuilder,
ValidCert,
amalgamation::ComponentAmalgamation,
+ amalgamation::ComponentAmalgamationIter,
amalgamation::ErasedKeyAmalgamation,
amalgamation::KeyAmalgamation,
amalgamation::KeyAmalgamationIter,
@@ -37,6 +38,7 @@ pub use crate::cert::{
amalgamation::SubordinateKeyAmalgamation,
amalgamation::ValidAmalgamation as _,
amalgamation::ValidComponentAmalgamation,
+ amalgamation::ValidComponentAmalgamationIter,
amalgamation::ValidErasedKeyAmalgamation,
amalgamation::ValidKeyAmalgamation,
amalgamation::ValidKeyAmalgamationIter,
@@ -44,12 +46,10 @@ pub use crate::cert::{
amalgamation::ValidSubordinateKeyAmalgamation,
amalgamation::ValidateAmalgamation as _,
bundle::ComponentBundle,
- bundle::ComponentBundleIter,
bundle::KeyBundle,
bundle::PrimaryKeyBundle,
bundle::SubkeyBundle,
bundle::UnknownBundle,
bundle::UserAttributeBundle,
bundle::UserIDBundle,
- bundle::ValidComponentBundleIter,
};