summaryrefslogtreecommitdiffstats
path: root/openpgp/src/packet/key_flags.rs
diff options
context:
space:
mode:
Diffstat (limited to 'openpgp/src/packet/key_flags.rs')
-rw-r--r--openpgp/src/packet/key_flags.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/openpgp/src/packet/key_flags.rs b/openpgp/src/packet/key_flags.rs
index 92dac82f..51f9e00d 100644
--- a/openpgp/src/packet/key_flags.rs
+++ b/openpgp/src/packet/key_flags.rs
@@ -156,6 +156,11 @@ impl KeyFlags {
}
}
+ /// Returns a new `KeyFlags` with all capabilities disabled.
+ pub fn empty() -> Self {
+ KeyFlags::default()
+ }
+
/// Returns a slice referencing the raw values.
pub(crate) fn as_vec(&self) -> Vec<u8> {
let mut ret = if self.unknown.is_empty() {
@@ -249,6 +254,11 @@ impl KeyFlags {
self.is_group_key = v;
self
}
+
+ /// Returns whether no flags are set.
+ pub fn is_empty(&self) -> bool {
+ self.as_vec().into_iter().all(|b| b == 0)
+ }
}
// Numeric key capability flags.