tokio-xmpp: clippy run

skip-changelog

Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
Maxime “pep” Buquet 2025-04-07 22:57:33 +02:00
commit 23c947d081
14 changed files with 54 additions and 73 deletions

View file

@ -127,7 +127,7 @@ impl<T: AsyncBufRead> AsyncBufRead for CaptureBufRead<T> {
this.inner.consume(amt);
if let Some((_, consumed_up_to)) = this.buf.as_mut() {
// Increase the amount of data to preserve.
*consumed_up_to = *consumed_up_to + amt;
*consumed_up_to += amt;
}
}
}
@ -186,12 +186,11 @@ pub(super) fn log_recv(err: Option<&xmpp_parsers::Error>, capture: Option<Vec<u8
log::trace!("RECV (error: {}) [data capture disabled]", err);
}
},
None => match capture {
Some(capture) => {
None => {
if let Some(capture) = capture {
log::trace!("RECV (ok) {}", LogXsoBuf(&capture));
}
None => (),
},
}
}
}

View file

@ -152,7 +152,7 @@ impl TimeoutState {
self.level = TimeoutLevel::Soft;
self.deadline
.as_mut()
.reset((Instant::now() + self.timeouts.data_to_soft()).into());
.reset(Instant::now() + self.timeouts.data_to_soft());
}
}
@ -380,10 +380,10 @@ impl<Io: AsyncBufRead> Stream for RawXmlStream<Io> {
}
}
impl<'x, Io: AsyncWrite> RawXmlStreamProj<'x, Io> {
impl<Io: AsyncWrite> RawXmlStreamProj<'_, Io> {
fn flush_tx_log(&mut self) {
let range = &self.tx_buffer[*self.tx_buffer_logged..];
if range.len() == 0 {
if range.is_empty() {
return;
}
log_send(range);
@ -413,12 +413,12 @@ impl<'x, Io: AsyncWrite> RawXmlStreamProj<'x, Io> {
fn progress_write(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), io::Error>> {
self.flush_tx_log();
while self.tx_buffer.len() > 0 {
while !self.tx_buffer.is_empty() {
let written = match ready!(self
.parser
.as_mut()
.inner_pinned()
.poll_write(cx, &self.tx_buffer))
.poll_write(cx, self.tx_buffer))
{
Ok(v) => v,
Err(e) => return Poll::Ready(Err(e)),
@ -461,7 +461,7 @@ impl<'x, Io: AsyncWrite> Sink<xso::Item<'x>> for RawXmlStream<Io> {
// Some progress and it went fine, move on.
Poll::Ready(Ok(())) => (),
// Something went wrong -> return the error.
Poll::Ready(Err(e)) => return Poll::Ready(Err(e.into())),
Poll::Ready(Err(e)) => return Poll::Ready(Err(e)),
}
if this.tx_buffer.len() < *this.tx_buffer_high_water_mark {
Poll::Ready(Ok(()))
@ -608,10 +608,7 @@ impl<T: FromXml> ReadXsoState<T> {
// whitespace keepalives.
// (And also, we'll know faster when the remote side sends
// non-whitespace garbage.)
let text_buffering = match self {
ReadXsoState::PreData => false,
_ => true,
};
let text_buffering = !matches!(self, ReadXsoState::PreData);
source
.as_mut()
.parser_pinned()
@ -745,7 +742,7 @@ impl<'x, Io: AsyncBufRead, T: FromXml> ReadXso<'x, Io, T> {
}
}
impl<'x, Io: AsyncBufRead, T: FromXml> Future for ReadXso<'x, Io, T>
impl<Io: AsyncBufRead, T: FromXml> Future for ReadXso<'_, Io, T>
where
T::Builder: Unpin,
{
@ -770,7 +767,7 @@ pub struct StreamHeader<'x> {
pub id: Option<Cow<'x, str>>,
}
impl<'x> StreamHeader<'x> {
impl StreamHeader<'_> {
/// Take the contents and return them as new object.
///
/// `self` will be left with all its parts set to `None`.

View file

@ -111,10 +111,10 @@ fn highlight_xml(xml: &str) -> String {
struct LogXsoBuf<'x>(&'x [u8]);
impl<'x> fmt::Display for LogXsoBuf<'x> {
impl fmt::Display for LogXsoBuf<'_> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
// We always generate UTF-8, so this should be good... I think.
let text = core::str::from_utf8(&self.0).unwrap();
let text = core::str::from_utf8(self.0).unwrap();
#[cfg(feature = "syntax-highlighting")]
let text = highlight_xml(text);
f.write_str(&text)
@ -493,7 +493,7 @@ pub struct Shutdown<'a, Io: AsyncWrite, T: FromXml + AsXml> {
stream: Pin<&'a mut XmlStream<Io, T>>,
}
impl<'a, Io: AsyncWrite, T: FromXml + AsXml> Future for Shutdown<'a, Io, T> {
impl<Io: AsyncWrite, T: FromXml + AsXml> Future for Shutdown<'_, Io, T> {
type Output = io::Result<()>;
fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {