From 415e46bdcbb95d5ac1ba9c93177c610fa64ba35f Mon Sep 17 00:00:00 2001 From: Justus Winter Date: Wed, 4 Jul 2018 14:36:42 +0200 Subject: 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(), ...) --- openpgp/src/serialize/stream.rs | 7 +++++++ 1 file changed, 7 insertions(+) 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. -- cgit v1.2.3