diff options
author | Neal H. Walfield <neal@pep.foundation> | 2020-01-06 10:29:13 +0100 |
---|---|---|
committer | Neal H. Walfield <neal@pep.foundation> | 2020-01-06 14:34:03 +0100 |
commit | 7e78e716610ac3a9bff86035c52b344b437951a2 (patch) | |
tree | 8897a006fd588a019c4beffabdf0050bdc1b8c5b /openpgp/src/serialize/cert.rs | |
parent | a01b070c9599be7f2be4dfaa25dd9ff01efe8a57 (diff) |
openpgp: Pass a timestamp to the KeyIter instead of each filter.
- KeyIter::revoked and KeyIter::key_flags (and its variants) didn't
take a time stamp so they could only be used for filtering keys
based on their current state, not their state at some time in the
past. Adding a time stamp to each of the filters would have fixed
the problem, but it would have made the interface ugly: callers
always want the same time stamp for all filters.
- Split KeyIter into two structures: a KeyIter and a ValidKeyIter.
- Add KeyIter::policy. It takes a time stamp, which is then used
for filters like `alive` and `revoked`, and it returns a
ValidKeyIter, which exposes filters that require a time stamp.
Diffstat (limited to 'openpgp/src/serialize/cert.rs')
-rw-r--r-- | openpgp/src/serialize/cert.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/openpgp/src/serialize/cert.rs b/openpgp/src/serialize/cert.rs index 773606a6..4c217cbf 100644 --- a/openpgp/src/serialize/cert.rs +++ b/openpgp/src/serialize/cert.rs @@ -316,7 +316,7 @@ impl<'a> TSK<'a> { /// # f().unwrap(); /// # fn f() -> Result<()> { /// let (cert, _) = CertBuilder::new().add_signing_subkey().generate()?; - /// assert_eq!(cert.keys().alive().revoked(false).secret().count(), 2); + /// assert_eq!(cert.keys().policy(None).alive().revoked(false).secret().count(), 2); /// /// // Only write out the primary key's secret. /// let mut buf = Vec::new(); @@ -328,7 +328,7 @@ impl<'a> TSK<'a> { /// .serialize(&mut buf)?; /// /// let cert_ = Cert::from_bytes(&buf)?; - /// assert_eq!(cert_.keys().alive().revoked(false).secret().count(), 1); + /// assert_eq!(cert_.keys().policy(None).alive().revoked(false).secret().count(), 1); /// assert!(cert_.primary().secret().is_some()); /// # Ok(()) } pub fn set_filter<P>(mut self, predicate: P) -> Self |