summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2019-02-06 12:30:27 +0100
committerJustus Winter <justus@sequoia-pgp.org>2019-02-06 12:30:27 +0100
commitd6f553a2f3063d2995fbd91ed137cc876d7ecdc0 (patch)
treed191406c8d326ff15ae933b7985239c08fca3692 /examples
parent35b03999024955f68008d9ef5287cff753ed178b (diff)
openpgp: Remove the armored! macro.
- The packet parser now digests armored data, so there is no need to use this even in examples or tests, just use the appropriate .from_bytes(..) function. - Fixes #169.
Diffstat (limited to 'examples')
-rw-r--r--examples/guide-exploring-openpgp.rs12
-rw-r--r--examples/guide-getting-started.rs8
-rw-r--r--examples/guide-the-keystore.rs10
3 files changed, 12 insertions, 18 deletions
diff --git a/examples/guide-exploring-openpgp.rs b/examples/guide-exploring-openpgp.rs
index 66b95588..409475ef 100644
--- a/examples/guide-exploring-openpgp.rs
+++ b/examples/guide-exploring-openpgp.rs
@@ -1,12 +1,11 @@
//! https://sequoia-pgp.org/guide/exploring-openpgp/
-#[macro_use] // For armored!
extern crate sequoia_openpgp as openpgp;
use openpgp::parse::Parse;
fn main() {
- let mut reader = armored!(
- "-----BEGIN PGP PUBLIC KEY BLOCK-----
+ let tpk =
+ b"-----BEGIN PGP PUBLIC KEY BLOCK-----
mQENBFpxtsABCADZcBa1Q3ZLZnju18o0+t8LoQuIIeyeUQ0H45y6xUqyrD5HSkVM
VGQs6IHLq70mAizBJ4VznUVqVOh/NhOlapXi6/TKpjHvttdg45o6Pgqa0Kx64luT
@@ -35,11 +34,10 @@ fn main() {
bGeT3KvlJlH5kthQ9shsmT14gYwGMR6rKpNUXmlpetkjqUK7pGVaHGgJWUZ9QPGU
awwPdWWvZSyXJAPZ9lC5sTKwMJDwIxILug==
=lAie
- -----END PGP PUBLIC KEY BLOCK-----"
- );
+ -----END PGP PUBLIC KEY BLOCK-----";
- // Parse message.
- let pile = openpgp::PacketPile::from_reader(&mut reader).unwrap();
+ // Parse the TPK.
+ let pile = openpgp::PacketPile::from_bytes(tpk).unwrap();
// Iterate over children.
for (i, p) in pile.children().enumerate() {
diff --git a/examples/guide-getting-started.rs b/examples/guide-getting-started.rs
index 940f9032..28be8a41 100644
--- a/examples/guide-getting-started.rs
+++ b/examples/guide-getting-started.rs
@@ -1,17 +1,15 @@
//! https://sequoia-pgp.org/guide/getting-started/
-#[macro_use] // For armored!
extern crate sequoia_openpgp as openpgp;
use std::io;
fn main() {
- let mut reader = armored!(
- "-----BEGIN PGP ARMORED FILE-----
+ let mut reader = openpgp::armor::Reader::from_bytes(
+ b"-----BEGIN PGP ARMORED FILE-----
SGVsbG8gd29ybGQhCg==
=XLsG
- -----END PGP ARMORED FILE-----"
- );
+ -----END PGP ARMORED FILE-----", None);
io::copy(&mut reader, &mut io::stdout()).unwrap();
}
diff --git a/examples/guide-the-keystore.rs b/examples/guide-the-keystore.rs
index dac57c85..b4c5b15b 100644
--- a/examples/guide-the-keystore.rs
+++ b/examples/guide-the-keystore.rs
@@ -1,14 +1,13 @@
//! https://sequoia-pgp.org/guide/the-keystore/
-#[macro_use] // For armored!
extern crate sequoia_openpgp as openpgp;
extern crate sequoia;
use sequoia::{core, store};
use openpgp::parse::Parse;
fn main() {
- let mut reader = armored!(
- "-----BEGIN PGP PUBLIC KEY BLOCK-----
+ let tpk =
+ b"-----BEGIN PGP PUBLIC KEY BLOCK-----
mQENBFpxtsABCADZcBa1Q3ZLZnju18o0+t8LoQuIIeyeUQ0H45y6xUqyrD5HSkVM
VGQs6IHLq70mAizBJ4VznUVqVOh/NhOlapXi6/TKpjHvttdg45o6Pgqa0Kx64luT
@@ -37,14 +36,13 @@ fn main() {
bGeT3KvlJlH5kthQ9shsmT14gYwGMR6rKpNUXmlpetkjqUK7pGVaHGgJWUZ9QPGU
awwPdWWvZSyXJAPZ9lC5sTKwMJDwIxILug==
=lAie
- -----END PGP PUBLIC KEY BLOCK-----"
- );
+ -----END PGP PUBLIC KEY BLOCK-----";
// Provide some context.
let ctx = core::Context::new("org.sequoia-pgp.guide").unwrap();
// Parse TPK.
- let tpk = openpgp::TPK::from_reader(&mut reader).unwrap();
+ let tpk = openpgp::TPK::from_bytes(tpk).unwrap();
// Open a store.
let store = store::Store::open(&ctx, "default").unwrap();