Trait sequoia_openpgp::cert::amalgamation::key::PrimaryKey

source ·
pub trait PrimaryKey<'a, P, R>: Sealed
where P: 'a + KeyParts, R: 'a + KeyRole,
{ // Required method fn primary(&self) -> bool; }
Expand description

Whether the key is a primary key.

This trait is an implementation detail. It exists so that we can have a blanket implementation of ValidAmalgamation for ValidKeyAmalgamation, for instance, even though we only have specialized implementations of PrimaryKey.

§Sealed trait

This trait is sealed and cannot be implemented for types outside this crate. Therefore it can be extended in a non-breaking way. If you want to implement the trait inside the crate you also need to implement the seal::Sealed marker trait.

Required Methods§

source

fn primary(&self) -> bool

Returns whether the key amalgamation is a primary key amalgamation.

§Examples
// This works if the type is concrete:
let ka: PrimaryKeyAmalgamation<_> = cert.primary_key();
assert!(ka.primary());

// Or if it has been erased:
for (i, ka) in cert.keys().enumerate() {
    let ka: ErasedKeyAmalgamation<_> = ka;
    if i == 0 {
        // The primary key is always the first key returned by
        // `Cert::keys`.
        assert!(ka.primary());
    } else {
        // The rest are subkeys.
        assert!(! ka.primary());
    }
}

Implementors§

source§

impl<'a, P> PrimaryKey<'a, P, PrimaryRole> for PrimaryKeyAmalgamation<'a, P>
where P: 'a + KeyParts,

source§

impl<'a, P> PrimaryKey<'a, P, PrimaryRole> for ValidPrimaryKeyAmalgamation<'a, P>
where P: 'a + KeyParts,

source§

impl<'a, P> PrimaryKey<'a, P, SubordinateRole> for SubordinateKeyAmalgamation<'a, P>
where P: 'a + KeyParts,

source§

impl<'a, P> PrimaryKey<'a, P, SubordinateRole> for ValidSubordinateKeyAmalgamation<'a, P>
where P: 'a + KeyParts,

source§

impl<'a, P> PrimaryKey<'a, P, UnspecifiedRole> for ErasedKeyAmalgamation<'a, P>
where P: 'a + KeyParts,

source§

impl<'a, P> PrimaryKey<'a, P, UnspecifiedRole> for ValidErasedKeyAmalgamation<'a, P>
where P: 'a + KeyParts,