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 | |
parent | 8ebaf6e4ada1cea0b9e6f6dfee61c22cfdc9748c (diff) |
openpgp: Rename KeyIter to KeyAmalgamationIter
- Rename `KeyIter` to `KeyAmalgamationIter`, `ValidKeyIter` to
`ValidKeyAmalgamationIter`.
- Rename `cert/keyiter.rs` to `cert/amalgamation/iter.rs`.
-rw-r--r-- | openpgp-ffi/include/sequoia/openpgp.h | 2 | ||||
-rw-r--r-- | openpgp-ffi/src/cert.rs | 80 | ||||
-rw-r--r-- | openpgp-ffi/src/serialize.rs | 8 | ||||
-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 |
8 files changed, 96 insertions, 96 deletions
diff --git a/openpgp-ffi/include/sequoia/openpgp.h b/openpgp-ffi/include/sequoia/openpgp.h index 09b2f49e..624435a0 100644 --- a/openpgp-ffi/include/sequoia/openpgp.h +++ b/openpgp-ffi/include/sequoia/openpgp.h @@ -681,7 +681,7 @@ pgp_valid_user_id_amalgamation_t pgp_cert_valid_user_id_iter_next (pgp_cert_vali /*/ void pgp_cert_valid_user_id_iter_free (pgp_cert_valid_user_id_iter_t iter); -/* openpgp::cert::KeyIter. */ +/* openpgp::cert::KeyAmalgamationIter. */ /*/ /// Changes the iterator to only return keys that have secret keys. diff --git a/openpgp-ffi/src/cert.rs b/openpgp-ffi/src/cert.rs index 4541c03e..89c61199 100644 --- a/openpgp-ffi/src/cert.rs +++ b/openpgp-ffi/src/cert.rs @@ -446,7 +446,7 @@ pub extern "C" fn pgp_cert_user_id_iter_next<'a>( } } -/// Wraps a ValidKeyIter for export via the FFI. +/// Wraps a ValidKeyAmalgamationIter for export via the FFI. pub struct ValidUserIDIterWrapper<'a> { pub(crate) // For serialize.rs. iter: Option<ValidComponentBundleIter<'a, openpgp::packet::UserID>>, @@ -494,12 +494,12 @@ pub extern "C" fn pgp_cert_valid_user_id_iter_next<'a>( } -/* cert::KeyIter. */ +/* cert::KeyAmalgamationIter. */ -/// Wraps a KeyIter for export via the FFI. -pub struct KeyIterWrapper<'a> { +/// Wraps a KeyAmalgamationIter for export via the FFI. +pub struct KeyAmalgamationIterWrapper<'a> { pub(crate) // For serialize.rs. - iter: Option<KeyIter<'a, openpgp::packet::key::PublicParts, + iter: Option<KeyAmalgamationIter<'a, openpgp::packet::key::PublicParts, openpgp::packet::key::UnspecifiedRole>>, // Whether next has been called. next_called: bool, @@ -511,10 +511,10 @@ pub struct KeyIterWrapper<'a> { /// subkeys. #[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C" fn pgp_cert_key_iter(cert: *const Cert) - -> *mut KeyIterWrapper<'static> + -> *mut KeyAmalgamationIterWrapper<'static> { let cert = cert.ref_raw(); - box_raw!(KeyIterWrapper { + box_raw!(KeyAmalgamationIterWrapper { iter: Some(cert.keys()), next_called: false, }) @@ -523,7 +523,7 @@ pub extern "C" fn pgp_cert_key_iter(cert: *const Cert) /// Frees a pgp_cert_key_iter_t. #[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C" fn pgp_cert_key_iter_free( - iter: Option<&mut KeyIterWrapper>) + iter: Option<&mut KeyAmalgamationIterWrapper>) { ffi_free!(iter) } @@ -533,11 +533,11 @@ pub extern "C" fn pgp_cert_key_iter_free( /// Note: you may not call this function after starting to iterate. #[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C" fn pgp_cert_key_iter_secret<'a>( - iter_wrapper: *mut KeyIterWrapper<'a>) + iter_wrapper: *mut KeyAmalgamationIterWrapper<'a>) { let iter_wrapper = ffi_param_ref_mut!(iter_wrapper); if iter_wrapper.next_called { - panic!("Can't change KeyIter filter after iterating."); + panic!("Can't change KeyAmalgamationIter filter after iterating."); } use std::mem::transmute; @@ -552,11 +552,11 @@ pub extern "C" fn pgp_cert_key_iter_secret<'a>( /// Note: you may not call this function after starting to iterate. #[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C" fn pgp_cert_key_iter_unencrypted_secret<'a>( - iter_wrapper: *mut KeyIterWrapper<'a>) + iter_wrapper: *mut KeyAmalgamationIterWrapper<'a>) { let iter_wrapper = ffi_param_ref_mut!(iter_wrapper); if iter_wrapper.next_called { - panic!("Can't change KeyIter filter after iterating."); + panic!("Can't change KeyAmalgamationIter filter after iterating."); } use std::mem::transmute; @@ -571,19 +571,19 @@ pub extern "C" fn pgp_cert_key_iter_unencrypted_secret<'a>( /// Note: you may not call this function after starting to iterate. #[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C" fn pgp_cert_key_iter_policy<'a>( - iter_wrapper: *mut KeyIterWrapper<'a>, + iter_wrapper: *mut KeyAmalgamationIterWrapper<'a>, policy: *const Policy, when: time_t) - -> *mut ValidKeyIterWrapper<'static> + -> *mut ValidKeyAmalgamationIterWrapper<'static> { let policy = policy.ref_raw(); let iter_wrapper = ffi_param_ref_mut!(iter_wrapper); if iter_wrapper.next_called { - panic!("Can't change KeyIter filter after iterating."); + panic!("Can't change KeyAmalgamationIter filter after iterating."); } use std::mem::transmute; - box_raw!(ValidKeyIterWrapper { + box_raw!(ValidKeyAmalgamationIterWrapper { iter: Some(unsafe { transmute(iter_wrapper.iter.take().unwrap() .with_policy(&**policy, maybe_time(when))) @@ -603,7 +603,7 @@ pub extern "C" fn pgp_cert_key_iter_policy<'a>( /// *rso. #[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C" fn pgp_cert_key_iter_next<'a>( - iter_wrapper: *mut KeyIterWrapper<'a>) + iter_wrapper: *mut KeyAmalgamationIterWrapper<'a>) -> Maybe<KeyAmalgamation<'a>> { let iter_wrapper = ffi_param_ref_mut!(iter_wrapper); @@ -616,10 +616,10 @@ pub extern "C" fn pgp_cert_key_iter_next<'a>( } } -/// Wraps a ValidKeyIter for export via the FFI. -pub struct ValidKeyIterWrapper<'a> { +/// Wraps a ValidKeyAmalgamationIter for export via the FFI. +pub struct ValidKeyAmalgamationIterWrapper<'a> { pub(crate) // For serialize.rs. - iter: Option<ValidKeyIter<'a, openpgp::packet::key::PublicParts, + iter: Option<ValidKeyAmalgamationIter<'a, openpgp::packet::key::PublicParts, openpgp::packet::key::UnspecifiedRole>>, // Whether next has been called. next_called: bool, @@ -633,10 +633,10 @@ pub struct ValidKeyIterWrapper<'a> { #[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C" fn pgp_cert_valid_key_iter(cert: *const Cert, policy: *const Policy, when: time_t) - -> *mut ValidKeyIterWrapper<'static> + -> *mut ValidKeyAmalgamationIterWrapper<'static> { let cert = cert.ref_raw(); - let iter = box_raw!(KeyIterWrapper { + let iter = box_raw!(KeyAmalgamationIterWrapper { iter: Some(cert.keys()), next_called: false, }); @@ -647,7 +647,7 @@ pub extern "C" fn pgp_cert_valid_key_iter(cert: *const Cert, /// Frees a pgp_cert_key_iter_t. #[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C" fn pgp_cert_valid_key_iter_free( - iter: Option<&mut ValidKeyIterWrapper>) + iter: Option<&mut ValidKeyAmalgamationIterWrapper>) { ffi_free!(iter) } @@ -657,11 +657,11 @@ pub extern "C" fn pgp_cert_valid_key_iter_free( /// Note: you may not call this function after starting to iterate. #[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C" fn pgp_cert_valid_key_iter_secret<'a>( - iter_wrapper: *mut ValidKeyIterWrapper<'a>) + iter_wrapper: *mut ValidKeyAmalgamationIterWrapper<'a>) { let iter_wrapper = ffi_param_ref_mut!(iter_wrapper); if iter_wrapper.next_called { - panic!("Can't change ValidKeyIter filter after iterating."); + panic!("Can't change ValidKeyAmalgamationIter filter after iterating."); } use std::mem::transmute; @@ -676,11 +676,11 @@ pub extern "C" fn pgp_cert_valid_key_iter_secret<'a>( /// Note: you may not call this function after starting to iterate. #[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C" fn pgp_cert_valid_key_iter_unencrypted_secret<'a>( - iter_wrapper: *mut ValidKeyIterWrapper<'a>) + iter_wrapper: *mut ValidKeyAmalgamationIterWrapper<'a>) { let iter_wrapper = ffi_param_ref_mut!(iter_wrapper); if iter_wrapper.next_called { - panic!("Can't change ValidKeyIter filter after iterating."); + panic!("Can't change ValidKeyAmalgamationIter filter after iterating."); } use std::mem::transmute; @@ -700,11 +700,11 @@ pub extern "C" fn pgp_cert_valid_key_iter_unencrypted_secret<'a>( /// Note: you may not call this function after starting to iterate. #[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C" fn pgp_cert_valid_key_iter_for_certification<'a>( - iter_wrapper: *mut ValidKeyIterWrapper<'a>) + iter_wrapper: *mut ValidKeyAmalgamationIterWrapper<'a>) { let iter_wrapper = ffi_param_ref_mut!(iter_wrapper); if iter_wrapper.next_called { - panic!("Can't change KeyIter filter after iterating."); + panic!("Can't change KeyAmalgamationIter filter after iterating."); } iter_wrapper.iter = @@ -722,11 +722,11 @@ pub extern "C" fn pgp_cert_valid_key_iter_for_certification<'a>( /// Note: you may not call this function after starting to iterate. #[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C" fn pgp_cert_valid_key_iter_for_signing<'a>( - iter_wrapper: *mut ValidKeyIterWrapper<'a>) + iter_wrapper: *mut ValidKeyAmalgamationIterWrapper<'a>) { let iter_wrapper = ffi_param_ref_mut!(iter_wrapper); if iter_wrapper.next_called { - panic!("Can't change KeyIter filter after iterating."); + panic!("Can't change KeyAmalgamationIter filter after iterating."); } iter_wrapper.iter = @@ -744,11 +744,11 @@ pub extern "C" fn pgp_cert_valid_key_iter_for_signing<'a>( /// Note: you may not call this function after starting to iterate. #[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C" fn pgp_cert_valid_key_iter_for_storage_encryption<'a>( - iter_wrapper: *mut ValidKeyIterWrapper<'a>) + iter_wrapper: *mut ValidKeyAmalgamationIterWrapper<'a>) { let iter_wrapper = ffi_param_ref_mut!(iter_wrapper); if iter_wrapper.next_called { - panic!("Can't change KeyIter filter after iterating."); + panic!("Can't change KeyAmalgamationIter filter after iterating."); } iter_wrapper.iter = @@ -766,11 +766,11 @@ pub extern "C" fn pgp_cert_valid_key_iter_for_storage_encryption<'a>( /// Note: you may not call this function after starting to iterate. #[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C" fn pgp_cert_valid_key_iter_for_transport_encryption<'a>( - iter_wrapper: *mut ValidKeyIterWrapper<'a>) + iter_wrapper: *mut ValidKeyAmalgamationIterWrapper<'a>) { let iter_wrapper = ffi_param_ref_mut!(iter_wrapper); if iter_wrapper.next_called { - panic!("Can't change KeyIter filter after iterating."); + panic!("Can't change KeyAmalgamationIter filter after iterating."); } iter_wrapper.iter = @@ -785,11 +785,11 @@ pub extern "C" fn pgp_cert_valid_key_iter_for_transport_encryption<'a>( /// Note: you may not call this function after starting to iterate. #[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C" fn pgp_cert_valid_key_iter_alive<'a>( - iter_wrapper: *mut ValidKeyIterWrapper<'a>) + iter_wrapper: *mut ValidKeyAmalgamationIterWrapper<'a>) { let iter_wrapper = ffi_param_ref_mut!(iter_wrapper); if iter_wrapper.next_called { - panic!("Can't change KeyIter filter after iterating."); + panic!("Can't change KeyAmalgamationIter filter after iterating."); } iter_wrapper.iter = Some(iter_wrapper.iter.take().unwrap().alive()); @@ -801,12 +801,12 @@ pub extern "C" fn pgp_cert_valid_key_iter_alive<'a>( /// Note: you may not call this function after starting to iterate. #[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C" fn pgp_cert_valid_key_iter_revoked<'a>( - iter_wrapper: *mut ValidKeyIterWrapper<'a>, + iter_wrapper: *mut ValidKeyAmalgamationIterWrapper<'a>, revoked: bool) { let iter_wrapper = ffi_param_ref_mut!(iter_wrapper); if iter_wrapper.next_called { - panic!("Can't change KeyIter filter after iterating."); + panic!("Can't change KeyAmalgamationIter filter after iterating."); } iter_wrapper.iter = @@ -822,7 +822,7 @@ pub extern "C" fn pgp_cert_valid_key_iter_revoked<'a>( /// *rso. #[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C" fn pgp_cert_valid_key_iter_next<'a>( - iter_wrapper: *mut ValidKeyIterWrapper<'a>, + iter_wrapper: *mut ValidKeyAmalgamationIterWrapper<'a>, sigo: Option<&mut *mut Signature>, rso: Option<&mut *mut RevocationStatus<'a>>) -> Maybe<ValidKeyAmalgamation<'a>> diff --git a/openpgp-ffi/src/serialize.rs b/openpgp-ffi/src/serialize.rs index bcd2d6f2..b137a485 100644 --- a/openpgp-ffi/src/serialize.rs +++ b/openpgp-ffi/src/serialize.rs @@ -37,8 +37,8 @@ use self::openpgp::serialize::{ use super::keyid::KeyID; use super::packet::key::Key; -use super::cert::KeyIterWrapper; -use super::cert::ValidKeyIterWrapper; +use super::cert::KeyAmalgamationIterWrapper; +use super::cert::ValidKeyAmalgamationIterWrapper; /// Streams an OpenPGP message. /// @@ -279,7 +279,7 @@ fn pgp_recipient_set_keyid(recipient: *mut Recipient, keyid: *mut KeyID) { /// libc's allocator. #[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C" fn pgp_recipients_from_key_iter<'a>( - iter_wrapper: *mut KeyIterWrapper<'a>, + iter_wrapper: *mut KeyAmalgamationIterWrapper<'a>, result_len: *mut size_t) -> *mut *mut Recipient<'a> { @@ -311,7 +311,7 @@ fn pgp_recipients_from_key_iter<'a>( /// libc's allocator. #[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C" fn pgp_recipients_from_valid_key_iter<'a>( - iter_wrapper: *mut ValidKeyIterWrapper<'a>, + iter_wrapper: *mut ValidKeyAmalgamationIterWrapper<'a>, result_len: *mut size_t) -> *mut *mut Recipient<'a> { 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 _, |