summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeal H. Walfield <neal@pep.foundation>2022-01-03 16:04:29 +0100
committerNeal H. Walfield <neal@pep.foundation>2022-01-13 10:23:34 +0100
commit57f0aebec70feb838e825b7ae771054c64cb50c0 (patch)
tree31f7715170cc60d656a73d9b26eaabedfff39ab6
parent49de4f855db1497391263651be290f93487ad6f4 (diff)
sq: Change function to also take a reference.
- Change `get_signing_keys` to also take a `&Cert`, not just a `Cert`, by making it polymorphic over the element type. Specifically, change it to take a `Borrow<Cert>` instead of a `Cert`.
-rw-r--r--sq/src/commands/mod.rs9
1 files changed, 6 insertions, 3 deletions
diff --git a/sq/src/commands/mod.rs b/sq/src/commands/mod.rs
index 85466717..dc90477d 100644
--- a/sq/src/commands/mod.rs
+++ b/sq/src/commands/mod.rs
@@ -1,4 +1,5 @@
use anyhow::Context as _;
+use std::borrow::Borrow;
use std::cmp::Ordering;
use std::collections::{HashMap, HashSet};
use std::fs::File;
@@ -54,13 +55,15 @@ pub mod certify;
/// Returns suitable signing keys from a given list of Certs.
#[allow(clippy::never_loop)]
-fn get_signing_keys(certs: &[openpgp::Cert], p: &dyn Policy,
- private_key_store: Option<&str>,
- timestamp: Option<SystemTime>)
+fn get_signing_keys<C>(certs: &[C], p: &dyn Policy,
+ private_key_store: Option<&str>,
+ timestamp: Option<SystemTime>)
-> Result<Vec<Box<dyn crypto::Signer + Send + Sync>>>
+ where C: Borrow<Cert>
{
let mut keys: Vec<Box<dyn crypto::Signer + Send + Sync>> = Vec::new();
'next_cert: for tsk in certs {
+ let tsk = tsk.borrow();
for key in tsk.keys().with_policy(p, timestamp).alive().revoked(false)
.for_signing()
.supported()