[−][src]Struct sequoia_openpgp::cert::amalgamation::ValidComponentAmalgamation
A ComponentAmalgamation
plus a Policy
and a reference time.
A ValidComponentAmalgamation
combines a
ComponentAmalgamation
with a Policy
and a reference time.
This allows it to implement the ValidAmalgamation
trait, which
provides methods that require a Policy
and a reference time.
Although ComponentAmalgamation
could implement these methods by
requiring that the caller explicitly pass them in, embedding them
in the ValidComponentAmalgamation
helps ensure that multipart
operations, even those that span multiple functions, use the same
Policy
and reference time.
A ValidComponentAmalgamation
is typically obtained by
transforming a ComponentAmalgamation
using
ValidateAmalgamation::with_policy
. A
ComponentAmalgamationIter
can also be changed to yield
ValidComponentAmalgamation
s.
A ValidComponentAmalgamation
is guaranteed to come from a valid
certificate, and have a valid and live binding signature at the
specified reference time. Note: this only means that the binding
signatures are live; it says nothing about whether the
certificate is live. If you care about that, then you need to
check it separately.
Examples
Print out information about all non-revoked User IDs.
use openpgp::cert::prelude::*; use openpgp::packet::prelude::*; use openpgp::policy::StandardPolicy; use openpgp::types::RevocationStatus; let p = &StandardPolicy::new(); for u in cert.userids() { // Create a `ValidComponentAmalgamation`. This may fail if // there are no binding signatures that are accepted by the // policy and that are live right now. let u = u.with_policy(p, None)?; // Before using the User ID, we still need to check that it is // not revoked; `ComponentAmalgamation::with_policy` ensures // that there is a valid *binding signature*, not that the // `ComponentAmalgamation` is valid. // // Note: `ValidComponentAmalgamation::revocation_status` and // `Preferences::preferred_symmetric_algorithms` use the // embedded policy and timestamp. Even though we used `None` for // the timestamp (i.e., now), they are guaranteed to use the same // timestamp, because `with_policy` eagerly transforms it into // the current time. // // Note: we only check whether the User ID is not revoked. If // we were using a key, we'd also want to check that it is alive. // (Keys can expire, but User IDs cannot.) if let RevocationStatus::Revoked(_revs) = u.revocation_status() { // Revoked by the key owner. (If we care about // designated revokers, then we need to check those // ourselves.) } else { // Print information about the User ID. eprintln!("{}: preferred symmetric algorithms: {:?}", String::from_utf8_lossy(u.value()), u.preferred_symmetric_algorithms()); } }
Implementations
impl<'a, C> ValidComponentAmalgamation<'a, C> where
C: Ord + Send + Sync,
[src]
C: Ord + Send + Sync,
pub fn self_signatures(&self) -> impl Iterator<Item = &Signature> + Send + Sync
[src]
The component's self-signatures.
This method only returns signatures that are valid under the current policy.
pub fn certifications(&self) -> impl Iterator<Item = &Signature> + Send + Sync
[src]
The component's third-party certifications.
This method only returns signatures that are valid under the current policy.
pub fn self_revocations(&self) -> impl Iterator<Item = &Signature> + Send + Sync
[src]
The component's revocations that were issued by the certificate holder.
This method only returns signatures that are valid under the current policy.
pub fn other_revocations(
&self
) -> impl Iterator<Item = &Signature> + Send + Sync
[src]
&self
) -> impl Iterator<Item = &Signature> + Send + Sync
The component's revocations that were issued by other certificates.
This method only returns signatures that are valid under the current policy.
Methods from Deref<Target = ComponentAmalgamation<'a, C>>
pub fn parts_as_public(
&'a self
) -> &'a ComponentAmalgamation<'a, Key<PublicParts, R>>
[src]
&'a self
) -> &'a ComponentAmalgamation<'a, Key<PublicParts, R>>
Changes the key's parts tag to PublicParts
.
pub fn parts_as_secret(
&'a self
) -> Result<&'a ComponentAmalgamation<'a, Key<SecretParts, R>>>
[src]
&'a self
) -> Result<&'a ComponentAmalgamation<'a, Key<SecretParts, R>>>
Changes the key's parts tag to SecretParts
.
pub fn parts_as_unspecified(
&'a self
) -> &ComponentAmalgamation<'a, Key<UnspecifiedParts, R>>
[src]
&'a self
) -> &ComponentAmalgamation<'a, Key<UnspecifiedParts, R>>
Changes the key's parts tag to UnspecifiedParts
.
pub fn role_as_primary(
&'a self
) -> &'a ComponentAmalgamation<'a, Key<P, PrimaryRole>>
[src]
&'a self
) -> &'a ComponentAmalgamation<'a, Key<P, PrimaryRole>>
Changes the key's role tag to PrimaryRole
.
pub fn role_as_subordinate(
&'a self
) -> &'a ComponentAmalgamation<'a, Key<P, SubordinateRole>>
[src]
&'a self
) -> &'a ComponentAmalgamation<'a, Key<P, SubordinateRole>>
Changes the key's role tag to SubordinateRole
.
pub fn role_as_unspecified(
&'a self
) -> &'a ComponentAmalgamation<'a, Key<P, UnspecifiedRole>>
[src]
&'a self
) -> &'a ComponentAmalgamation<'a, Key<P, UnspecifiedRole>>
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 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, C> Clone for ValidComponentAmalgamation<'a, C>
[src]
pub fn clone(&self) -> Self
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<'a, C: Debug> Debug for ValidComponentAmalgamation<'a, C>
[src]
impl<'a, C> Deref for ValidComponentAmalgamation<'a, C>
[src]
type Target = ComponentAmalgamation<'a, C>
The resulting type after dereferencing.
pub fn deref(&self) -> &Self::Target
[src]
impl<'a, C: 'a> From<ValidComponentAmalgamation<'a, C>> for ComponentAmalgamation<'a, C>
[src]
pub fn from(vca: ValidComponentAmalgamation<'a, C>) -> Self
[src]
impl<'a, C> Preferences<'a> for ValidComponentAmalgamation<'a, C>
[src]
pub fn preferred_symmetric_algorithms(&self) -> Option<&'a [SymmetricAlgorithm]>
[src]
pub fn preferred_hash_algorithms(&self) -> Option<&'a [HashAlgorithm]>
[src]
pub fn preferred_compression_algorithms(
&self
) -> Option<&'a [CompressionAlgorithm]>
[src]
&self
) -> Option<&'a [CompressionAlgorithm]>
pub fn preferred_aead_algorithms(&self) -> Option<&'a [AEADAlgorithm]>
[src]
pub fn key_server_preferences(&self) -> Option<KeyServerPreferences>
[src]
pub fn preferred_key_server(&self) -> Option<&'a [u8]>
[src]
pub fn features(&self) -> Option<Features>
[src]
impl<'a, C> ValidAmalgamation<'a, C> for ValidComponentAmalgamation<'a, C>
[src]
pub fn cert(&self) -> &ValidCert<'a>
[src]
pub fn time(&self) -> SystemTime
[src]
pub fn policy(&self) -> &'a dyn Policy
[src]
pub fn binding_signature(&self) -> &'a Signature
[src]
pub fn revocation_status(&self) -> RevocationStatus<'a>
[src]
pub fn map<F: Fn(&'a Signature) -> Option<T>, T>(&self, f: F) -> Option<T>
[src]
pub fn direct_key_signature(&self) -> Result<&'a Signature>
[src]
impl<'a, C> ValidateAmalgamation<'a, C> for ValidComponentAmalgamation<'a, C>
[src]
Auto Trait Implementations
impl<'a, C> !RefUnwindSafe for ValidComponentAmalgamation<'a, C>
impl<'a, C> Send for ValidComponentAmalgamation<'a, C> where
C: Sync,
C: Sync,
impl<'a, C> Sync for ValidComponentAmalgamation<'a, C> where
C: Sync,
C: Sync,
impl<'a, C> Unpin for ValidComponentAmalgamation<'a, C>
impl<'a, C> !UnwindSafe for ValidComponentAmalgamation<'a, C>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DynClone for T where
T: Clone,
[src]
T: Clone,
pub fn __clone_box(&self, Private) -> *mut ()
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,