tokio-xmpp: clippy run
skip-changelog Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
parent
1b635854ad
commit
23c947d081
14 changed files with 54 additions and 73 deletions
|
|
@ -214,10 +214,7 @@ impl ConnectedState {
|
|||
// from the peer when everything has been transmitted, which may be
|
||||
// longer than the stream timeout.
|
||||
ready!(Self::poll_write_sm_req(
|
||||
match sm_state {
|
||||
None => None,
|
||||
Some(ref mut v) => Some(v),
|
||||
},
|
||||
sm_state.as_mut().map(|x| x as &mut SmState),
|
||||
stream.as_mut(),
|
||||
cx
|
||||
))?;
|
||||
|
|
@ -558,7 +555,7 @@ impl ConnectedState {
|
|||
"Failed to process <sm:a/> sent by the server: {e}",
|
||||
);
|
||||
self.to_stream_error_state(e.into());
|
||||
return Poll::Ready(None);
|
||||
Poll::Ready(None)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
@ -823,13 +820,12 @@ impl ConnectedState {
|
|||
|
||||
pub fn queue_sm_request(&mut self) -> bool {
|
||||
match self {
|
||||
Self::Ready { sm_state, .. } => {
|
||||
if let Some(sm_state) = sm_state {
|
||||
sm_state.pending_req = true;
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
Self::Ready {
|
||||
sm_state: Some(sm_state),
|
||||
..
|
||||
} => {
|
||||
sm_state.pending_req = true;
|
||||
true
|
||||
}
|
||||
_ => false,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -168,7 +168,7 @@ impl StanzaStream {
|
|||
// TODO: auth errors should probably be fatal??
|
||||
log::error!("Failed to connect: {}. Retrying in {:?}.", e, delay);
|
||||
tokio::time::sleep(delay).await;
|
||||
delay = delay * 2;
|
||||
delay *= 2;
|
||||
if delay > MAX_DELAY {
|
||||
delay = MAX_DELAY;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -101,18 +101,15 @@ pub(super) enum NegotiationResult {
|
|||
|
||||
impl NegotiationState {
|
||||
pub fn new(features: &StreamFeatures, sm_state: Option<SmState>) -> io::Result<Self> {
|
||||
match sm_state {
|
||||
Some(sm_state) => {
|
||||
if features.stream_management.is_some() {
|
||||
return Ok(Self::SendSmRequest {
|
||||
sm_state: Some(sm_state),
|
||||
bound_jid: None,
|
||||
});
|
||||
} else {
|
||||
log::warn!("Peer is not offering stream management anymore. Dropping state.");
|
||||
}
|
||||
if let Some(sm_state) = sm_state {
|
||||
if features.stream_management.is_some() {
|
||||
return Ok(Self::SendSmRequest {
|
||||
sm_state: Some(sm_state),
|
||||
bound_jid: None,
|
||||
});
|
||||
} else {
|
||||
log::warn!("Peer is not offering stream management anymore. Dropping state.");
|
||||
}
|
||||
None => (),
|
||||
}
|
||||
|
||||
if !features.can_bind() {
|
||||
|
|
@ -247,7 +244,7 @@ impl NegotiationState {
|
|||
|
||||
Ok(XmppStreamElement::StreamError(error)) => {
|
||||
log::debug!("Received stream:error, failing stream and discarding any stream management state.");
|
||||
let error = io::Error::new(io::ErrorKind::Other, error);
|
||||
let error = io::Error::other(error);
|
||||
transmit_queue.fail(&(&error).into());
|
||||
Poll::Ready(Break(NegotiationResult::Disconnect {
|
||||
error,
|
||||
|
|
@ -472,7 +469,7 @@ impl NegotiationState {
|
|||
|
||||
Ok(XmppStreamElement::StreamError(error)) => {
|
||||
log::debug!("Received stream error, failing stream and discarding any stream management state.");
|
||||
let error = io::Error::new(io::ErrorKind::Other, error);
|
||||
let error = io::Error::other(error);
|
||||
transmit_queue.fail(&(&error).into());
|
||||
Poll::Ready(Break(NegotiationResult::Disconnect {
|
||||
error,
|
||||
|
|
|
|||
|
|
@ -224,7 +224,7 @@ pub(super) struct TransmitQueueRef<'x, T> {
|
|||
q: &'x mut VecDeque<T>,
|
||||
}
|
||||
|
||||
impl<'x, T> TransmitQueueRef<'x, T> {
|
||||
impl<T> TransmitQueueRef<'_, T> {
|
||||
/// Take the item out of the queue.
|
||||
pub fn take(self) -> T {
|
||||
// Unwrap: when this type is created, a check is made that the queue
|
||||
|
|
@ -265,7 +265,7 @@ impl<T: Unpin> TransmitQueue<T> {
|
|||
|
||||
/// Poll the queue for the next item to transmit.
|
||||
pub fn poll_next(&mut self, cx: &mut Context) -> Poll<Option<TransmitQueueRef<'_, T>>> {
|
||||
if self.peek.len() > 0 {
|
||||
if !self.peek.is_empty() {
|
||||
// Cannot use `if let Some(.) = .` here because of a borrowchecker
|
||||
// restriction. If the reference is created before the branch is
|
||||
// entered, it will think it needs to be borrowed until the end
|
||||
|
|
|
|||
|
|
@ -177,7 +177,7 @@ impl SmState {
|
|||
let to_drop = h.wrapping_sub(self.outbound_base) as usize;
|
||||
if to_drop > 0 {
|
||||
log::trace!("remote_acked: need to drop {to_drop} stanzas");
|
||||
if to_drop as usize > self.unacked_stanzas.len() {
|
||||
if to_drop > self.unacked_stanzas.len() {
|
||||
if to_drop as u32 > u32::MAX / 2 {
|
||||
// If we look at the stanza counter values as RFC 1982
|
||||
// values, a wrapping difference greater than half the
|
||||
|
|
|
|||
|
|
@ -196,7 +196,7 @@ impl WorkerStream {
|
|||
match ready!(substate.poll(
|
||||
Pin::new(stream),
|
||||
identity,
|
||||
&features,
|
||||
features,
|
||||
transmit_queue,
|
||||
cx
|
||||
)) {
|
||||
|
|
@ -205,13 +205,9 @@ impl WorkerStream {
|
|||
|
||||
// produced an event to emit.
|
||||
Some(ConnectedEvent::Worker(v)) => {
|
||||
match v {
|
||||
// Capture the JID from a stream reset to
|
||||
// update our state.
|
||||
WorkerEvent::Reset { ref bound_jid, .. } => {
|
||||
*identity = bound_jid.clone();
|
||||
}
|
||||
_ => (),
|
||||
// Capture the JID from a stream reset to update our state.
|
||||
if let WorkerEvent::Reset { ref bound_jid, .. } = v {
|
||||
*identity = bound_jid.clone();
|
||||
}
|
||||
return Poll::Ready(Some(v));
|
||||
}
|
||||
|
|
@ -364,7 +360,7 @@ struct DriveDuplex<'x> {
|
|||
queue: &'x mut TransmitQueue<QueueEntry>,
|
||||
}
|
||||
|
||||
impl<'x> Future for DriveDuplex<'x> {
|
||||
impl Future for DriveDuplex<'_> {
|
||||
type Output = Option<WorkerEvent>;
|
||||
|
||||
fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
|
||||
|
|
@ -378,7 +374,7 @@ struct DriveWrites<'x> {
|
|||
queue: &'x mut TransmitQueue<QueueEntry>,
|
||||
}
|
||||
|
||||
impl<'x> Future for DriveWrites<'x> {
|
||||
impl Future for DriveWrites<'_> {
|
||||
type Output = Never;
|
||||
|
||||
fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
|
||||
|
|
@ -391,7 +387,7 @@ struct Close<'x> {
|
|||
stream: Pin<&'x mut WorkerStream>,
|
||||
}
|
||||
|
||||
impl<'x> Future for Close<'x> {
|
||||
impl Future for Close<'_> {
|
||||
type Output = io::Result<()>;
|
||||
|
||||
fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
|
||||
|
|
|
|||
Loading…
Reference in a new issue