From ad3a26fe2d096e77f001ea00b51174475dd7cbed Mon Sep 17 00:00:00 2001 From: lumi Date: Mon, 20 Feb 2017 02:05:36 +0100 Subject: [PATCH] add stream resetting to the transport --- src/transport.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/transport.rs b/src/transport.rs index 289b6d62..f0506564 100644 --- a/src/transport.rs +++ b/src/transport.rs @@ -23,6 +23,8 @@ pub trait Transport { fn write_element(&mut self, element: &minidom::Element) -> Result<(), Error>; fn read_element(&mut self) -> Result; + + fn reset_stream(&mut self); } pub struct SslTransport { @@ -49,6 +51,17 @@ impl Transport for SslTransport { fn read_element(&mut self) -> Result { Ok(minidom::Element::from_reader(&mut self.reader)?) } + + fn reset_stream(&mut self) { + let locked_io = LockedIO::from(self.inner.clone()); + self.reader = EventReader::new(locked_io.clone()); + self.writer = EventWriter::new_with_config(locked_io, EmitterConfig { + line_separator: "".into(), + perform_indent: false, + normalize_empty_elements: false, + .. Default::default() + }); + } } impl SslTransport {