add XMPPStream.send_stanza() convenience method
This commit is contained in:
parent
06b97ea228
commit
71e2b1c84f
4 changed files with 14 additions and 8 deletions
|
|
@ -1,10 +1,11 @@
|
|||
use futures::{Poll, Stream, Sink, StartSend};
|
||||
use futures::sink::Send;
|
||||
use tokio_io::{AsyncRead, AsyncWrite};
|
||||
use tokio_codec::Framed;
|
||||
use minidom::Element;
|
||||
use jid::Jid;
|
||||
|
||||
use xmpp_codec::XMPPCodec;
|
||||
use xmpp_codec::{XMPPCodec, Packet};
|
||||
use stream_start::StreamStart;
|
||||
|
||||
pub const NS_XMPP_STREAM: &str = "http://etherx.jabber.org/streams";
|
||||
|
|
@ -38,6 +39,13 @@ impl<S: AsyncRead + AsyncWrite> XMPPStream<S> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<S: AsyncWrite> XMPPStream<S> {
|
||||
/// Convenience method
|
||||
pub fn send_stanza<E: Into<Element>>(self, e: E) -> Send<Self> {
|
||||
self.send(Packet::Stanza(e.into()))
|
||||
}
|
||||
}
|
||||
|
||||
/// Proxy to self.stream
|
||||
impl<S: AsyncWrite> Sink for XMPPStream<S> {
|
||||
type SinkItem = <Framed<S, XMPPCodec> as Sink>::SinkItem;
|
||||
|
|
|
|||
Loading…
Reference in a new issue