summaryrefslogtreecommitdiffstats
path: root/openpgp/examples/encrypt-for.rs
diff options
context:
space:
mode:
Diffstat (limited to 'openpgp/examples/encrypt-for.rs')
-rw-r--r--openpgp/examples/encrypt-for.rs17
1 files changed, 8 insertions, 9 deletions
diff --git a/openpgp/examples/encrypt-for.rs b/openpgp/examples/encrypt-for.rs
index 28f63934..958c2095 100644
--- a/openpgp/examples/encrypt-for.rs
+++ b/openpgp/examples/encrypt-for.rs
@@ -7,7 +7,8 @@ use std::io;
use anyhow::Context;
extern crate sequoia_openpgp as openpgp;
-use crate::openpgp::armor;
+
+use crate::openpgp::serialize::stream::Armorer;
use crate::openpgp::types::KeyFlags;
use crate::openpgp::parse::Parse;
use crate::openpgp::serialize::stream::{
@@ -47,14 +48,16 @@ fn main() -> openpgp::Result<()> {
});
// Compose a writer stack corresponding to the output format and
- // packet structure we want. First, we want the output to be
- // ASCII armored.
- let mut sink = armor::Writer::new(io::stdout(), armor::Kind::Message)
- .context("Failed to create an armored writer")?;
+ // packet structure we want.
+ let mut sink = io::stdout();
// Stream an OpenPGP message.
let message = Message::new(&mut sink);
+ let message = Armorer::new(message)
+ // Customize the `Armorer` here.
+ .build()?;
+
// We want to encrypt a literal data packet.
let encryptor = Encryptor::for_recipients(message, recipients)
.build().context("Failed to create encryptor")?;
@@ -70,9 +73,5 @@ fn main() -> openpgp::Result<()> {
// writer stack.
literal_writer.finalize()?;
- // Finalize the armor writer.
- sink.finalize()
- .context("Failed to write data")?;
-
Ok(())
}