diff options
Diffstat (limited to 'openpgp/src/cert')
-rw-r--r-- | openpgp/src/cert/amalgamation.rs | 64 | ||||
-rw-r--r-- | openpgp/src/cert/bindings.rs | 4 | ||||
-rw-r--r-- | openpgp/src/cert/builder.rs | 3 | ||||
-rw-r--r-- | openpgp/src/cert/bundle.rs | 8 |
4 files changed, 20 insertions, 59 deletions
diff --git a/openpgp/src/cert/amalgamation.rs b/openpgp/src/cert/amalgamation.rs index c9ffc6e8..169898a8 100644 --- a/openpgp/src/cert/amalgamation.rs +++ b/openpgp/src/cert/amalgamation.rs @@ -800,65 +800,25 @@ impl<'a, C> ComponentAmalgamation<'a, C> { } /// The component's self-signatures. - /// - /// This method is a forwarder for - /// [`ComponentBundle::self_signatures`]. Although - /// `ComponentAmalgamation` derefs to a `&ComponentBundle`, this - /// method provides a more accurate lifetime, which is helpful - /// when returning the reference from a function. [See the - /// module's documentation] for more details. - /// - /// [`ComponentBundle::self_signatures`]: ../bundle/struct.ComponentBundle.html#method.self_signatures - /// [See the module's documentation]: index.html - pub fn self_signatures(&self) -> &'a [Signature] { - self.bundle().self_signatures() + pub fn self_signatures(&self) -> impl Iterator<Item=&'a Signature> + Send + Sync { + self.bundle().self_signatures().iter() } /// The component's third-party certifications. - /// - /// This method is a forwarder for - /// [`ComponentBundle::certifications`]. Although - /// `ComponentAmalgamation` derefs to a `&ComponentBundle`, this - /// method provides a more accurate lifetime, which is helpful - /// when returning the reference from a function. [See the - /// module's documentation] for more details. - /// - /// [`ComponentBundle::certifications`]: ../bundle/struct.ComponentBundle.html#method.certifications - /// [See the module's documentation]: index.html - pub fn certifications(&self) -> &'a [Signature] { - self.bundle().certifications() + pub fn certifications(&self) -> impl Iterator<Item=&'a Signature> + Send + Sync { + self.bundle().certifications().iter() } /// The component's revocations that were issued by the /// certificate holder. - /// - /// This method is a forwarder for - /// [`ComponentBundle::self_revocations`]. Although - /// `ComponentAmalgamation` derefs to a `&ComponentBundle`, this - /// method provides a more accurate lifetime, which is helpful - /// when returning the reference from a function. [See the - /// module's documentation] for more details. - /// - /// [`ComponentBundle::self_revocations`]: ../bundle/struct.ComponentBundle.html#method.self_revocations - /// [See the module's documentation]: index.html - pub fn self_revocations(&self) -> &'a [Signature] { - self.bundle().self_revocations() + pub fn self_revocations(&self) -> impl Iterator<Item=&'a Signature> + Send + Sync { + self.bundle().self_revocations().iter() } /// The component's revocations that were issued by other /// certificates. - /// - /// This method is a forwarder for - /// [`ComponentBundle::other_revocations`]. Although - /// `ComponentAmalgamation` derefs to a `&ComponentBundle`, this - /// method provides a more accurate lifetime, which is helpful - /// when returning the reference from a function. [See the - /// module's documentation] for more details. - /// - /// [`ComponentBundle::other_revocations`]: ../bundle/struct.ComponentBundle.html#method.other_revocations - /// [See the module's documentation]: index.html - pub fn other_revocations(&self) -> &'a [Signature] { - self.bundle().other_revocations() + pub fn other_revocations(&self) -> impl Iterator<Item=&'a Signature> + Send + Sync { + self.bundle().other_revocations().iter() } } @@ -1194,7 +1154,7 @@ impl<'a, C> ValidComponentAmalgamation<'a, C> /// /// This method only returns signatures that are valid under the current policy. pub fn self_signatures(&self) -> impl Iterator<Item=&Signature> + Send + Sync { - std::ops::Deref::deref(self).self_signatures().iter() + std::ops::Deref::deref(self).self_signatures() .filter(move |sig| self.cert.policy().signature(sig, HashAlgoSecurity::SecondPreImageResistance).is_ok()) } @@ -1203,7 +1163,7 @@ impl<'a, C> ValidComponentAmalgamation<'a, C> /// /// This method only returns signatures that are valid under the current policy. pub fn certifications(&self) -> impl Iterator<Item=&Signature> + Send + Sync { - std::ops::Deref::deref(self).certifications().iter() + std::ops::Deref::deref(self).certifications() .filter(move |sig| self.cert.policy().signature(sig, HashAlgoSecurity::CollisionResistance).is_ok()) } @@ -1213,7 +1173,7 @@ impl<'a, C> ValidComponentAmalgamation<'a, C> /// /// This method only returns signatures that are valid under the current policy. pub fn self_revocations(&self) -> impl Iterator<Item=&Signature> + Send + Sync { - std::ops::Deref::deref(self).self_revocations().iter() + std::ops::Deref::deref(self).self_revocations() .filter(move |sig|self.cert.policy().signature(sig, HashAlgoSecurity::SecondPreImageResistance).is_ok()) } @@ -1223,7 +1183,7 @@ impl<'a, C> ValidComponentAmalgamation<'a, C> /// /// This method only returns signatures that are valid under the current policy. pub fn other_revocations(&self) -> impl Iterator<Item=&Signature> + Send + Sync { - std::ops::Deref::deref(self).other_revocations().iter() + std::ops::Deref::deref(self).other_revocations() .filter(move |sig| self.cert.policy().signature(sig, HashAlgoSecurity::CollisionResistance).is_ok()) } diff --git a/openpgp/src/cert/bindings.rs b/openpgp/src/cert/bindings.rs index 1d1ee3c5..49f4b4f7 100644 --- a/openpgp/src/cert/bindings.rs +++ b/openpgp/src/cert/bindings.rs @@ -176,7 +176,7 @@ impl UserID { /// /// // Check that we have a certification on the userid. /// assert_eq!(bob.userids().nth(0).unwrap() - /// .certifications().len(), 1); + /// .certifications().count(), 1); /// # Ok(()) } pub fn certify<S, H, T>(&self, signer: &mut dyn Signer, cert: &Cert, signature_type: S, @@ -314,7 +314,7 @@ impl UserAttribute { /// /// // Check that we have a certification on the userid. /// assert_eq!(bob.user_attributes().nth(0).unwrap() - /// .certifications().len(), + /// .certifications().count(), /// 1); /// # Ok(()) } pub fn certify<S, H, T>(&self, signer: &mut dyn Signer, cert: &Cert, diff --git a/openpgp/src/cert/builder.rs b/openpgp/src/cert/builder.rs index 627bd4f0..7a50ac66 100644 --- a/openpgp/src/cert/builder.rs +++ b/openpgp/src/cert/builder.rs @@ -342,7 +342,8 @@ impl CertBuilder<'_> { /// Some("Alice Lovelace <alice@example.org>")) /// .set_creation_time(t) /// .generate()?; - /// assert_eq!(cert.primary_key().self_signatures()[0].signature_creation_time(), + /// assert_eq!(cert.primary_key().self_signatures().nth(0).unwrap() + /// .signature_creation_time(), /// Some(t)); /// # Ok(()) /// # } diff --git a/openpgp/src/cert/bundle.rs b/openpgp/src/cert/bundle.rs index 272088ce..d37f5158 100644 --- a/openpgp/src/cert/bundle.rs +++ b/openpgp/src/cert/bundle.rs @@ -397,7 +397,7 @@ impl<C> ComponentBundle<C> { /// for (i, ka) in cert.keys().enumerate() { /// eprintln!("Key #{} ({}) has {:?} self signatures", /// i, ka.fingerprint(), - /// ka.self_signatures().len()); + /// ka.self_signatures().count()); /// } /// # Ok(()) } /// ``` @@ -426,7 +426,7 @@ impl<C> ComponentBundle<C> { /// for ua in cert.userids() { /// eprintln!("User ID {} has {:?} unverified, third-party certifications", /// String::from_utf8_lossy(ua.userid().value()), - /// ua.certifications().len()); + /// ua.certifications().count()); /// } /// # Ok(()) } /// ``` @@ -456,7 +456,7 @@ impl<C> ComponentBundle<C> { /// for u in cert.userids() { /// eprintln!("User ID {} has {:?} revocation certificates.", /// String::from_utf8_lossy(u.userid().value()), - /// u.self_revocations().len()); + /// u.self_revocations().count()); /// } /// # Ok(()) } /// ``` @@ -486,7 +486,7 @@ impl<C> ComponentBundle<C> { /// for u in cert.userids() { /// eprintln!("User ID {} has {:?} unverified, third-party revocation certificates.", /// String::from_utf8_lossy(u.userid().value()), - /// u.other_revocations().len()); + /// u.other_revocations().count()); /// } /// # Ok(()) } /// ``` |