[][src]Struct sequoia_openpgp::cert::prelude::KeyAmalgamationIter

pub struct KeyAmalgamationIter<'a, P, R> where
    P: KeyParts,
    R: KeyRole
{ /* fields omitted */ }

An iterator over Keys.

A KeyAmalgamationIter is like a ComponentAmalgamationIter, but specialized for keys. Refer to the module documentation for an explanation of why a different type is necessary.

Using the KeyAmalgamationIter::with_policy, it is possible to change the iterator to only return KeyAmalgamations for valid Keys. In this case, KeyAmalgamationIter::with_policy transforms the KeyAmalgamationIter into a ValidKeyAmalgamationIter, which returns ValidKeyAmalgamations. ValidKeyAmalgamation offers additional filters.

KeyAmalgamationIter supports other filters. For instance KeyAmalgamationIter::secret filters on whether secret key material is present, and KeyAmalgamationIter::unencrypted_secret filters on whether secret key material is present and unencrypted. Of course, since KeyAmalgamationIter implements Iterator, it is possible to use Iterator::filter to implement custom filters.

KeyAmalgamationIter follows the builder pattern. There is no need to explicitly finalize it: it already implements the Iterator trait.

A KeyAmalgamationIter is returned by Cert::keys.

Implementations

impl<'a, P, R> KeyAmalgamationIter<'a, P, R> where
    P: KeyParts,
    R: KeyRole
[src]

pub fn secret(self) -> KeyAmalgamationIter<'a, SecretParts, R>[src]

Changes the iterator to only return keys with secret key material.

Examples

for ka in cert.keys().secret() {
    // Use it.
}

pub fn unencrypted_secret(self) -> KeyAmalgamationIter<'a, SecretParts, R>[src]

Changes the iterator to only return keys with unencrypted secret key material.

Examples

for ka in cert.keys().unencrypted_secret() {
    // Use it.
}

pub fn key_handle<H>(self, h: H) -> Self where
    H: Into<KeyHandle>, 
[src]

Changes the iterator to only return a key if it matches one of the specified KeyHandles.

This function is cumulative. If you call this function (or key_handles) multiple times, then the iterator returns a key if it matches any of the specified KeyHandles.

This function uses KeyHandle::aliases to compare key handles.

Examples

for ka in cert.keys().key_handle(key_handle) {
    // Use it.
}

pub fn key_handles<'b>(self, h: impl Iterator<Item = &'b KeyHandle>) -> Self where
    'a: 'b, 
[src]

Changes the iterator to only return a key if it matches one of the specified KeyHandles.

This function is cumulative. If you call this function (or key_handle) multiple times, then the iterator returns a key if it matches any of the specified KeyHandles.

This function uses KeyHandle::aliases to compare key handles.

Examples

for ka in cert.keys().key_handles(key_handles.iter()) {
    // Use it.
}

pub fn subkeys(self) -> KeyAmalgamationIter<'a, P, SubordinateRole>[src]

Changes the iterator to only return subkeys.

This function also changes the return type. Instead of the iterator returning a ErasedKeyAmalgamation, it returns a SubordinateKeyAmalgamation.

Examples

for ka in cert.keys().subkeys() {
    // Use it.
    assert!(! ka.primary());
}

pub fn with_policy<T>(
    self,
    policy: &'a dyn Policy,
    time: T
) -> ValidKeyAmalgamationIter<'a, P, R> where
    T: Into<Option<SystemTime>>, 
[src]

Changes the iterator to only return valid Keys.

If time is None, then the current time is used.

This also makes a number of additional filters like alive and revoked available.

Refer to the ValidateAmalgamation trait for a definition of a valid component.

Examples

use openpgp::policy::StandardPolicy;
let p = &StandardPolicy::new();

// Iterate over all valid User Attributes.
for ka in cert.keys().with_policy(p, None) {
    // ka is a `ValidKeyAmalgamation`, specifically, an
    // `ValidErasedKeyAmalgamation`.
}

Trait Implementations

impl<'a, P, R> Debug for KeyAmalgamationIter<'a, P, R> where
    P: KeyParts,
    R: KeyRole
[src]

impl<'a> Iterator for KeyAmalgamationIter<'a, PublicParts, PrimaryRole>[src]

type Item = PrimaryKeyAmalgamation<'a, PublicParts>

The type of the elements being iterated over.

impl<'a> Iterator for KeyAmalgamationIter<'a, SecretParts, PrimaryRole>[src]

type Item = PrimaryKeyAmalgamation<'a, SecretParts>

The type of the elements being iterated over.

impl<'a> Iterator for KeyAmalgamationIter<'a, UnspecifiedParts, PrimaryRole>[src]

type Item = PrimaryKeyAmalgamation<'a, UnspecifiedParts>

The type of the elements being iterated over.

impl<'a> Iterator for KeyAmalgamationIter<'a, PublicParts, SubordinateRole>[src]

type Item = SubordinateKeyAmalgamation<'a, PublicParts>

The type of the elements being iterated over.

impl<'a> Iterator for KeyAmalgamationIter<'a, SecretParts, SubordinateRole>[src]

type Item = SubordinateKeyAmalgamation<'a, SecretParts>

The type of the elements being iterated over.

impl<'a> Iterator for KeyAmalgamationIter<'a, UnspecifiedParts, SubordinateRole>[src]

type Item = SubordinateKeyAmalgamation<'a, UnspecifiedParts>

The type of the elements being iterated over.

impl<'a> Iterator for KeyAmalgamationIter<'a, PublicParts, UnspecifiedRole>[src]

type Item = ErasedKeyAmalgamation<'a, PublicParts>

The type of the elements being iterated over.

impl<'a> Iterator for KeyAmalgamationIter<'a, SecretParts, UnspecifiedRole>[src]

type Item = ErasedKeyAmalgamation<'a, SecretParts>

The type of the elements being iterated over.

impl<'a> Iterator for KeyAmalgamationIter<'a, UnspecifiedParts, UnspecifiedRole>[src]

type Item = ErasedKeyAmalgamation<'a, UnspecifiedParts>

The type of the elements being iterated over.

Auto Trait Implementations

impl<'a, P, R> RefUnwindSafe for KeyAmalgamationIter<'a, P, R> where
    P: RefUnwindSafe,
    R: RefUnwindSafe

impl<'a, P, R> Send for KeyAmalgamationIter<'a, P, R> where
    P: Send,
    R: Send

impl<'a, P, R> Sync for KeyAmalgamationIter<'a, P, R> where
    P: Sync,
    R: Sync

impl<'a, P, R> Unpin for KeyAmalgamationIter<'a, P, R> where
    P: Unpin,
    R: Unpin

impl<'a, P, R> UnwindSafe for KeyAmalgamationIter<'a, P, R> where
    P: UnwindSafe,
    R: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<I> UnicodeNormalization<I> for I where
    I: Iterator<Item = char>,