1
2
Fork 0
mirror of https://github.com/mat-1/azalea.git synced 2025-08-02 06:16:04 +00:00

fix some clippy warnings

This commit is contained in:
mat 2021-12-26 14:17:01 -06:00
parent af28b0e57a
commit 1a961d968b
14 changed files with 7 additions and 20 deletions

View file

@ -13,7 +13,7 @@ const MAX_STRING_LENGTH: u16 = 32767;
#[async_trait]
pub trait Writable {
fn write_list<F, T>(&mut self, list: &Vec<T>, writer: F) -> Result<(), std::io::Error>
fn write_list<F, T>(&mut self, list: &[T], writer: F) -> Result<(), std::io::Error>
where
F: FnOnce(&mut Self, &T) -> Result<(), std::io::Error> + Copy,
T: Sized,
@ -49,7 +49,7 @@ pub trait Writable {
#[async_trait]
impl Writable for Vec<u8> {
fn write_list<F, T>(&mut self, list: &Vec<T>, writer: F) -> Result<(), std::io::Error>
fn write_list<F, T>(&mut self, list: &[T], writer: F) -> Result<(), std::io::Error>
where
F: FnOnce(&mut Self, &T) -> Result<(), std::io::Error> + Copy,
Self: Sized,
@ -215,7 +215,7 @@ where
}
return i;
}
return 5;
5
}
fn get_varlong_size(&mut self, value: i32) -> u8 {
@ -225,7 +225,7 @@ where
}
return i;
}
return 10;
10
}
async fn read_byte_array(&mut self) -> Result<Vec<u8>, String> {

View file

@ -1,7 +1,6 @@
use super::GamePacket;
use crate::mc_buf::{Readable, Writable};
use azalea_core::{game_type::GameType, resource_location::ResourceLocation};
use tokio::io::AsyncReadExt;
#[derive(Clone, Debug)]
pub struct ClientboundLoginPacket {

View file

@ -3,7 +3,6 @@ pub mod clientbound_login_packet;
use super::ProtocolPacket;
use crate::connect::PacketFlow;
use async_trait::async_trait;
use tokio::io::BufReader;
#[derive(Clone, Debug)]
pub enum GamePacket

View file

@ -1,7 +1,5 @@
use std::hash::Hash;
use tokio::io::BufReader;
use crate::{mc_buf::Writable, packets::ConnectionProtocol};
use super::HandshakePacket;

View file

@ -1,7 +1,6 @@
pub mod client_intention_packet;
use async_trait::async_trait;
use tokio::io::BufReader;
use crate::connect::PacketFlow;

View file

@ -2,7 +2,6 @@ use super::LoginPacket;
use crate::mc_buf::{Readable, Writable};
use azalea_auth::game_profile::GameProfile;
use azalea_core::serializable_uuid::SerializableUuid;
use tokio::io::BufReader;
use uuid::Uuid;
#[derive(Clone, Debug)]

View file

@ -1,5 +1,4 @@
use std::hash::Hash;
use tokio::io::BufReader;
use crate::mc_buf::Readable;

View file

@ -1,5 +1,4 @@
use std::hash::Hash;
use tokio::io::BufReader;
use crate::mc_buf::{Readable, Writable};

View file

@ -1,5 +1,4 @@
use std::hash::Hash;
use tokio::io::BufReader;
use crate::mc_buf::Writable;

View file

@ -4,7 +4,6 @@ pub mod login;
pub mod status;
use async_trait::async_trait;
use tokio::io::BufReader;
use crate::connect::PacketFlow;

View file

@ -1,7 +1,6 @@
use azalea_chat::component::Component;
use serde::Deserialize;
use serde_json::Value;
use tokio::io::BufReader;
use crate::mc_buf::Readable;

View file

@ -2,7 +2,6 @@ pub mod clientbound_status_response_packet;
pub mod serverbound_status_request_packet;
use async_trait::async_trait;
use tokio::io::BufReader;
use crate::connect::PacketFlow;

View file

@ -1,5 +1,4 @@
use std::hash::Hash;
use tokio::io::BufReader;
use super::StatusPacket;

View file

@ -19,7 +19,7 @@ where
Ok(buf)
}
Err(e) => Err("length wider than 21-bit".to_string()),
Err(_) => Err("length wider than 21-bit".to_string()),
}
}
@ -66,7 +66,7 @@ where
n, compression_threshold
));
}
if n > MAXIMUM_UNCOMPRESSED_LENGTH.into() {
if n > MAXIMUM_UNCOMPRESSED_LENGTH {
return Err(format!(
"Badly compressed packet - size of {} is larger than protocol maximum of {}",
n, MAXIMUM_UNCOMPRESSED_LENGTH
@ -104,5 +104,5 @@ where
}
let packet = packet_decoder(&mut buf.as_slice(), flow).await?;
return Ok(packet);
Ok(packet)
}