client: switch SinkItem to Packet

this breaks backwards compatibility
This commit is contained in:
Astro 2019-01-29 01:52:07 +01:00
commit 2654722fa3
3 changed files with 10 additions and 20 deletions

View file

@ -1,6 +1,6 @@
use futures::{done, Async, AsyncSink, Future, Poll, Sink, StartSend, Stream};
use idna;
use xmpp_parsers::{Jid, JidParseError, Element};
use xmpp_parsers::{Jid, JidParseError};
use sasl::common::{ChannelBinding, Credentials};
use std::mem::replace;
use std::str::FromStr;
@ -193,24 +193,13 @@ impl Stream for Client {
}
impl Sink for Client {
type SinkItem = Element;
type SinkItem = Packet;
type SinkError = Error;
fn start_send(&mut self, item: Self::SinkItem) -> StartSend<Self::SinkItem, Self::SinkError> {
match self.state {
ClientState::Connected(ref mut stream) => {
match stream.start_send(Packet::Stanza(item)) {
Ok(AsyncSink::NotReady(Packet::Stanza(stanza))) =>
Ok(AsyncSink::NotReady(stanza)),
Ok(AsyncSink::NotReady(_)) => {
panic!("Client.start_send with stanza but got something else back")
}
Ok(AsyncSink::Ready) =>
Ok(AsyncSink::Ready),
Err(e) =>
Err(e)?,
}
}
ClientState::Connected(ref mut stream) =>
Ok(stream.start_send(item)?),
_ =>
Ok(AsyncSink::NotReady(item)),
}

View file

@ -8,6 +8,7 @@ extern crate derive_error;
mod starttls;
mod stream_start;
pub mod xmpp_codec;
pub use crate::xmpp_codec::Packet;
pub mod xmpp_stream;
pub use crate::starttls::StartTlsClient;
mod event;