diff options
author | Neal H. Walfield <neal@pep.foundation> | 2020-04-03 11:15:05 +0200 |
---|---|---|
committer | Neal H. Walfield <neal@pep.foundation> | 2020-04-03 11:34:02 +0200 |
commit | 72bb51dc3ba1d368cad1d833a734d39a32ba3149 (patch) | |
tree | f04f5746b41ce4a92058502d3e2868361f7e1150 /openpgp | |
parent | 8ebaf6e4ada1cea0b9e6f6dfee61c22cfdc9748c (diff) |
openpgp: Rename KeyIter to KeyAmalgamationIter
- Rename `KeyIter` to `KeyAmalgamationIter`, `ValidKeyIter` to
`ValidKeyAmalgamationIter`.
- Rename `cert/keyiter.rs` to `cert/amalgamation/iter.rs`.
Diffstat (limited to 'openpgp')
-rw-r--r-- | openpgp/src/cert/amalgamation.rs | 6 | ||||
-rw-r--r-- | openpgp/src/cert/amalgamation/iter.rs (renamed from openpgp/src/cert/keyiter.rs) | 80 | ||||
-rw-r--r-- | openpgp/src/cert/bundle.rs | 5 | ||||
-rw-r--r-- | openpgp/src/cert/mod.rs | 7 | ||||
-rw-r--r-- | openpgp/src/cert/prelude.rs | 4 |
5 files changed, 51 insertions, 51 deletions
diff --git a/openpgp/src/cert/amalgamation.rs b/openpgp/src/cert/amalgamation.rs index 9c4a992d..06a7bd56 100644 --- a/openpgp/src/cert/amalgamation.rs +++ b/openpgp/src/cert/amalgamation.rs @@ -35,6 +35,12 @@ use crate::{ }, }; +mod iter; +pub use iter::{ + KeyAmalgamationIter, + ValidKeyAmalgamationIter, +}; + /// Applies a policy to an amalgamation. /// /// Note: This trait is split off from the `Amalgamation` trait, to diff --git a/openpgp/src/cert/keyiter.rs b/openpgp/src/cert/amalgamation/iter.rs index 5f44fb99..1f9973dc 100644 --- a/openpgp/src/cert/keyiter.rs +++ b/openpgp/src/cert/amalgamation/iter.rs @@ -19,21 +19,21 @@ use crate::{ /// /// Returned by `Cert::keys()`. /// -/// `KeyIter` follows the builder pattern. There is no need to +/// `KeyAmalgamationIter` follows the builder pattern. There is no need to /// explicitly finalize it, however: it already implements the /// `Iterator` trait. /// -/// By default, `KeyIter` returns all keys. `KeyIter` provides some +/// By default, `KeyAmalgamationIter` returns all keys. `KeyAmalgamationIter` provides some /// filters to control what it returns. For instance, -/// `KeyIter::secret` causes the iterator to only returns keys that -/// include secret key material. Of course, since `KeyIter` +/// `KeyAmalgamationIter::secret` causes the iterator to only returns keys that +/// include secret key material. Of course, since `KeyAmalgamationIter` /// implements `Iterator`, it is possible to use `Iterator::filter` to /// implement custom filters. -pub struct KeyIter<'a, P, R> +pub struct KeyAmalgamationIter<'a, P, R> where P: key::KeyParts, R: key::KeyRole, { - // This is an option to make it easier to create an empty KeyIter. + // This is an option to make it easier to create an empty KeyAmalgamationIter. cert: Option<&'a Cert>, primary: bool, subkey_iter: slice::Iter<'a, KeyBundle<key::PublicParts, @@ -53,12 +53,12 @@ pub struct KeyIter<'a, P, R> _r: std::marker::PhantomData<R>, } -impl<'a, P, R> fmt::Debug for KeyIter<'a, P, R> +impl<'a, P, R> fmt::Debug for KeyAmalgamationIter<'a, P, R> where P: key::KeyParts, R: key::KeyRole, { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("KeyIter") + f.debug_struct("KeyAmalgamationIter") .field("secret", &self.secret) .field("unencrypted_secret", &self.unencrypted_secret) .field("key_handles", &self.key_handles) @@ -68,7 +68,7 @@ impl<'a, P, R> fmt::Debug for KeyIter<'a, P, R> macro_rules! impl_iterator { ($parts:path, $role:path, $item:ty) => { - impl<'a> Iterator for KeyIter<'a, $parts, $role> + impl<'a> Iterator for KeyAmalgamationIter<'a, $parts, $role> { type Item = $item; @@ -103,14 +103,14 @@ impl_iterator!(key::SecretParts, key::UnspecifiedRole, impl_iterator!(key::UnspecifiedParts, key::UnspecifiedRole, ErasedKeyAmalgamation<'a, key::UnspecifiedParts>); -impl<'a, P, R> KeyIter<'a, P, R> +impl<'a, P, R> KeyAmalgamationIter<'a, P, R> where P: key::KeyParts, R: key::KeyRole, { fn next_common(&mut self) -> Option<ErasedKeyAmalgamation<'a, key::PublicParts>> { - tracer!(false, "KeyIter::next", 0); - t!("KeyIter: {:?}", self); + tracer!(false, "KeyAmalgamationIter::next", 0); + t!("KeyAmalgamationIter: {:?}", self); if self.cert.is_none() { return None; @@ -180,13 +180,13 @@ impl<'a, P, R> KeyIter<'a, P, R> } } -impl<'a, P, R> KeyIter<'a, P, R> +impl<'a, P, R> KeyAmalgamationIter<'a, P, R> where P: key::KeyParts, R: key::KeyRole, { - /// Returns a new `KeyIter` instance. + /// Returns a new `KeyAmalgamationIter` instance. pub(crate) fn new(cert: &'a Cert) -> Self where Self: 'a { - KeyIter { + KeyAmalgamationIter { cert: Some(cert), primary: false, subkey_iter: cert.subkeys.iter(), @@ -202,8 +202,8 @@ impl<'a, P, R> KeyIter<'a, P, R> } /// Changes the filter to only return keys with secret key material. - pub fn secret(self) -> KeyIter<'a, key::SecretParts, R> { - KeyIter { + pub fn secret(self) -> KeyAmalgamationIter<'a, key::SecretParts, R> { + KeyAmalgamationIter { cert: self.cert, primary: self.primary, subkey_iter: self.subkey_iter, @@ -220,8 +220,8 @@ impl<'a, P, R> KeyIter<'a, P, R> /// Changes the filter to only return keys with unencrypted secret /// key material. - pub fn unencrypted_secret(self) -> KeyIter<'a, key::SecretParts, R> { - KeyIter { + pub fn unencrypted_secret(self) -> KeyAmalgamationIter<'a, key::SecretParts, R> { + KeyAmalgamationIter { cert: self.cert, primary: self.primary, subkey_iter: self.subkey_iter, @@ -262,8 +262,8 @@ impl<'a, P, R> KeyIter<'a, P, R> } /// Changes the iterator to skip the primary key. - pub fn subkeys(self) -> KeyIter<'a, P, key::SubordinateRole> { - KeyIter { + pub fn subkeys(self) -> KeyAmalgamationIter<'a, P, key::SubordinateRole> { + KeyAmalgamationIter { cert: self.cert, primary: true, subkey_iter: self.subkey_iter, @@ -283,7 +283,7 @@ impl<'a, P, R> KeyIter<'a, P, R> /// /// If `time` is None, then the current time is used. /// - /// See `ValidKeyIter` for the definition of a valid key. + /// See `ValidKeyAmalgamationIter` for the definition of a valid key. /// /// This also makes a number of filters like `alive` and `revoked` /// available and causes the iterator to return a @@ -408,10 +408,10 @@ impl<'a, P, R> KeyIter<'a, P, R> /// [signature expirations]: https://tools.ietf.org/html/rfc4880#section-5.2.3.10 /// [This discussion]: https://crypto.stackexchange.com/a/12138 pub fn with_policy<T>(self, policy: &'a dyn Policy, time: T) - -> ValidKeyIter<'a, P, R> + -> ValidKeyAmalgamationIter<'a, P, R> where T: Into<Option<SystemTime>> { - ValidKeyIter { + ValidKeyAmalgamationIter { cert: self.cert, primary: self.primary, subkey_iter: self.subkey_iter, @@ -441,14 +441,14 @@ impl<'a, P, R> KeyIter<'a, P, R> /// or certificate may be expired, but the self-signature is still /// valid. /// -/// `ValidKeyIter` follows the builder pattern. There is no need to +/// `ValidKeyAmalgamationIter` follows the builder pattern. There is no need to /// explicitly finalize it, however: it already implements the /// `Iterator` trait. -pub struct ValidKeyIter<'a, P, R> +pub struct ValidKeyAmalgamationIter<'a, P, R> where P: key::KeyParts, R: key::KeyRole, { - // This is an option to make it easier to create an empty ValidKeyIter. + // This is an option to make it easier to create an empty ValidKeyAmalgamationIter. cert: Option<&'a Cert>, primary: bool, subkey_iter: slice::Iter<'a, KeyBundle<key::PublicParts, @@ -484,12 +484,12 @@ pub struct ValidKeyIter<'a, P, R> _r: std::marker::PhantomData<R>, } -impl<'a, P, R> fmt::Debug for ValidKeyIter<'a, P, R> +impl<'a, P, R> fmt::Debug for ValidKeyAmalgamationIter<'a, P, R> where P: key::KeyParts, R: key::KeyRole, { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("ValidKeyIter") + f.debug_struct("ValidKeyAmalgamationIter") .field("policy", &self.policy) .field("time", &self.time) .field("secret", &self.secret) @@ -504,7 +504,7 @@ impl<'a, P, R> fmt::Debug for ValidKeyIter<'a, P, R> macro_rules! impl_iterator { ($parts:path, $role:path, $item:ty) => { - impl<'a> Iterator for ValidKeyIter<'a, $parts, $role> + impl<'a> Iterator for ValidKeyAmalgamationIter<'a, $parts, $role> { type Item = $item; @@ -539,15 +539,15 @@ impl_iterator!(key::SecretParts, key::UnspecifiedRole, impl_iterator!(key::UnspecifiedParts, key::UnspecifiedRole, ValidErasedKeyAmalgamation<'a, key::UnspecifiedParts>); -impl<'a, P, R> ValidKeyIter<'a, P, R> +impl<'a, P, R> ValidKeyAmalgamationIter<'a, P, R> where P: key::KeyParts, R: key::KeyRole, { fn next_common(&mut self) -> Option<ValidErasedKeyAmalgamation<'a, key::PublicParts>> { - tracer!(false, "ValidKeyIter::next", 0); - t!("ValidKeyIter: {:?}", self); + tracer!(false, "ValidKeyAmalgamationIter::next", 0); + t!("ValidKeyAmalgamationIter: {:?}", self); if self.cert.is_none() { return None; @@ -674,7 +674,7 @@ impl<'a, P, R> ValidKeyIter<'a, P, R> } } -impl<'a, P, R> ValidKeyIter<'a, P, R> +impl<'a, P, R> ValidKeyAmalgamationIter<'a, P, R> where P: key::KeyParts, R: key::KeyRole, { @@ -817,8 +817,8 @@ impl<'a, P, R> ValidKeyIter<'a, P, R> } /// Changes the filter to only return keys with secret key material. - pub fn secret(self) -> ValidKeyIter<'a, key::SecretParts, R> { - ValidKeyIter { + pub fn secret(self) -> ValidKeyAmalgamationIter<'a, key::SecretParts, R> { + ValidKeyAmalgamationIter { cert: self.cert, primary: self.primary, subkey_iter: self.subkey_iter, @@ -841,8 +841,8 @@ impl<'a, P, R> ValidKeyIter<'a, P, R> /// Changes the filter to only return keys with unencrypted secret /// key material. - pub fn unencrypted_secret(self) -> ValidKeyIter<'a, key::SecretParts, R> { - ValidKeyIter { + pub fn unencrypted_secret(self) -> ValidKeyAmalgamationIter<'a, key::SecretParts, R> { + ValidKeyAmalgamationIter { cert: self.cert, primary: self.primary, subkey_iter: self.subkey_iter, @@ -889,8 +889,8 @@ impl<'a, P, R> ValidKeyIter<'a, P, R> } /// Changes the iterator to skip the primary key. - pub fn subkeys(self) -> ValidKeyIter<'a, P, key::SubordinateRole> { - ValidKeyIter { + pub fn subkeys(self) -> ValidKeyAmalgamationIter<'a, P, key::SubordinateRole> { + ValidKeyAmalgamationIter { cert: self.cert, primary: true, subkey_iter: self.subkey_iter, diff --git a/openpgp/src/cert/bundle.rs b/openpgp/src/cert/bundle.rs index 7a78ae2b..01a38fd3 100644 --- a/openpgp/src/cert/bundle.rs +++ b/openpgp/src/cert/bundle.rs @@ -30,11 +30,6 @@ pub use iter::{ ValidComponentBundleIter, }; -pub use super::{ - keyiter::KeyIter, - keyiter::ValidKeyIter, -}; - /// 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 f1a5519f..f2bff65d 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 keyiter; pub mod key_amalgamation; mod parser; mod revoke; @@ -683,9 +682,9 @@ impl Cert { /// /// That is, this returns an iterator over the primary key and any /// subkeys. - pub fn keys(&self) -> KeyIter<key::PublicParts, key::UnspecifiedRole> + pub fn keys(&self) -> KeyAmalgamationIter<key::PublicParts, key::UnspecifiedRole> { - KeyIter::new(self) + KeyAmalgamationIter::new(self) } /// Returns the Cert found in the packet stream. @@ -1465,7 +1464,7 @@ impl<'a> ValidCert<'a> { /// /// That is, this returns an iterator over the primary key and any /// subkeys. - pub fn keys(&self) -> ValidKeyIter<key::PublicParts, key::UnspecifiedRole> { + pub fn keys(&self) -> ValidKeyAmalgamationIter<key::PublicParts, key::UnspecifiedRole> { self.cert.keys().with_policy(self.policy, self.time) } diff --git a/openpgp/src/cert/prelude.rs b/openpgp/src/cert/prelude.rs index 32eabf80..3c825bf6 100644 --- a/openpgp/src/cert/prelude.rs +++ b/openpgp/src/cert/prelude.rs @@ -29,20 +29,20 @@ pub use crate::cert::{ UserIDRevocationBuilder, ValidCert, amalgamation::ComponentAmalgamation, + amalgamation::KeyAmalgamationIter, amalgamation::ValidAmalgamation as _, amalgamation::ValidComponentAmalgamation, + amalgamation::ValidKeyAmalgamationIter, amalgamation::ValidateAmalgamation as _, bundle::ComponentBundle, bundle::ComponentBundleIter, bundle::KeyBundle, - bundle::KeyIter, bundle::PrimaryKeyBundle, bundle::SubkeyBundle, bundle::UnknownBundle, bundle::UserAttributeBundle, bundle::UserIDBundle, bundle::ValidComponentBundleIter, - bundle::ValidKeyIter, key_amalgamation::ErasedKeyAmalgamation, key_amalgamation::KeyAmalgamation, key_amalgamation::Primary as _, |