diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2018-07-04 14:36:42 +0200 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2018-07-04 14:39:49 +0200 |
commit | 415e46bdcbb95d5ac1ba9c93177c610fa64ba35f (patch) | |
tree | 19004dbbb36706ed7149f224c1cb97b89feb8533 | |
parent | 222016e57c31135315d643c36c9328271c3bf19c (diff) |
openpgp: Add a new way to wrap writers for streaming serialization.
- Implement `From<'a mut io::Write>` for the writer stack. While
this may be neat in some situations, if you have a concrete
writer `sink`, you need to do some acrobatics to use it, e.g.:
Signer::new((&mut sink as &mut io::Write).into(), ...)
-rw-r--r-- | openpgp/src/serialize/stream.rs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/openpgp/src/serialize/stream.rs b/openpgp/src/serialize/stream.rs index ec605c0a..93809b7b 100644 --- a/openpgp/src/serialize/stream.rs +++ b/openpgp/src/serialize/stream.rs @@ -65,6 +65,13 @@ pub fn wrap<'a, W: 'a + io::Write>(w: W) -> writer::Stack<'a, Cookie> { } +impl<'a> From<&'a mut io::Write> for writer::Stack<'a, Cookie> { + fn from(w: &'a mut io::Write) -> Self { + writer::Generic::new(w, Cookie::new(0)) + } +} + + /// Writes an arbitrary packet. /// /// This writer can be used to construct arbitrary OpenPGP packets. |