Skip to content

Commit 2713290

Browse files
Xaeroxeariscript
authored andcommitted
remove unused code per clippy, fix other clippy complaints
1 parent c271bcf commit 2713290

File tree

4 files changed

+5
-75
lines changed

4 files changed

+5
-75
lines changed

src/rcon.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
mod client;
55
mod packet;
66

7+
#[allow(clippy::module_name_repetitions)]
78
pub use client::RconClient;
89

910
const MAX_LEN_CLIENTBOUND: usize = 4096;

src/rcon/client.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ use tokio::{
3030
/// Ok(())
3131
/// }
3232
/// ```
33+
#[allow(clippy::module_name_repetitions)]
3334
#[derive(Debug)]
3435
pub struct RconClient {
3536
socket: TcpStream,

src/socket.rs

Lines changed: 2 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::varint::{VarInt, CONTINUE_BIT};
22
use async_trait::async_trait;
33
use bytes::{BufMut, BytesMut};
44
use std::io::{Error, ErrorKind};
5-
use tokio::io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt, Result};
5+
use tokio::io::{AsyncRead, AsyncReadExt, AsyncWrite, Result};
66

77
/// Trait to allow for reading and writing `VarInt`s from the socket.
88
///
@@ -12,26 +12,6 @@ pub(crate) trait ReadWriteVarInt {
1212
/// Read a [VarInt] from the socket.
1313
/// Returns the parsed value as [i32] in a [Result].
1414
async fn read_varint(&mut self) -> Result<i32>;
15-
16-
/// Write a [VarInt] to the socket.
17-
/// Writes the given integer in the form of a [VarInt].
18-
/// Returns whether the operation was successful in a [Result].
19-
async fn write_varint(&mut self, value: i32) -> Result<()>;
20-
}
21-
22-
/// Trait to allow for reading and writing `VarLong`s from the socket.
23-
///
24-
/// The type is specified [in wiki.vg](https://wiki.vg/Protocol#VarInt_and_VarLong).
25-
#[async_trait]
26-
pub(crate) trait ReadWriteVarLong {
27-
/// Read a `VarLong` from the socket.
28-
/// Returns the parsed value as [i64] in a [Result].
29-
async fn read_varlong(&mut self) -> Result<i64>;
30-
31-
/// Write a `VarLong` to the socket.
32-
/// Writes the given integer in the form of a `VarLong`.
33-
/// Returns whether the operation was successful in a [Result].
34-
async fn write_varlong(&mut self, value: i64) -> Result<()>;
3515
}
3616

3717
/// Trait to allow for reading and writing strings from the socket.
@@ -43,22 +23,6 @@ pub(crate) trait ReadWriteMinecraftString {
4323
/// Read a [String] from the socket.
4424
/// Returns the parsed value recieved from the socket in a [Result].
4525
async fn read_mc_string(&mut self) -> Result<String>;
46-
47-
/// Write a [str] to the socket.
48-
/// Returns whether the operation was successful in a [Result].
49-
async fn write_mc_string(&mut self, value: &str) -> Result<()>;
50-
}
51-
52-
/// Trait to allow for reading and writing null terminated strings from the socket.
53-
#[async_trait]
54-
pub(crate) trait ReadWriteNullTermString {
55-
/// Read a [String] from the socket.
56-
/// Returns the pased value recieved from the socket in a [Result].
57-
async fn read_null_terminated_string(&mut self) -> Result<String>;
58-
59-
/// Write a [str] ot the socket
60-
/// Returns whetehr the operation was successful in a [Result].
61-
async fn write_null_terminated_string(&mut self, value: &str) -> Result<()>;
6226
}
6327

6428
#[async_trait]
@@ -82,10 +46,6 @@ where
8246
.try_into()
8347
.map_err(|err| Error::new(ErrorKind::InvalidData, err))
8448
}
85-
86-
async fn write_varint(&mut self, value: i32) -> Result<()> {
87-
self.write_all(&VarInt::from(value)).await
88-
}
8949
}
9050

9151
#[async_trait]
@@ -100,37 +60,4 @@ where
10060

10161
String::from_utf8(buffer).map_err(|err| Error::new(ErrorKind::InvalidData, err))
10262
}
103-
104-
async fn write_mc_string(&mut self, value: &str) -> Result<()> {
105-
self.write_varint(value.len() as i32).await?;
106-
self.write_all(value.as_bytes()).await?;
107-
108-
Ok(())
109-
}
110-
}
111-
112-
#[async_trait]
113-
impl<T> ReadWriteNullTermString for T
114-
where
115-
T: AsyncRead + AsyncWrite + Unpin + Send,
116-
{
117-
async fn read_null_terminated_string(&mut self) -> Result<String> {
118-
let mut string = String::new();
119-
120-
loop {
121-
let current = self.read_u8().await?;
122-
if current == 0 {
123-
break;
124-
}
125-
126-
string.push(current as char);
127-
}
128-
129-
Ok(string)
130-
}
131-
132-
async fn write_null_terminated_string(&mut self, value: &str) -> Result<()> {
133-
self.write_all(value.as_bytes()).await?;
134-
self.write_u8(0).await
135-
}
136-
}
63+
}

src/status/data.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ pub struct ChatComponentObject {
121121
/// * `minecraft:uniform` - Unicode font
122122
/// * `minecraft:alt` - enchanting table font
123123
/// * `minecraft:default` - font based on resource pack (1.16+)
124+
///
124125
/// Any other value can be ignored
125126
pub font: Option<String>,
126127

0 commit comments

Comments
 (0)