use std::fmt;
use std::convert::{TryFrom, TryInto};
use std::time::SystemTime;
use std::borrow::Borrow;
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()`.
///
/// `KeyIter` follows the builder pattern. There is no need to
/// explicitly finalize it, however: it already implements the
/// `Iterator` trait.
///
/// By default, `KeyIter` returns all keys. `KeyIter` provides some
/// filters to control what it returns. For instance,
/// `KeyIter::secret` causes the iterator to only returns keys that
/// include secret key material. Of course, since `KeyIter`
/// implements `Iterator`, it is possible to use `Iterator::filter` to
/// implement custom filters.
pub struct KeyIter<'a, P: key::KeyParts> {
// This is an option to make it easier to create an empty KeyIter.
cert: Option<&'a Cert>,
primary: bool,
subkey_iter: UnfilteredKeyBundleIter<'a,
key