summaryrefslogtreecommitdiffstats
path: root/openpgp/src/types/key_flags.rs
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2020-01-02 15:23:02 +0100
committerJustus Winter <justus@sequoia-pgp.org>2020-01-02 15:23:02 +0100
commit78f41e581af5d93718af68becebe3cbff8fed2d1 (patch)
tree821cb21c4d47891ec8b2144df9e0a737f614d058 /openpgp/src/types/key_flags.rs
parent5987c772b2681fd82cfb8c3974a5408f40474f5a (diff)
openpgp: Make KeyFlags::new polymorphic, improve KeyFlags::default.
Diffstat (limited to 'openpgp/src/types/key_flags.rs')
-rw-r--r--openpgp/src/types/key_flags.rs5
1 files changed, 3 insertions, 2 deletions
diff --git a/openpgp/src/types/key_flags.rs b/openpgp/src/types/key_flags.rs
index 51210c32..6b67288f 100644
--- a/openpgp/src/types/key_flags.rs
+++ b/openpgp/src/types/key_flags.rs
@@ -18,7 +18,7 @@ pub struct KeyFlags{
impl Default for KeyFlags {
fn default() -> Self {
- KeyFlags::new(&vec![0])
+ KeyFlags::new(&[])
}
}
@@ -124,7 +124,8 @@ impl BitOr for &KeyFlags {
impl KeyFlags {
/// Creates a new instance from `bits`.
- pub fn new(bits: &[u8]) -> Self {
+ pub fn new<B: AsRef<[u8]>>(bits: B) -> Self {
+ let bits = bits.as_ref();
let for_certification = bits.get(0)
.map(|x| x & KEY_FLAG_CERTIFY != 0).unwrap_or(false);
let for_signing = bits.get(0)