delint (clippy)
This commit is contained in:
parent
00e2daaecd
commit
7cd31bd425
8 changed files with 55 additions and 64 deletions
|
|
@ -130,12 +130,9 @@ impl<S: AsyncRead + AsyncWrite> Future for ClientAuth<S> {
|
|||
if stanza.name() == "failure"
|
||||
&& stanza.ns() == Some(NS_XMPP_SASL) =>
|
||||
{
|
||||
let mut e = None;
|
||||
for child in stanza.children() {
|
||||
e = Some(child.name().clone());
|
||||
break
|
||||
}
|
||||
let e = e.unwrap_or_else(|| "Authentication failure");
|
||||
let e = stanza.children().next()
|
||||
.map(|child| child.name())
|
||||
.unwrap_or("Authentication failure");
|
||||
Err(e.to_owned())
|
||||
},
|
||||
Ok(Async::Ready(event)) => {
|
||||
|
|
|
|||
|
|
@ -44,13 +44,10 @@ fn make_bind_request(resource: Option<&String>) -> Element {
|
|||
.attr("id", BIND_REQ_ID);
|
||||
let mut bind_el = Element::builder("bind")
|
||||
.ns(NS_XMPP_BIND);
|
||||
match resource {
|
||||
Some(resource) => {
|
||||
let resource_el = Element::builder("resource")
|
||||
.append(resource);
|
||||
bind_el = bind_el.append(resource_el.build());
|
||||
},
|
||||
None => (),
|
||||
if let Some(resource) = resource {
|
||||
let resource_el = Element::builder("resource")
|
||||
.append(resource);
|
||||
bind_el = bind_el.append(resource_el.build());
|
||||
}
|
||||
iq.append(bind_el.build())
|
||||
.build()
|
||||
|
|
@ -87,7 +84,7 @@ impl<S: AsyncRead + AsyncWrite> Future for ClientBind<S> {
|
|||
&& iq.attr("id") == Some(BIND_REQ_ID) => {
|
||||
match iq.attr("type") {
|
||||
Some("result") => {
|
||||
get_bind_response_jid(&iq)
|
||||
get_bind_response_jid(iq)
|
||||
.map(|jid| stream.jid = jid);
|
||||
Ok(Async::Ready(stream))
|
||||
},
|
||||
|
|
|
|||
|
|
@ -9,22 +9,22 @@ pub enum Event {
|
|||
|
||||
impl Event {
|
||||
pub fn is_online(&self) -> bool {
|
||||
match self {
|
||||
&Event::Online => true,
|
||||
match *self {
|
||||
Event::Online => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_stanza(&self, name: &str) -> bool {
|
||||
match self {
|
||||
&Event::Stanza(ref stanza) => stanza.name() == name,
|
||||
match *self {
|
||||
Event::Stanza(ref stanza) => stanza.name() == name,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn as_stanza(&self) -> Option<&Element> {
|
||||
match self {
|
||||
&Event::Stanza(ref stanza) => Some(stanza),
|
||||
match *self {
|
||||
Event::Stanza(ref stanza) => Some(stanza),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -130,10 +130,6 @@ impl Stream for Client {
|
|||
},
|
||||
ClientState::Connected(mut stream) => {
|
||||
match stream.poll() {
|
||||
Ok(Async::NotReady) => {
|
||||
self.state = ClientState::Connected(stream);
|
||||
Ok(Async::NotReady)
|
||||
},
|
||||
Ok(Async::Ready(None)) => {
|
||||
// EOF
|
||||
self.state = ClientState::Disconnected;
|
||||
|
|
@ -143,6 +139,7 @@ impl Stream for Client {
|
|||
self.state = ClientState::Connected(stream);
|
||||
Ok(Async::Ready(Some(ClientEvent::Stanza(stanza))))
|
||||
},
|
||||
Ok(Async::NotReady) |
|
||||
Ok(Async::Ready(_)) => {
|
||||
self.state = ClientState::Connected(stream);
|
||||
Ok(Async::NotReady)
|
||||
|
|
@ -179,8 +176,8 @@ impl Sink for Client {
|
|||
}
|
||||
|
||||
fn poll_complete(&mut self) -> Poll<(), Self::SinkError> {
|
||||
match &mut self.state {
|
||||
&mut ClientState::Connected(ref mut stream) =>
|
||||
match self.state {
|
||||
ClientState::Connected(ref mut stream) =>
|
||||
stream.poll_complete()
|
||||
.map_err(|e| e.description().to_owned()),
|
||||
_ =>
|
||||
|
|
|
|||
Loading…
Reference in a new issue