[−][src]Trait sequoia_openpgp::packet::key::KeyRole
A marker trait that captures a Key
's role.
A Key
can either be a primary key (key::PrimaryRole
) or a
subordinate key (key::SubordinateRole
). For those cases where
the type information needs to be erased (e.g., interfaces like
Cert::keys
), we provide the key::UnspecifiedRole
marker.
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
pub fn convert_key<P: KeyParts>(key: Key<P, UnspecifiedRole>) -> Key<P, Self> where
Self: Sized,
[src]
Self: Sized,
Converts a key with an unspecified role into this kind of key.
This function is helpful when you need to convert a concrete
type into a generic type. Using From
works, but requires
adding a type bound to the generic type, which is ugly and
invasive.
Examples
use sequoia_openpgp as openpgp; use openpgp::Result; use openpgp::packet::prelude::*; fn f<R>(cert: &Cert, mut key: Key<key::UnspecifiedParts, R>) -> Result<Key<key::UnspecifiedParts, R>> where R: key::KeyRole { // ... if criterium { // Cert::primary_key's return type is concrete // (Key<key::PublicParts, key::PrimaryRole>). We need to // convert it to the generic type Key<key::UnspecifiedParts, R>. // First, we "downcast" it to have unspecified parts and an // unspecified role, then we use a method defined by the // generic type to perform the conversion to the generic // type R. key = R::convert_key( cert.primary_key().key().clone() .parts_into_unspecified() .role_into_unspecified()); } // ... Ok(key) }
pub fn convert_key_ref<P: KeyParts>(
key: &Key<P, UnspecifiedRole>
) -> &Key<P, Self> where
Self: Sized,
[src]
key: &Key<P, UnspecifiedRole>
) -> &Key<P, Self> where
Self: Sized,
Converts a key reference with an unspecified role into this kind of key reference.
This function is helpful when you need to convert a concrete
type into a generic type. Using From
works, but requires
adding a type bound to the generic type, which is ugly and
invasive.
pub fn convert_bundle<P: KeyParts>(
bundle: KeyBundle<P, UnspecifiedRole>
) -> KeyBundle<P, Self> where
Self: Sized,
[src]
bundle: KeyBundle<P, UnspecifiedRole>
) -> KeyBundle<P, Self> where
Self: Sized,
Converts a key bundle with an unspecified role into this kind of key bundle.
This function is helpful when you need to convert a concrete
type into a generic type. Using From
works, but requires
adding a type bound to the generic type, which is ugly and
invasive.
pub fn convert_bundle_ref<P: KeyParts>(
bundle: &KeyBundle<P, UnspecifiedRole>
) -> &KeyBundle<P, Self> where
Self: Sized,
[src]
bundle: &KeyBundle<P, UnspecifiedRole>
) -> &KeyBundle<P, Self> where
Self: Sized,
Converts a key bundle reference with an unspecified role into this kind of key bundle reference.
This function is helpful when you need to convert a concrete
type into a generic type. Using From
works, but requires
adding a type bound to the generic type, which is ugly and
invasive.
Implementors
impl KeyRole for PrimaryRole
[src]
pub fn convert_key<P: KeyParts>(key: Key<P, UnspecifiedRole>) -> Key<P, Self>
[src]
pub fn convert_key_ref<P: KeyParts>(
key: &Key<P, UnspecifiedRole>
) -> &Key<P, Self>
[src]
key: &Key<P, UnspecifiedRole>
) -> &Key<P, Self>
pub fn convert_bundle<P: KeyParts>(
bundle: KeyBundle<P, UnspecifiedRole>
) -> KeyBundle<P, Self>
[src]
bundle: KeyBundle<P, UnspecifiedRole>
) -> KeyBundle<P, Self>
pub fn convert_bundle_ref<P: KeyParts>(
bundle: &KeyBundle<P, UnspecifiedRole>
) -> &KeyBundle<P, Self>
[src]
bundle: &KeyBundle<P, UnspecifiedRole>
) -> &KeyBundle<P, Self>
impl KeyRole for SubordinateRole
[src]
pub fn convert_key<P: KeyParts>(key: Key<P, UnspecifiedRole>) -> Key<P, Self>
[src]
pub fn convert_key_ref<P: KeyParts>(
key: &Key<P, UnspecifiedRole>
) -> &Key<P, Self>
[src]
key: &Key<P, UnspecifiedRole>
) -> &Key<P, Self>
pub fn convert_bundle<P: KeyParts>(
bundle: KeyBundle<P, UnspecifiedRole>
) -> KeyBundle<P, Self>
[src]
bundle: KeyBundle<P, UnspecifiedRole>
) -> KeyBundle<P, Self>
pub fn convert_bundle_ref<P: KeyParts>(
bundle: &KeyBundle<P, UnspecifiedRole>
) -> &KeyBundle<P, Self>
[src]
bundle: &KeyBundle<P, UnspecifiedRole>
) -> &KeyBundle<P, Self>
impl KeyRole for UnspecifiedRole
[src]
pub fn convert_key<P: KeyParts>(key: Key<P, UnspecifiedRole>) -> Key<P, Self>
[src]
pub fn convert_key_ref<P: KeyParts>(
key: &Key<P, UnspecifiedRole>
) -> &Key<P, Self>
[src]
key: &Key<P, UnspecifiedRole>
) -> &Key<P, Self>
pub fn convert_bundle<P: KeyParts>(
bundle: KeyBundle<P, UnspecifiedRole>
) -> KeyBundle<P, Self>
[src]
bundle: KeyBundle<P, UnspecifiedRole>
) -> KeyBundle<P, Self>
pub fn convert_bundle_ref<P: KeyParts>(
bundle: &KeyBundle<P, UnspecifiedRole>
) -> &KeyBundle<P, Self>
[src]
bundle: &KeyBundle<P, UnspecifiedRole>
) -> &KeyBundle<P, Self>