diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2020-04-20 17:15:08 +0200 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2020-04-20 18:44:00 +0200 |
commit | bc4e1564ea816a66d1191fc310ac6d2b02d1a92f (patch) | |
tree | 4ee0e4ee0706fa9cedab061fef8cffbc549b0d62 /tool/src/sq.rs | |
parent | 15723e28cc6e18b0ca7a51212bbcd72fb0e40c72 (diff) |
openpgp: Add armor::Writer::with_headers.
- Add a new constructor that takes headers. This allows us to make
the header argument polymorphic.
Diffstat (limited to 'tool/src/sq.rs')
-rw-r--r-- | tool/src/sq.rs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/tool/src/sq.rs b/tool/src/sq.rs index 1d6c0a92..6d770e6d 100644 --- a/tool/src/sq.rs +++ b/tool/src/sq.rs @@ -93,12 +93,12 @@ impl<T: Write> From<openpgp::armor::Writer<T>> for Writer<T> { } impl<T: Write> Writer<T> { - pub fn armor(self, kind: openpgp::armor::Kind, headers: &[(&str, &str)]) + pub fn armor(self, kind: openpgp::armor::Kind, headers: Vec<(&str, &str)>) -> openpgp::Result<Self> { match self { Writer::Binary { inner } => - Ok(openpgp::armor::Writer::new(inner, kind, headers)? + Ok(openpgp::armor::Writer::with_headers(inner, kind, headers)? .into()), Writer::Armored { .. } => Err(openpgp::Error::InvalidOperation("already armored".into()) @@ -136,7 +136,7 @@ fn create_or_stdout_pgp(f: Option<&str>, force: bool, let sink = create_or_stdout(f, force)?; let mut sink = Writer::from(sink); if ! binary { - sink = sink.armor(kind, &[])?; + sink = sink.armor(kind, Vec::new())?; } Ok(sink) } @@ -178,9 +178,9 @@ fn serialize_keyring(mut output: &mut dyn io::Write, certs: &[Cert], binary: boo let headers: Vec<_> = headers.iter() .map(|value| ("Comment", value.as_str())) .collect(); - let mut output = armor::Writer::new(&mut output, - armor::Kind::PublicKey, - &headers)?; + let mut output = armor::Writer::with_headers(&mut output, + armor::Kind::PublicKey, + headers)?; for cert in certs { cert.serialize(&mut output)?; } |