Struct sequoia_openpgp::types::KeyFlags [−][src]
pub struct KeyFlags(_);
Expand description
Describes how a key may be used, and stores additional information.
Key flags are described in Section 5.2.3.21 of RFC 4880 and Section 5.2.3.22 of RFC 4880bis.
A note on equality
PartialEq
compares the serialized form of the key flag sets. If
you prefer to compare two key flag sets for semantic equality, you
should use KeyFlags::normalized_eq
. The difference between
semantic equality and serialized equality is that semantic
equality ignores differences in the amount of padding.
Examples
use sequoia_openpgp as openpgp; use openpgp::cert::prelude::*; use openpgp::policy::StandardPolicy; let p = &StandardPolicy::new(); let (cert, _) = CertBuilder::new() .add_userid("Alice <alice@example.com>") .add_transport_encryption_subkey() .generate()?; for subkey in cert.with_policy(p, None)?.keys().subkeys() { // Key contains one Encryption subkey: assert!(subkey.key_flags().unwrap().for_transport_encryption()); }
Implementations
Compares two key flag sets for semantic equality.
KeyFlags
’ implementation of PartialEq
compares two key
flag sets for serialized equality. That is, the PartialEq
implementation considers two key flag sets to not be equal
if they have different amounts of padding. This comparison
function ignores padding.
Examples
use sequoia_openpgp as openpgp; use openpgp::types::KeyFlags; let a = KeyFlags::new(&[0x1]); let b = KeyFlags::new(&[0x1, 0x0]); assert!(a != b); assert!(a.normalized_eq(&b));
Returns whether the specified key flag is set.
Examples
use sequoia_openpgp as openpgp; use openpgp::types::KeyFlags; // Key flags 0 and 2. let kf = KeyFlags::new(&[0x5]); assert!(kf.get(0)); assert!(! kf.get(1)); assert!(kf.get(2)); assert!(! kf.get(3)); assert!(! kf.get(8)); assert!(! kf.get(80));
Sets the specified key flag.
This also clears any padding (trailing NUL bytes).
Examples
use sequoia_openpgp as openpgp; use openpgp::types::KeyFlags; let kf = KeyFlags::empty().set(0).set(2); assert!(kf.get(0)); assert!(! kf.get(1)); assert!(kf.get(2)); assert!(! kf.get(3));
Clears the specified key flag.
This also clears any padding (trailing NUL bytes).
Examples
use sequoia_openpgp as openpgp; use openpgp::types::KeyFlags; let kf = KeyFlags::empty().set(0).set(2).clear(2); assert!(kf.get(0)); assert!(! kf.get(1)); assert!(! kf.get(2)); assert!(! kf.get(3));
This key may be used to certify other keys.
Declares that this key may be used to certify other keys.
Declares that this key may not be used to certify other keys.
This key may be used to sign data.
Declares that this key may be used to sign data.
Declares that this key may not be used to sign data.
This key may be used to encrypt communications.
Declares that this key may be used to encrypt communications.
Declares that this key may not be used to encrypt communications.
This key may be used to encrypt storage.
Declares that this key may be used to encrypt storage.
Declares that this key may not be used to encrypt storage.
This key may be used for authentication.
Declares that this key may be used for authentication.
Declares that this key may not be used for authentication.
The private component of this key may have been split using a secret-sharing mechanism.
Declares that the private component of this key may have been split using a secret-sharing mechanism.
Declares that the private component of this key has not been split using a secret-sharing mechanism.
The private component of this key may be in possession of more than one person.
Declares that the private component of this key should not be in possession of more than one person.
Trait Implementations
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
Auto Trait Implementations
impl RefUnwindSafe for KeyFlags
impl UnwindSafe for KeyFlags
Blanket Implementations
Mutably borrows from an owned value. Read more
type Output = T
type Output = T
Should always be Self