mirror of
https://github.com/EasyTier/EasyTier.git
synced 2026-05-06 17:59:11 +00:00
clippy all codes (#1214)
1. clippy code 2. add fmt and clippy check in ci
This commit is contained in:
@@ -145,8 +145,7 @@ where
|
||||
return Poll::Ready(None);
|
||||
}
|
||||
|
||||
while let Some(packet) =
|
||||
Self::extract_one_packet(self_mut.buf, *self_mut.max_packet_size)
|
||||
if let Some(packet) = Self::extract_one_packet(self_mut.buf, *self_mut.max_packet_size)
|
||||
{
|
||||
if let Err(TunnelError::InvalidPacket(msg)) = packet.as_ref() {
|
||||
self_mut
|
||||
@@ -157,7 +156,7 @@ where
|
||||
}
|
||||
|
||||
reserve_buf(
|
||||
&mut self_mut.buf,
|
||||
self_mut.buf,
|
||||
*self_mut.max_packet_size,
|
||||
*self_mut.max_packet_size * 2,
|
||||
);
|
||||
@@ -186,12 +185,12 @@ where
|
||||
}
|
||||
|
||||
pub trait ZCPacketToBytes {
|
||||
fn into_bytes(&self, zc_packet: ZCPacket) -> Result<Bytes, TunnelError>;
|
||||
fn zcpacket_into_bytes(&self, zc_packet: ZCPacket) -> Result<Bytes, TunnelError>;
|
||||
}
|
||||
|
||||
pub struct TcpZCPacketToBytes;
|
||||
impl ZCPacketToBytes for TcpZCPacketToBytes {
|
||||
fn into_bytes(&self, item: ZCPacket) -> Result<Bytes, TunnelError> {
|
||||
fn zcpacket_into_bytes(&self, item: ZCPacket) -> Result<Bytes, TunnelError> {
|
||||
let mut item = item.convert_type(ZCPacketType::TCP);
|
||||
|
||||
let tcp_len = PEER_MANAGER_HEADER_SIZE + item.payload_len();
|
||||
@@ -280,7 +279,9 @@ where
|
||||
|
||||
fn start_send(self: Pin<&mut Self>, item: ZCPacket) -> Result<(), Self::Error> {
|
||||
let pinned = self.project();
|
||||
pinned.sending_bufs.push(pinned.converter.into_bytes(item)?);
|
||||
pinned
|
||||
.sending_bufs
|
||||
.push(pinned.converter.zcpacket_into_bytes(item)?);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -461,14 +462,13 @@ pub mod tests {
|
||||
continue;
|
||||
};
|
||||
tracing::debug!(?msg, "recv a msg, try echo back");
|
||||
if let Err(_) = send.send(msg).await {
|
||||
if send.send(msg).await.is_err() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
let Some(ret) = recv.next().await else {
|
||||
assert!(false, "recv error");
|
||||
return;
|
||||
panic!("recv error");
|
||||
};
|
||||
|
||||
if ret.is_err() {
|
||||
@@ -597,7 +597,7 @@ pub mod tests {
|
||||
let elapsed_sec = now.elapsed().as_secs();
|
||||
if elapsed_sec > 0 {
|
||||
bps_clone.store(
|
||||
count as u64 / now.elapsed().as_secs() as u64,
|
||||
count as u64 / now.elapsed().as_secs(),
|
||||
std::sync::atomic::Ordering::Relaxed,
|
||||
);
|
||||
}
|
||||
@@ -621,7 +621,7 @@ pub mod tests {
|
||||
while now.elapsed().as_secs() < 10 {
|
||||
// send.feed(item)
|
||||
let item = ZCPacket::new_with_payload(send_buf.as_ref());
|
||||
let _ = send.feed(item).await.unwrap();
|
||||
send.feed(item).await.unwrap();
|
||||
}
|
||||
|
||||
send.close().await.unwrap();
|
||||
@@ -649,7 +649,7 @@ pub mod tests {
|
||||
.init();
|
||||
}
|
||||
|
||||
pub async fn wait_for_condition<F, FRet>(mut condition: F, timeout: std::time::Duration) -> ()
|
||||
pub async fn wait_for_condition<F, FRet>(mut condition: F, timeout: std::time::Duration)
|
||||
where
|
||||
F: FnMut() -> FRet + Send,
|
||||
FRet: Future<Output = bool>,
|
||||
|
||||
Reference in New Issue
Block a user