summaryrefslogtreecommitdiffstats
path: root/openpgp/src/packet/userid.rs
diff options
context:
space:
mode:
authorNeal H. Walfield <neal@pep.foundation>2019-05-07 18:21:29 +0200
committerNeal H. Walfield <neal@pep.foundation>2019-05-08 14:48:53 +0200
commit0ad3263b1e28192b19e4588de37b848dedad801b (patch)
tree7fdb8ae91e41a37337e825f6b832678693b81df4 /openpgp/src/packet/userid.rs
parent25174eaaa28587c561cfab9421ded48b4e82ce15 (diff)
openpgp: Add a conversion from &[u8] to UserID
- User IDs don't need to be UTF-8 and at the lowest level we don't assume that they are.
Diffstat (limited to 'openpgp/src/packet/userid.rs')
-rw-r--r--openpgp/src/packet/userid.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/openpgp/src/packet/userid.rs b/openpgp/src/packet/userid.rs
index 1c8b3f84..3f0d88f0 100644
--- a/openpgp/src/packet/userid.rs
+++ b/openpgp/src/packet/userid.rs
@@ -41,6 +41,16 @@ impl From<Vec<u8>> for UserID {
}
}
+impl From<&[u8]> for UserID {
+ fn from(u: &[u8]) -> Self {
+ UserID {
+ common: Default::default(),
+ value: u.to_vec(),
+ parsed: RefCell::new(None),
+ }
+ }
+}
+
impl<'a> From<&'a str> for UserID {
fn from(u: &'a str) -> Self {
let b = u.as_bytes();