Skip to content

Commit 9db498e

Browse files
committed
Cleaned up and fixed some warnings
1 parent 2667abf commit 9db498e

File tree

6 files changed

+17
-24
lines changed

6 files changed

+17
-24
lines changed

src/crates/ferrumc_net/src/lib.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,25 @@ use std::sync::{Arc, atomic, OnceLock};
77
use std::sync::atomic::AtomicU32;
88

99
use dashmap::DashMap;
10-
use ferrumc_utils::encoding::varint::read_varint;
11-
use ferrumc_utils::prelude::*;
12-
use lariv::Lariv;
13-
use lazy_static::lazy_static;
1410
use log::{debug, trace};
1511
use rand::random;
1612
use tokio::io::AsyncReadExt;
1713
use tokio::io::AsyncWriteExt;
18-
use tokio::sync::{RwLock, RwLockWriteGuard};
14+
use tokio::sync::RwLock;
15+
16+
use ferrumc_utils::encoding::varint::read_varint;
17+
use ferrumc_utils::prelude::*;
1918

20-
use crate::packets::{handle_packet};
19+
use crate::packets::handle_packet;
2120

22-
mod packets;
21+
pub mod packets;
2322

2423
#[allow(non_snake_case)]
2524
pub fn CONNECTIONS() -> &'static ConnectionList {
2625
static CONNECTIONS: OnceLock<ConnectionList> = OnceLock::new();
2726
CONNECTIONS.get_or_init(|| ConnectionList {
2827
connections: DashMap::new(),
2928
connection_count: AtomicU32::new(0),
30-
purge_queue: Lariv::new(1024),
3129
})
3230
}
3331

@@ -65,8 +63,6 @@ pub struct ConnectionList {
6563
pub connections: DashMap<u32, Arc<RwLock<Connection>>>,
6664
// The number of connections.
6765
pub connection_count: AtomicU32,
68-
// The queue of connections to be purged. This is used to store the connections to be dropped at the end of every tick.
69-
pub purge_queue: Lariv<u32>,
7066
}
7167

7268
#[derive()]

src/crates/ferrumc_net/src/packets/incoming/handshake.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
use std::sync::Arc;
2-
use log::{debug, info};
31
use ferrumc_macros::{Decode, packet};
42
use ferrumc_utils::encoding::varint::VarInt;
3+
54
use crate::{Connection, State};
65
use crate::packets::IncomingPacket;
76

src/crates/ferrumc_net/src/packets/incoming/ping.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
use std::sync::Arc;
21
use log::info;
32
use tokio::io::AsyncWriteExt;
3+
44
use ferrumc_macros::{Decode, packet};
55
use ferrumc_utils::encoding::varint::VarInt;
6+
67
use crate::Connection;
78
use crate::packets::IncomingPacket;
89
use crate::packets::outgoing::ping::OutgoingPing;

src/crates/ferrumc_net/src/packets/incoming/status.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
use std::sync::Arc;
2-
use tokio::sync::OnceCell;
1+
use base64::Engine;
32
use log::info;
43
use serde::Serialize;
4+
use tokio::io::{AsyncReadExt, AsyncWriteExt};
5+
use tokio::sync::OnceCell;
6+
57
use ferrumc_macros::{Decode, packet};
8+
use ferrumc_utils::config;
69
use ferrumc_utils::encoding::varint::VarInt;
10+
711
use crate::Connection;
812
use crate::packets::IncomingPacket;
913
use crate::packets::outgoing::status::OutgoingStatusResponse;
10-
use tokio::io::{AsyncReadExt, AsyncWriteExt};
11-
use ferrumc_utils::config;
12-
use base64::{Engine};
1314

1415
#[derive(Decode)]
1516
#[packet(packet_id = 0x00, state = "status")]
@@ -48,7 +49,7 @@ struct Description {
4849
}
4950

5051
impl IncomingPacket for Status {
51-
async fn handle(&self, conn: &mut tokio::sync::RwLockWriteGuard<'_, Connection>) -> Result<(), ferrumc_utils::error::Error> {
52+
async fn handle(&self, conn: &mut tokio::sync::RwLockWriteGuard<'_, Connection>) -> Result<(), Error> {
5253
info!("Handling status request packet");
5354
let config = config::get_global_config();
5455

src/crates/ferrumc_net/src/packets/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ pub mod incoming;
1111
pub mod outgoing;
1212

1313
pub trait IncomingPacket {
14+
#[allow(async_fn_in_trait)]
1415
async fn handle(&self, conn: &mut tokio::sync::RwLockWriteGuard<Connection>) -> Result<(), Error>;
1516
}
1617

src/tests.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,8 @@
33
mod tests {
44
use std::io::Cursor;
55

6-
use tokio::io::{AsyncRead, AsyncSeek};
7-
86
use ferrumc_macros::Decode;
97
use ferrumc_utils::encoding::varint::VarInt;
10-
use ferrumc_utils::type_impls::Decode;
11-
12-
use crate::Error;
138

149
#[tokio::test]
1510
async fn test_macro_decode() {

0 commit comments

Comments
 (0)