xmlstream: add support for boxing the transport
This is useful in situations where we don't want to care about the specific type of the underlying transport.
This commit is contained in:
parent
2388f23b4e
commit
519718d9b5
2 changed files with 44 additions and 0 deletions
|
|
@ -70,6 +70,8 @@ use tokio::io::{AsyncBufRead, AsyncWrite};
|
|||
|
||||
use xso::{AsXml, FromXml, Item};
|
||||
|
||||
use crate::connect::AsyncReadAndWrite;
|
||||
|
||||
mod capture;
|
||||
mod common;
|
||||
mod initiator;
|
||||
|
|
@ -337,6 +339,21 @@ impl<Io: AsyncBufRead + AsyncWrite + Unpin, T: FromXml + AsXml + fmt::Debug> Xml
|
|||
self.assert_retypable();
|
||||
self.inner.into_inner()
|
||||
}
|
||||
|
||||
/// Box the underlying transport stream.
|
||||
///
|
||||
/// This removes the specific type of the transport from the XML stream's
|
||||
/// type signature.
|
||||
pub fn box_stream(self) -> XmlStream<Box<dyn AsyncReadAndWrite + Send + 'static>, T>
|
||||
where
|
||||
Io: AsyncReadAndWrite + Send + 'static,
|
||||
{
|
||||
XmlStream {
|
||||
inner: self.inner.box_stream(),
|
||||
read_state: self.read_state,
|
||||
write_state: self.write_state,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<Io: AsyncBufRead, T: FromXml + AsXml + fmt::Debug> Stream for XmlStream<Io, T> {
|
||||
|
|
|
|||
Loading…
Reference in a new issue