use std::fmt;
use std::convert::TryInto;
use std::time::SystemTime;
use std::borrow::Borrow;
use std::slice;
use crate::{
KeyHandle,
types::RevocationStatus,
packet::key,
packet::key::SecretKeyMaterial,
types::KeyFlags,
cert::prelude::*,
policy::Policy,
};
/// An iterator over all `Key`s (both the primary key and the subkeys)
/// in a certificate.
///
/// Returned by `Cert::keys()`.
///
/// `KeyAmalgamationIter` follows the builder pattern. There is no need to
/// explicitly finalize it, however: it already implements the
/// `Iterator` trait.
///
/// By default, `KeyAmalgamationIter` returns all keys. `KeyAmalgamationIter` provides some
/// filters to control what it returns. For instance,
/// `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 KeyAmalgamationIter<'a, P, R>
where P: key::KeyParts,
R: key::KeyRole,
{
// 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,
key::SubordinateRole>>,
// If not None, filters by whether a key has a secret.
secret: Option<bool>,
// If not None, filters by whether a key has an unencrypted
// secret.
unencrypted_secret: Option<bool>,
// Only return keys in this set.
key_handles: Vec<KeyHandle>,
_p: std::marker::PhantomData<P>,
_r: std::marker::PhantomData<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)