mirror of
https://gitlab.com/xmpp-rs/xmpp-rs.git
synced 2024-07-12 22:21:53 +00:00
add stream resetting to the transport
This commit is contained in:
parent
a94c66cabc
commit
ad3a26fe2d
1 changed files with 13 additions and 0 deletions
|
@ -23,6 +23,8 @@ pub trait Transport {
|
||||||
|
|
||||||
fn write_element(&mut self, element: &minidom::Element) -> Result<(), Error>;
|
fn write_element(&mut self, element: &minidom::Element) -> Result<(), Error>;
|
||||||
fn read_element(&mut self) -> Result<minidom::Element, Error>;
|
fn read_element(&mut self) -> Result<minidom::Element, Error>;
|
||||||
|
|
||||||
|
fn reset_stream(&mut self);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct SslTransport {
|
pub struct SslTransport {
|
||||||
|
@ -49,6 +51,17 @@ impl Transport for SslTransport {
|
||||||
fn read_element(&mut self) -> Result<minidom::Element, Error> {
|
fn read_element(&mut self) -> Result<minidom::Element, Error> {
|
||||||
Ok(minidom::Element::from_reader(&mut self.reader)?)
|
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 {
|
impl SslTransport {
|
||||||
|
|
Loading…
Reference in a new issue