summaryrefslogtreecommitdiffstats
path: root/store
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2019-09-11 16:12:21 +0200
committerJustus Winter <justus@sequoia-pgp.org>2019-09-18 13:08:08 +0200
commit446dfdbcb63af00daa3a777958419e1dfb6fc737 (patch)
treea5bbe4244083d9a467ab8d86be762fb67bd0054e /store
parent130eed7cda9f77502bbb181bfabb45934af46a8d (diff)
openpgp: Make Parse::from_bytes polymorphic over AsRef<[u8]>.
- A drawback of this change is that currently AsRef<[u8]> is not implemented for [u8; _], only for specific lengths. This is a compiler limitation that may be lifted in the future. This limitation required fixing some tests, notably those using include_bytes!. - Fixes #296.
Diffstat (limited to 'store')
-rw-r--r--store/src/lib.rs28
1 files changed, 14 insertions, 14 deletions
diff --git a/store/src/lib.rs b/store/src/lib.rs
index 9e710a9b..59e73063 100644
--- a/store/src/lib.rs
+++ b/store/src/lib.rs
@@ -157,7 +157,7 @@ impl Store {
/// # .ipc_policy(IPCPolicy::Internal)
/// # .ephemeral().build()?;
/// # let tpk = TPK::from_bytes(
- /// # include_bytes!("../../openpgp/tests/data/keys/testy.pgp")).unwrap();
+ /// # &include_bytes!("../../openpgp/tests/data/keys/testy.pgp")[..]).unwrap();
/// let key = Store::import(&ctx, &tpk)?;
/// assert_eq!(key.tpk()?.fingerprint(), tpk.fingerprint());
/// # Ok(())
@@ -193,7 +193,7 @@ impl Store {
/// # .ipc_policy(IPCPolicy::Internal)
/// # .ephemeral().build()?;
/// # let tpk = TPK::from_bytes(
- /// # include_bytes!("../../openpgp/tests/data/keys/testy.pgp")).unwrap();
+ /// # &include_bytes!("../../openpgp/tests/data/keys/testy.pgp")[..]).unwrap();
/// Store::import(&ctx, &tpk)?;
/// let key = Store::lookup(&ctx, &tpk.fingerprint())?;
/// assert_eq!(key.tpk()?.fingerprint(), tpk.fingerprint());
@@ -228,7 +228,7 @@ impl Store {
/// # .ipc_policy(IPCPolicy::Internal)
/// # .ephemeral().build()?;
/// # let tpk = TPK::from_bytes(
- /// # include_bytes!("../../openpgp/tests/data/keys/testy.pgp")).unwrap();
+ /// # &include_bytes!("../../openpgp/tests/data/keys/testy.pgp")[..]).unwrap();
/// Store::import(&ctx, &tpk)?;
/// let key = Store::lookup_by_keyid(&ctx, &tpk.fingerprint().to_keyid())?;
/// assert_eq!(key.tpk()?.fingerprint(), tpk.fingerprint());
@@ -264,7 +264,7 @@ impl Store {
/// # .ipc_policy(IPCPolicy::Internal)
/// # .ephemeral().build()?;
/// # let tpk = TPK::from_bytes(
- /// # include_bytes!("../../openpgp/tests/data/keys/neal.pgp"))
+ /// # &include_bytes!("../../openpgp/tests/data/keys/neal.pgp")[..])
/// # .unwrap();
/// Store::import(&ctx, &tpk)?;
///
@@ -412,7 +412,7 @@ impl Mapping {
/// # .ipc_policy(IPCPolicy::Internal)
/// # .ephemeral().build()?;
/// # let tpk = TPK::from_bytes(
- /// # include_bytes!("../../openpgp/tests/data/keys/testy.pgp")).unwrap();
+ /// # &include_bytes!("../../openpgp/tests/data/keys/testy.pgp")[..]).unwrap();
/// let mapping = Mapping::open(&ctx, REALM_CONTACTS, "default")?;
/// mapping.import("Testy McTestface", &tpk)?;
/// # Ok(())
@@ -483,7 +483,7 @@ impl Mapping {
/// # .ipc_policy(IPCPolicy::Internal)
/// # .ephemeral().build()?;
/// # let tpk = TPK::from_bytes(
- /// # include_bytes!("../../openpgp/tests/data/keys/emmelie-dorothea-dina-samantha-awina-ed25519.pgp"))
+ /// # &include_bytes!("../../openpgp/tests/data/keys/emmelie-dorothea-dina-samantha-awina-ed25519.pgp")[..])
/// # .unwrap();
/// let mapping = Mapping::open(&ctx, REALM_CONTACTS, "default")?;
/// mapping.import("Emmelie", &tpk)?;
@@ -683,9 +683,9 @@ impl Binding {
/// # .ipc_policy(IPCPolicy::Internal)
/// # .ephemeral().build()?;
/// # let old = TPK::from_bytes(
- /// # include_bytes!("../../openpgp/tests/data/keys/testy.pgp")).unwrap();
+ /// # &include_bytes!("../../openpgp/tests/data/keys/testy.pgp")[..]).unwrap();
/// # let new = TPK::from_bytes(
- /// # include_bytes!("../../openpgp/tests/data/keys/testy-new.pgp")).unwrap();
+ /// # &include_bytes!("../../openpgp/tests/data/keys/testy-new.pgp")[..]).unwrap();
/// let mapping = Mapping::open(&ctx, REALM_CONTACTS, "default")?;
/// mapping.import("Testy McTestface", &old)?;
/// // later...
@@ -738,9 +738,9 @@ impl Binding {
/// # .ipc_policy(IPCPolicy::Internal)
/// # .ephemeral().build()?;
/// # let old = TPK::from_bytes(
- /// # include_bytes!("../../openpgp/tests/data/keys/testy.pgp")).unwrap();
+ /// # &include_bytes!("../../openpgp/tests/data/keys/testy.pgp")[..]).unwrap();
/// # let new = TPK::from_bytes(
- /// # include_bytes!("../../openpgp/tests/data/keys/testy-new.pgp")).unwrap();
+ /// # &include_bytes!("../../openpgp/tests/data/keys/testy-new.pgp")[..]).unwrap();
/// let mapping = Mapping::open(&ctx, REALM_CONTACTS, "default")?;
/// mapping.import("Testy McTestface", &old)?;
/// // later...
@@ -890,9 +890,9 @@ impl Key {
/// # .ipc_policy(IPCPolicy::Internal)
/// # .ephemeral().build()?;
/// # let old = TPK::from_bytes(
- /// # include_bytes!("../../openpgp/tests/data/keys/testy.pgp")).unwrap();
+ /// # &include_bytes!("../../openpgp/tests/data/keys/testy.pgp")[..]).unwrap();
/// # let new = TPK::from_bytes(
- /// # include_bytes!("../../openpgp/tests/data/keys/testy-new.pgp")).unwrap();
+ /// # &include_bytes!("../../openpgp/tests/data/keys/testy-new.pgp")[..]).unwrap();
/// let mapping = Mapping::open(&ctx, REALM_CONTACTS, "default")?;
/// let fp = Fingerprint::from_hex("3E8877C877274692975189F5D03F6F865226FE8B").unwrap();
/// let binding = mapping.add("Testy McTestface", &fp)?;
@@ -1267,7 +1267,7 @@ mod test {
.ipc_policy(core::IPCPolicy::Internal)
.build().unwrap();
let mapping = Mapping::open(&ctx, REALM_CONTACTS, "default").unwrap();
- let tpk = TPK::from_bytes(bytes!("testy.pgp")).unwrap();
+ let tpk = TPK::from_bytes(&bytes!("testy.pgp")[..]).unwrap();
mapping.import("Mr. McTestface", &tpk).unwrap();
let binding = mapping.lookup("Mr. McTestface").unwrap();
let tpk_retrieved = binding.tpk().unwrap();
@@ -1295,7 +1295,7 @@ mod test {
.ipc_policy(core::IPCPolicy::Internal)
.build().unwrap();
let mapping = Mapping::open(&ctx, REALM_CONTACTS, "default").unwrap();
- let tpk = TPK::from_bytes(bytes!("testy.pgp")).unwrap();
+ let tpk = TPK::from_bytes(&bytes!("testy.pgp")[..]).unwrap();
let fp = Fingerprint::from_bytes(b"bbbbbbbbbbbbbbbbbbbb");
let binding = mapping.add("Mister B.", &fp).unwrap();
let r = binding.import(&tpk);