[][src]Struct sequoia_openpgp::cert::amalgamation::key::KeyAmalgamation

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

A key, and its associated data, and useful methods.

A KeyAmalgamation is like a ComponentAmalgamation, but specialized for keys. Due to the requirement to keep track of the key's role when it is erased (see the module's documentation for more details), this is a different data structure rather than a specialized type alias.

Generally, you won't use this type directly, but instead use PrimaryKeyAmalgamation, SubordinateKeyAmalgamation, or ErasedKeyAmalgamation.

A KeyAmalgamation is returned by Cert::primary_key, and Cert::keys.

KeyAmalgamation implements ValidateAmalgamation, which allows you to turn a KeyAmalgamation into a ValidKeyAmalgamation using KeyAmalgamation::with_policy.

Examples

Iterating over all keys:

for ka in cert.keys() {
    let ka: ErasedKeyAmalgamation<_> = ka;
}

Getting the primary key:

let ka: PrimaryKeyAmalgamation<_> = cert.primary_key();

Iterating over just the subkeys:

// We can skip the primary key (it's always first):
for ka in cert.keys().skip(1) {
    let ka: ErasedKeyAmalgamation<_> = ka;
}

// Or use `subkeys`, which returns a more accurate type:
for ka in cert.keys().subkeys() {
    let ka: SubordinateKeyAmalgamation<_> = ka;
}

Implementations

impl<'a, P> KeyAmalgamation<'a, P, PrimaryRole, ()> where
    P: KeyParts
[src]

pub fn parts_into_public(self) -> PrimaryKeyAmalgamation<'a, PublicParts>[src]

Changes the key's parts tag to PublicParts.

pub fn parts_as_public(&'a self) -> &'a PrimaryKeyAmalgamation<'a, PublicParts>[src]

Changes the key's parts tag to PublicParts.

pub fn parts_into_secret(
    self
) -> Result<PrimaryKeyAmalgamation<'a, SecretParts>>
[src]

Changes the key's parts tag to SecretParts.

pub fn parts_as_secret(
    &'a self
) -> Result<&'a PrimaryKeyAmalgamation<'a, SecretParts>>
[src]

Changes the key's parts tag to SecretParts.

pub fn parts_into_unspecified(
    self
) -> PrimaryKeyAmalgamation<'a, UnspecifiedParts>
[src]

Changes the key's parts tag to UnspecifiedParts.

pub fn parts_as_unspecified(
    &'a self
) -> &PrimaryKeyAmalgamation<'a, UnspecifiedParts>
[src]

Changes the key's parts tag to UnspecifiedParts.

impl<'a, P> KeyAmalgamation<'a, P, SubordinateRole, ()> where
    P: KeyParts
[src]

pub fn parts_into_public(self) -> SubordinateKeyAmalgamation<'a, PublicParts>[src]

Changes the key's parts tag to PublicParts.

pub fn parts_as_public(
    &'a self
) -> &'a SubordinateKeyAmalgamation<'a, PublicParts>
[src]

Changes the key's parts tag to PublicParts.

pub fn parts_into_secret(
    self
) -> Result<SubordinateKeyAmalgamation<'a, SecretParts>>
[src]

Changes the key's parts tag to SecretParts.

pub fn parts_as_secret(
    &'a self
) -> Result<&'a SubordinateKeyAmalgamation<'a, SecretParts>>
[src]

Changes the key's parts tag to SecretParts.

pub fn parts_into_unspecified(
    self
) -> SubordinateKeyAmalgamation<'a, UnspecifiedParts>
[src]

Changes the key's parts tag to UnspecifiedParts.

pub fn parts_as_unspecified(
    &'a self
) -> &SubordinateKeyAmalgamation<'a, UnspecifiedParts>
[src]

Changes the key's parts tag to UnspecifiedParts.

impl<'a, P> KeyAmalgamation<'a, P, UnspecifiedRole, bool> where
    P: KeyParts
[src]

pub fn parts_into_public(self) -> ErasedKeyAmalgamation<'a, PublicParts>[src]

Changes the key's parts tag to PublicParts.

pub fn parts_as_public(&'a self) -> &'a ErasedKeyAmalgamation<'a, PublicParts>[src]

Changes the key's parts tag to PublicParts.

pub fn parts_into_secret(self) -> Result<ErasedKeyAmalgamation<'a, SecretParts>>[src]

Changes the key's parts tag to SecretParts.

pub fn parts_as_secret(
    &'a self
) -> Result<&'a ErasedKeyAmalgamation<'a, SecretParts>>
[src]

Changes the key's parts tag to SecretParts.

pub fn parts_into_unspecified(
    self
) -> ErasedKeyAmalgamation<'a, UnspecifiedParts>
[src]

Changes the key's parts tag to UnspecifiedParts.

pub fn parts_as_unspecified(
    &'a self
) -> &ErasedKeyAmalgamation<'a, UnspecifiedParts>
[src]

Changes the key's parts tag to UnspecifiedParts.

impl<'a, P, R, R2> KeyAmalgamation<'a, P, R, R2> where
    P: 'a + KeyParts,
    R: 'a + KeyRole
[src]

pub fn component_amalgamation(&self) -> &ComponentAmalgamation<'a, Key<P, R>>[src]

Returns the KeyAmalgamation's ComponentAmalgamation.

pub fn key(&self) -> &'a Key<P, R>[src]

Returns the KeyAmalgamation's key.

Normally, a type implementing KeyAmalgamation eventually derefs to a Key, however, this method provides a more accurate lifetime. See the documentation for ComponentAmalgamation::component for an explanation.

Methods from Deref<Target = ComponentAmalgamation<'a, Key<P, R>>>

pub fn parts_as_public(
    &'a self
) -> &'a ComponentAmalgamation<'a, Key<PublicParts, R>>
[src]

Changes the key's parts tag to PublicParts.

pub fn parts_as_secret(
    &'a self
) -> Result<&'a ComponentAmalgamation<'a, Key<SecretParts, R>>>
[src]

Changes the key's parts tag to SecretParts.

pub fn parts_as_unspecified(
    &'a self
) -> &ComponentAmalgamation<'a, Key<UnspecifiedParts, R>>
[src]

Changes the key's parts tag to UnspecifiedParts.

pub fn role_as_primary(
    &'a self
) -> &'a ComponentAmalgamation<'a, Key<P, PrimaryRole>>
[src]

Changes the key's role tag to PrimaryRole.

pub fn role_as_subordinate(
    &'a self
) -> &'a ComponentAmalgamation<'a, Key<P, SubordinateRole>>
[src]

Changes the key's role tag to SubordinateRole.

pub fn role_as_unspecified(
    &'a self
) -> &'a ComponentAmalgamation<'a, Key<P, UnspecifiedRole>>
[src]

Changes the key's role tag to UnspecifiedRole.

pub fn cert(&self) -> &'a Cert[src]

Returns the component's associated certificate.

for u in cert.userids() {
    // It's not only an identical `Cert`, it's the same one.
    assert!(std::ptr::eq(u.cert(), &cert));
}

pub fn bundle(&self) -> &'a ComponentBundle<C>[src]

Returns this amalgamation's bundle.

Note: although ComponentAmalgamation derefs to a &ComponentBundle, this method provides a more accurate lifetime, which is helpful when returning the reference from a function. See the module's documentation for more details.

Examples

use openpgp::cert::prelude::*;
use openpgp::packet::prelude::*;

cert.userids()
    .map(|ua| {
        // The following doesn't work:
        //
        //   let b: &ComponentBundle<_> = &ua; b
        //
        // Because ua's lifetime is this closure and autoderef
        // assigns `b` the same lifetime as `ua`.  `bundle()`,
        // however, returns a reference whose lifetime is that
        // of `cert`.
        ua.bundle()
    })
    .collect::<Vec<&ComponentBundle<_>>>();

pub fn component(&self) -> &'a C[src]

Returns this amalgamation's component.

Note: although ComponentAmalgamation derefs to a &Component (via &ComponentBundle), this method provides a more accurate lifetime, which is helpful when returning the reference from a function. See the module's documentation for more details.

pub fn self_signatures(&self) -> &'a [Signature][src]

The component's self-signatures.

This method is a forwarder for ComponentBundle::self_signatures. Although ComponentAmalgamation derefs to a &ComponentBundle, this method provides a more accurate lifetime, which is helpful when returning the reference from a function. See the module's documentation for more details.

pub fn certifications(&self) -> &'a [Signature][src]

The component's third-party certifications.

This method is a forwarder for ComponentBundle::certifications. Although ComponentAmalgamation derefs to a &ComponentBundle, this method provides a more accurate lifetime, which is helpful when returning the reference from a function. See the module's documentation for more details.

pub fn self_revocations(&self) -> &'a [Signature][src]

The component's revocations that were issued by the certificate holder.

This method is a forwarder for ComponentBundle::self_revocations. Although ComponentAmalgamation derefs to a &ComponentBundle, this method provides a more accurate lifetime, which is helpful when returning the reference from a function. See the module's documentation for more details.

pub fn other_revocations(&self) -> &'a [Signature][src]

The component's revocations that were issued by other certificates.

This method is a forwarder for ComponentBundle::other_revocations. Although ComponentAmalgamation derefs to a &ComponentBundle, this method provides a more accurate lifetime, which is helpful when returning the reference from a function. See the module's documentation for more details.

pub fn revocation_keys(
    &self,
    policy: &dyn Policy
) -> Box<dyn Iterator<Item = &'a RevocationKey> + 'a>
[src]

Returns a list of any designated revokers for this component.

This function returns the designated revokers listed on both this component's binding signature and the certificate's direct key signature.

Note: the returned list is deduplicated.

Examples

use openpgp::cert::prelude::*;
use openpgp::policy::StandardPolicy;
use openpgp::types::RevocationKey;

let p = &StandardPolicy::new();

let (alice, _) =
    CertBuilder::general_purpose(None, Some("alice@example.org"))
    .generate()?;
// Make Alice a designated revoker for Bob.
let (bob, _) =
    CertBuilder::general_purpose(None, Some("bob@example.org"))
    .set_revocation_keys(vec![(&alice).into()])
    .generate()?;

// Make sure Alice is listed as a designated revoker for Bob
// on a component.
assert_eq!(bob.with_policy(p, None)?.primary_userid()?.revocation_keys(p)
               .collect::<Vec<&RevocationKey>>(),
           vec![&(&alice).into()]);

pub fn userid(&self) -> &'a UserID[src]

Returns a reference to the User ID.

Note: although ComponentAmalgamation<UserID> derefs to a &UserID (via &ComponentBundle), this method provides a more accurate lifetime, which is helpful when returning the reference from a function. See the module's documentation for more details.

pub fn user_attribute(&self) -> &'a UserAttribute[src]

Returns a reference to the User Attribute.

Note: although ComponentAmalgamation<UserAttribute> derefs to a &UserAttribute (via &ComponentBundle), this method provides a more accurate lifetime, which is helpful when returning the reference from a function. See the module's documentation for more details.

Trait Implementations

impl<'a, P, R, R2> Clone for KeyAmalgamation<'a, P, R, R2> where
    P: 'a + KeyParts,
    R: 'a + KeyRole,
    R2: Copy
[src]

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

impl<'a, P, R, R2> Deref for KeyAmalgamation<'a, P, R, R2> where
    P: 'a + KeyParts,
    R: 'a + KeyRole
[src]

type Target = ComponentAmalgamation<'a, Key<P, R>>

The resulting type after dereferencing.

impl<'a> From<&'a KeyAmalgamation<'a, PublicParts, PrimaryRole, ()>> for &'a PrimaryKeyAmalgamation<'a, UnspecifiedParts>[src]

impl<'a> From<&'a KeyAmalgamation<'a, PublicParts, SubordinateRole, ()>> for &'a SubordinateKeyAmalgamation<'a, UnspecifiedParts>[src]

impl<'a> From<&'a KeyAmalgamation<'a, PublicParts, UnspecifiedRole, bool>> for &'a ErasedKeyAmalgamation<'a, UnspecifiedParts>[src]

impl<'a> From<&'a KeyAmalgamation<'a, SecretParts, PrimaryRole, ()>> for &'a PrimaryKeyAmalgamation<'a, PublicParts>[src]

impl<'a> From<&'a KeyAmalgamation<'a, SecretParts, PrimaryRole, ()>> for &'a PrimaryKeyAmalgamation<'a, UnspecifiedParts>[src]

impl<'a> From<&'a KeyAmalgamation<'a, SecretParts, SubordinateRole, ()>> for &'a SubordinateKeyAmalgamation<'a, PublicParts>[src]

impl<'a> From<&'a KeyAmalgamation<'a, SecretParts, SubordinateRole, ()>> for &'a SubordinateKeyAmalgamation<'a, UnspecifiedParts>[src]

impl<'a> From<&'a KeyAmalgamation<'a, SecretParts, UnspecifiedRole, bool>> for &'a ErasedKeyAmalgamation<'a, PublicParts>[src]

impl<'a> From<&'a KeyAmalgamation<'a, SecretParts, UnspecifiedRole, bool>> for &'a ErasedKeyAmalgamation<'a, UnspecifiedParts>[src]

impl<'a> From<&'a KeyAmalgamation<'a, UnspecifiedParts, PrimaryRole, ()>> for &'a PrimaryKeyAmalgamation<'a, PublicParts>[src]

impl<'a> From<&'a KeyAmalgamation<'a, UnspecifiedParts, SubordinateRole, ()>> for &'a SubordinateKeyAmalgamation<'a, PublicParts>[src]

impl<'a> From<&'a KeyAmalgamation<'a, UnspecifiedParts, UnspecifiedRole, bool>> for &'a ErasedKeyAmalgamation<'a, PublicParts>[src]

impl<'a, P: 'a + KeyParts> From<KeyAmalgamation<'a, P, PrimaryRole, ()>> for ErasedKeyAmalgamation<'a, P>[src]

impl<'a, P: 'a + KeyParts> From<KeyAmalgamation<'a, P, SubordinateRole, ()>> for ErasedKeyAmalgamation<'a, P>[src]

impl<'a> From<KeyAmalgamation<'a, PublicParts, PrimaryRole, ()>> for PrimaryKeyAmalgamation<'a, UnspecifiedParts>[src]

impl<'a> From<KeyAmalgamation<'a, PublicParts, PrimaryRole, ()>> for ErasedKeyAmalgamation<'a, UnspecifiedParts>[src]

impl<'a> From<KeyAmalgamation<'a, PublicParts, SubordinateRole, ()>> for SubordinateKeyAmalgamation<'a, UnspecifiedParts>[src]

impl<'a> From<KeyAmalgamation<'a, PublicParts, SubordinateRole, ()>> for ErasedKeyAmalgamation<'a, UnspecifiedParts>[src]

impl<'a> From<KeyAmalgamation<'a, PublicParts, UnspecifiedRole, bool>> for ErasedKeyAmalgamation<'a, UnspecifiedParts>[src]

impl<'a> From<KeyAmalgamation<'a, SecretParts, PrimaryRole, ()>> for PrimaryKeyAmalgamation<'a, PublicParts>[src]

impl<'a> From<KeyAmalgamation<'a, SecretParts, PrimaryRole, ()>> for PrimaryKeyAmalgamation<'a, UnspecifiedParts>[src]

impl<'a> From<KeyAmalgamation<'a, SecretParts, PrimaryRole, ()>> for ErasedKeyAmalgamation<'a, PublicParts>[src]

impl<'a> From<KeyAmalgamation<'a, SecretParts, PrimaryRole, ()>> for ErasedKeyAmalgamation<'a, UnspecifiedParts>[src]

impl<'a> From<KeyAmalgamation<'a, SecretParts, SubordinateRole, ()>> for SubordinateKeyAmalgamation<'a, PublicParts>[src]

impl<'a> From<KeyAmalgamation<'a, SecretParts, SubordinateRole, ()>> for SubordinateKeyAmalgamation<'a, UnspecifiedParts>[src]

impl<'a> From<KeyAmalgamation<'a, SecretParts, SubordinateRole, ()>> for ErasedKeyAmalgamation<'a, PublicParts>[src]

impl<'a> From<KeyAmalgamation<'a, SecretParts, SubordinateRole, ()>> for ErasedKeyAmalgamation<'a, UnspecifiedParts>[src]

impl<'a> From<KeyAmalgamation<'a, SecretParts, UnspecifiedRole, bool>> for ErasedKeyAmalgamation<'a, PublicParts>[src]

impl<'a> From<KeyAmalgamation<'a, SecretParts, UnspecifiedRole, bool>> for ErasedKeyAmalgamation<'a, UnspecifiedParts>[src]

impl<'a> From<KeyAmalgamation<'a, UnspecifiedParts, PrimaryRole, ()>> for PrimaryKeyAmalgamation<'a, PublicParts>[src]

impl<'a> From<KeyAmalgamation<'a, UnspecifiedParts, PrimaryRole, ()>> for ErasedKeyAmalgamation<'a, PublicParts>[src]

impl<'a> From<KeyAmalgamation<'a, UnspecifiedParts, SubordinateRole, ()>> for SubordinateKeyAmalgamation<'a, PublicParts>[src]

impl<'a> From<KeyAmalgamation<'a, UnspecifiedParts, SubordinateRole, ()>> for ErasedKeyAmalgamation<'a, PublicParts>[src]

impl<'a> From<KeyAmalgamation<'a, UnspecifiedParts, UnspecifiedRole, bool>> for ErasedKeyAmalgamation<'a, PublicParts>[src]

impl<'a, P, R, R2> From<ValidKeyAmalgamation<'a, P, R, R2>> for KeyAmalgamation<'a, P, R, R2> where
    P: 'a + KeyParts,
    R: 'a + KeyRole,
    R2: Copy
[src]

impl<'a> TryFrom<&'a KeyAmalgamation<'a, PublicParts, PrimaryRole, ()>> for &'a PrimaryKeyAmalgamation<'a, SecretParts>[src]

type Error = Error

The type returned in the event of a conversion error.

impl<'a> TryFrom<&'a KeyAmalgamation<'a, PublicParts, SubordinateRole, ()>> for &'a SubordinateKeyAmalgamation<'a, SecretParts>[src]

type Error = Error

The type returned in the event of a conversion error.

impl<'a> TryFrom<&'a KeyAmalgamation<'a, PublicParts, UnspecifiedRole, bool>> for &'a ErasedKeyAmalgamation<'a, SecretParts>[src]

type Error = Error

The type returned in the event of a conversion error.

impl<'a> TryFrom<&'a KeyAmalgamation<'a, UnspecifiedParts, PrimaryRole, ()>> for &'a PrimaryKeyAmalgamation<'a, SecretParts>[src]

type Error = Error

The type returned in the event of a conversion error.

impl<'a> TryFrom<&'a KeyAmalgamation<'a, UnspecifiedParts, SubordinateRole, ()>> for &'a SubordinateKeyAmalgamation<'a, SecretParts>[src]

type Error = Error

The type returned in the event of a conversion error.

impl<'a> TryFrom<&'a KeyAmalgamation<'a, UnspecifiedParts, UnspecifiedRole, bool>> for &'a ErasedKeyAmalgamation<'a, SecretParts>[src]

type Error = Error

The type returned in the event of a conversion error.

impl<'a, P, P2> TryFrom<KeyAmalgamation<'a, P, UnspecifiedRole, bool>> for PrimaryKeyAmalgamation<'a, P2> where
    P: 'a + KeyParts,
    P2: 'a + KeyParts
[src]

type Error = Error

The type returned in the event of a conversion error.

impl<'a, P, P2> TryFrom<KeyAmalgamation<'a, P, UnspecifiedRole, bool>> for SubordinateKeyAmalgamation<'a, P2> where
    P: 'a + KeyParts,
    P2: 'a + KeyParts
[src]

type Error = Error

The type returned in the event of a conversion error.

impl<'a> TryFrom<KeyAmalgamation<'a, PublicParts, PrimaryRole, ()>> for PrimaryKeyAmalgamation<'a, SecretParts>[src]

type Error = Error

The type returned in the event of a conversion error.

impl<'a> TryFrom<KeyAmalgamation<'a, PublicParts, SubordinateRole, ()>> for SubordinateKeyAmalgamation<'a, SecretParts>[src]

type Error = Error

The type returned in the event of a conversion error.

impl<'a> TryFrom<KeyAmalgamation<'a, PublicParts, UnspecifiedRole, bool>> for ErasedKeyAmalgamation<'a, SecretParts>[src]

type Error = Error

The type returned in the event of a conversion error.

impl<'a> TryFrom<KeyAmalgamation<'a, UnspecifiedParts, PrimaryRole, ()>> for PrimaryKeyAmalgamation<'a, SecretParts>[src]

type Error = Error

The type returned in the event of a conversion error.

impl<'a> TryFrom<KeyAmalgamation<'a, UnspecifiedParts, SubordinateRole, ()>> for SubordinateKeyAmalgamation<'a, SecretParts>[src]

type Error = Error

The type returned in the event of a conversion error.

impl<'a> TryFrom<KeyAmalgamation<'a, UnspecifiedParts, UnspecifiedRole, bool>> for ErasedKeyAmalgamation<'a, SecretParts>[src]

type Error = Error

The type returned in the event of a conversion error.

Auto Trait Implementations

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

impl<'a, P, R, R2> Send for KeyAmalgamation<'a, P, R, R2> where
    P: Sync,
    R: Sync,
    R2: Send

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

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

impl<'a, P, R, R2> UnwindSafe for KeyAmalgamation<'a, P, R, R2> where
    P: RefUnwindSafe,
    R: RefUnwindSafe,
    R2: 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> DynClone for T where
    T: Clone
[src]

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

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

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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.