summaryrefslogtreecommitdiffstats
path: root/openpgp/src
diff options
context:
space:
mode:
Diffstat (limited to 'openpgp/src')
-rw-r--r--openpgp/src/cert/amalgamation.rs23
-rw-r--r--openpgp/src/cert/components.rs1
-rw-r--r--openpgp/src/cert/key_amalgamation.rs25
-rw-r--r--openpgp/src/parse/stream.rs1
4 files changed, 34 insertions, 16 deletions
diff --git a/openpgp/src/cert/amalgamation.rs b/openpgp/src/cert/amalgamation.rs
index 64f5adf3..380abbeb 100644
--- a/openpgp/src/cert/amalgamation.rs
+++ b/openpgp/src/cert/amalgamation.rs
@@ -31,6 +31,13 @@ impl<'a, C> std::ops::Deref for ComponentAmalgamation<'a, C> {
}
}
+impl<'a, C> Amalgamation<'a> for ComponentAmalgamation<'a, C> {
+ /// Returns the certificate that the component came from.
+ fn cert(&self) -> &'a Cert {
+ self.cert
+ }
+}
+
impl<'a, C> ComponentAmalgamation<'a, C> {
/// Creates a new amalgamation.
pub(crate) fn new(cert: &'a Cert, bundle: &'a ComponentBundle<C>) -> Self
@@ -41,11 +48,6 @@ impl<'a, C> ComponentAmalgamation<'a, C> {
}
}
- /// Returns the certificate that the component came from.
- pub fn cert(&self) -> &'a Cert {
- self.cert
- }
-
/// Returns this component's bundle.
pub fn bundle(&self) -> &'a ComponentBundle<C> {
&self.bundle
@@ -199,11 +201,14 @@ impl<'a, C> ValidComponentAmalgamation<'a, C>
}
}
-/// Represents a component under a given policy.
-pub trait ValidAmalgamation<'a> {
+/// Represents a component.
+pub trait Amalgamation<'a> {
/// Returns the certificate that the component came from.
fn cert(&self) -> &'a Cert;
+}
+/// Represents a component under a given policy.
+pub trait ValidAmalgamation<'a> : Amalgamation<'a>{
/// Returns the amalgamation's reference time.
///
/// For queries that are with respect to a point in time, this
@@ -377,13 +382,15 @@ pub trait ValidAmalgamation<'a> {
}
}
-impl<'a, C> ValidAmalgamation<'a> for ValidComponentAmalgamation<'a, C> {
+impl<'a, C> Amalgamation<'a> for ValidComponentAmalgamation<'a, C> {
// NOTE: No docstring, because ComponentAmalgamation has the same method.
// Returns the certificate that the component came from.
fn cert(&self) -> &'a Cert {
self.cert
}
+}
+impl<'a, C> ValidAmalgamation<'a> for ValidComponentAmalgamation<'a, C> {
/// Returns the amalgamation's reference time.
///
/// For queries that are with respect to a point in time, this
diff --git a/openpgp/src/cert/components.rs b/openpgp/src/cert/components.rs
index 3965e65f..365c3f1c 100644
--- a/openpgp/src/cert/components.rs
+++ b/openpgp/src/cert/components.rs
@@ -25,6 +25,7 @@ use super::{
canonical_signature_order,
};
pub use super::amalgamation::{
+ Amalgamation,
ComponentAmalgamation,
ValidAmalgamation,
ValidComponentAmalgamation,
diff --git a/openpgp/src/cert/key_amalgamation.rs b/openpgp/src/cert/key_amalgamation.rs
index f0e5c50b..dcc74599 100644
--- a/openpgp/src/cert/key_amalgamation.rs
+++ b/openpgp/src/cert/key_amalgamation.rs
@@ -7,6 +7,7 @@ use failure::ResultExt;
use crate::{
Cert,
cert::components::{
+ Amalgamation,
KeyBundle,
ValidAmalgamation,
},
@@ -46,6 +47,12 @@ impl<'a, P: key::KeyParts> Deref for KeyAmalgamation<'a, P> {
}
}
+impl<'a, P: 'a + key::KeyParts> Amalgamation<'a> for KeyAmalgamation<'a, P> {
+ fn cert(&self) -> &'a Cert {
+ self.cert
+ }
+}
+
impl<'a, P: 'a + key::KeyParts> KeyAmalgamation<'a, P> {
pub(crate) fn new_primary(cert: &'a Cert) -> Self {
KeyAmalgamation {
@@ -87,12 +94,6 @@ impl<'a, P: 'a + key::KeyParts> KeyAmalgamation<'a, P> {
}
}
- /// Returns the certificate that the key came from.
- pub fn cert(&self) -> &'a Cert
- {
- self.cert
- }
-
/// Returns this key's bundle.
pub fn bundle(&self) -> &'a KeyBundle<P, key::UnspecifiedRole> {
match self {
@@ -273,7 +274,7 @@ impl<'a, P: key::KeyParts> From<ValidKeyAmalgamation<'a, P>>
}
}
-impl<'a, P: 'a + key::KeyParts> ValidAmalgamation<'a>
+impl<'a, P: 'a + key::KeyParts> Amalgamation<'a>
for ValidKeyAmalgamation<'a, P>
{
// NOTE: No docstring, because KeyAmalgamation has the same method.
@@ -281,7 +282,11 @@ impl<'a, P: 'a + key::KeyParts> ValidAmalgamation<'a>
fn cert(&self) -> &'a Cert {
self.cert
}
+}
+impl<'a, P: 'a + key::KeyParts> ValidAmalgamation<'a>
+ for ValidKeyAmalgamation<'a, P>
+{
/// Returns the amalgamation's reference time.
///
/// For queries that are with respect to a point in time, this
@@ -452,7 +457,7 @@ impl<'a, P: key::KeyParts> ValidPrimaryKeyAmalgamation<'a, P> {
}
}
-impl<'a, P: 'a + key::KeyParts> ValidAmalgamation<'a>
+impl<'a, P: 'a + key::KeyParts> Amalgamation<'a>
for ValidPrimaryKeyAmalgamation<'a, P>
{
// NOTE: No docstring, because KeyAmalgamation has the same method.
@@ -460,7 +465,11 @@ impl<'a, P: 'a + key::KeyParts> ValidAmalgamation<'a>
fn cert(&self) -> &'a Cert {
self.a.cert()
}
+}
+impl<'a, P: 'a + key::KeyParts> ValidAmalgamation<'a>
+ for ValidPrimaryKeyAmalgamation<'a, P>
+{
/// Returns the amalgamation's reference time.
///
/// For queries that are with respect to a point in time, this
diff --git a/openpgp/src/parse/stream.rs b/openpgp/src/parse/stream.rs
index ceca3e3c..646da1fe 100644
--- a/openpgp/src/parse/stream.rs
+++ b/openpgp/src/parse/stream.rs
@@ -44,6 +44,7 @@ use crate::{
packet::Signature,
Cert,
cert::components::{
+ Amalgamation,
ValidAmalgamation,
ValidKeyAmalgamation,
},