aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorFuwn <[email protected]>2024-06-03 14:57:47 -0700
committerFuwn <[email protected]>2024-06-03 14:57:47 -0700
commita6b766541ae58053ae705e0559d1a1ae8212634b (patch)
treeaeb55206e77679b2f5e1f47fae7f1bda5c6df5b9 /crates
parentMerge pull request #153 from Whirlsplash/renovate/actions-checkout-3.x (diff)
downloadwhirl-old.tar.xz
whirl-old.zip
fix: bump rust and update accordinglyold
Diffstat (limited to 'crates')
-rw-r--r--crates/whirl/src/lib.rs8
-rw-r--r--crates/whirl_api/src/lib.rs8
-rw-r--r--crates/whirl_api/src/routes/stats/mod.rs3
-rw-r--r--crates/whirl_common/src/lib.rs8
-rw-r--r--crates/whirl_config/src/lib.rs12
-rw-r--r--crates/whirl_db/src/schema.rs16
-rw-r--r--crates/whirl_prompt/src/lib.rs1
-rw-r--r--crates/whirl_server/src/cmd/commands/action.rs3
-rw-r--r--crates/whirl_server/src/cmd/commands/appear_actor.rs15
-rw-r--r--crates/whirl_server/src/cmd/commands/buddy_list.rs9
-rw-r--r--crates/whirl_server/src/cmd/commands/redirect_id.rs9
-rw-r--r--crates/whirl_server/src/cmd/commands/register_object_id.rs7
-rw-r--r--crates/whirl_server/src/cmd/commands/subscribe_room.rs11
-rw-r--r--crates/whirl_server/src/cmd/commands/teleport.rs3
-rw-r--r--crates/whirl_server/src/cmd/commands/text.rs7
-rw-r--r--crates/whirl_server/src/distributor.rs5
-rw-r--r--crates/whirl_server/src/hub.rs3
-rw-r--r--crates/whirl_server/src/lib.rs9
-rw-r--r--crates/whirl_server/src/net/property_list.rs15
19 files changed, 58 insertions, 94 deletions
diff --git a/crates/whirl/src/lib.rs b/crates/whirl/src/lib.rs
index 0233b20..ee68a02 100644
--- a/crates/whirl/src/lib.rs
+++ b/crates/whirl/src/lib.rs
@@ -1,13 +1,7 @@
// Copyright (C) 2021-2021 The Whirlsplash Collective
// SPDX-License-Identifier: GPL-3.0-only
-#![feature(
- type_ascription,
- hash_set_entry,
- type_name_of_val,
- decl_macro,
- proc_macro_hygiene
-)]
+#![feature(type_ascription, hash_set_entry, decl_macro, proc_macro_hygiene)]
#![deny(
warnings,
nonstandard_style,
diff --git a/crates/whirl_api/src/lib.rs b/crates/whirl_api/src/lib.rs
index efbec1a..9051f4c 100644
--- a/crates/whirl_api/src/lib.rs
+++ b/crates/whirl_api/src/lib.rs
@@ -3,13 +3,7 @@
//! The API, for external interaction.
-#![feature(
- type_ascription,
- hash_set_entry,
- type_name_of_val,
- decl_macro,
- proc_macro_hygiene
-)]
+#![feature(type_ascription, hash_set_entry, decl_macro, proc_macro_hygiene)]
#![deny(
warnings,
nonstandard_style,
diff --git a/crates/whirl_api/src/routes/stats/mod.rs b/crates/whirl_api/src/routes/stats/mod.rs
index 595b441..05b9bc7 100644
--- a/crates/whirl_api/src/routes/stats/mod.rs
+++ b/crates/whirl_api/src/routes/stats/mod.rs
@@ -6,7 +6,6 @@ pub mod structures;
use std::convert::TryFrom;
use axum::response;
-use num_traits::cast::AsPrimitive;
use sysinfo::{get_current_pid, ProcessExt, System, SystemExt};
use crate::routes::stats::structures::{Statistics, StatisticsProcess, StatisticsSystem};
@@ -31,7 +30,7 @@ pub async fn statistics() -> impl response::IntoResponse {
process: StatisticsProcess {
// (process.cpu_usage() * 100.0).round() / 100.0
memory_usage: (process.memory() / 1000).to_string(),
- cpu_usage: (process.cpu_usage() / sys.processors().len().as_(): f32).to_string(),
+ cpu_usage: (process.cpu_usage() / sys.processors().len() as f32).to_string(),
// uptime: seconds_to_hrtime((sys.get_uptime() - process.start_time()) as usize),
},
}),
diff --git a/crates/whirl_common/src/lib.rs b/crates/whirl_common/src/lib.rs
index 1c1cc55..fabc8b3 100644
--- a/crates/whirl_common/src/lib.rs
+++ b/crates/whirl_common/src/lib.rs
@@ -3,13 +3,7 @@
//! Assorted utilities, for global use.
-#![feature(
- type_ascription,
- hash_set_entry,
- type_name_of_val,
- decl_macro,
- proc_macro_hygiene
-)]
+#![feature(type_ascription, hash_set_entry, decl_macro, proc_macro_hygiene)]
#![deny(
warnings,
nonstandard_style,
diff --git a/crates/whirl_config/src/lib.rs b/crates/whirl_config/src/lib.rs
index b5f9d6e..fbcdee2 100644
--- a/crates/whirl_config/src/lib.rs
+++ b/crates/whirl_config/src/lib.rs
@@ -3,13 +3,7 @@
//! Configuration utilities, to interact with the configuration system.
-#![feature(
- type_ascription,
- hash_set_entry,
- type_name_of_val,
- decl_macro,
- proc_macro_hygiene
-)]
+#![feature(type_ascription, hash_set_entry, decl_macro, proc_macro_hygiene)]
#![deny(
warnings,
nonstandard_style,
@@ -74,7 +68,7 @@ impl Config {
/// - May panic if the configuration is unable to be read.
#[must_use]
pub fn get() -> Self {
- return if let Err(why) = Self::load() {
+ if let Err(why) = Self::load() {
error!(
"unable to load configuration file, reverting to default value: {}",
why
@@ -86,7 +80,7 @@ impl Config {
Self::default()
} else {
Self::load().unwrap()
- };
+ }
}
}
impl Default for Config {
diff --git a/crates/whirl_db/src/schema.rs b/crates/whirl_db/src/schema.rs
index 6d58598..318028e 100644
--- a/crates/whirl_db/src/schema.rs
+++ b/crates/whirl_db/src/schema.rs
@@ -1,4 +1,6 @@
-table! {
+// @generated automatically by Diesel CLI.
+
+diesel::table! {
serial_numbers (user_name) {
serial_number -> Text,
user_name -> Text,
@@ -6,7 +8,7 @@ table! {
}
}
-table! {
+diesel::table! {
user_properties (user_name) {
user_name -> Text,
property_id -> Integer,
@@ -17,12 +19,12 @@ table! {
}
}
-table! {
+diesel::table! {
user_registration (user_name) {
user_name_lower -> Text,
user_name -> Text,
serial_number -> Text,
- password -> Text,
+ pass_wordword -> Text,
client_version -> Text,
account_status -> Integer,
registration_date -> Text,
@@ -32,4 +34,8 @@ table! {
}
}
-allow_tables_to_appear_in_same_query!(serial_numbers, user_properties, user_registration,);
+diesel::allow_tables_to_appear_in_same_query!(
+ serial_numbers,
+ user_properties,
+ user_registration,
+);
diff --git a/crates/whirl_prompt/src/lib.rs b/crates/whirl_prompt/src/lib.rs
index 004fb0b..0c5c717 100644
--- a/crates/whirl_prompt/src/lib.rs
+++ b/crates/whirl_prompt/src/lib.rs
@@ -6,7 +6,6 @@
#![feature(
type_ascription,
hash_set_entry,
- type_name_of_val,
decl_macro,
proc_macro_hygiene,
stmt_expr_attributes
diff --git a/crates/whirl_server/src/cmd/commands/action.rs b/crates/whirl_server/src/cmd/commands/action.rs
index ac67eb2..6303528 100644
--- a/crates/whirl_server/src/cmd/commands/action.rs
+++ b/crates/whirl_server/src/cmd/commands/action.rs
@@ -8,7 +8,6 @@
// of actions, it will be of2m-ified.
use bytes::{BufMut, BytesMut};
-use num_traits::AsPrimitive;
pub fn create() -> Vec<u8> {
let mut command = BytesMut::new();
@@ -20,7 +19,7 @@ pub fn create() -> Vec<u8> {
// Convert to vector and insert the length
let mut command_as_vec = command.to_vec();
- command_as_vec.insert(0, command.len().as_(): u8 + 1);
+ command_as_vec.insert(0, command.len() as u8 + 1);
// Return bytes
command_as_vec
diff --git a/crates/whirl_server/src/cmd/commands/appear_actor.rs b/crates/whirl_server/src/cmd/commands/appear_actor.rs
index 89f0022..efdfb6d 100644
--- a/crates/whirl_server/src/cmd/commands/appear_actor.rs
+++ b/crates/whirl_server/src/cmd/commands/appear_actor.rs
@@ -2,7 +2,6 @@
// SPDX-License-Identifier: GPL-3.0-only
use bytes::{BufMut, BytesMut};
-use num_traits::AsPrimitive;
use crate::cmd::{constants::Command, extendable::Creatable};
@@ -25,16 +24,16 @@ impl Creatable for AppearActor {
command.put_i8(Command::ApprActr as i32 as i8); // Type
// Content
- command.put_i8(self.short_object_id.as_(): i8); // ObjId, why is it here? Worlds...
- command.put_u16(self.room_id.as_(): u16); // Room ID
- command.put_u16(self.x.as_(): u16); // X
- command.put_u16(self.y.as_(): u16); // Y
- command.put_u16(self.z.as_(): u16); // Z
- command.put_u16(self.direction.as_(): u16); // Direction
+ command.put_i8(self.short_object_id as i8); // ObjId, why is it here? Worlds...
+ command.put_u16(self.room_id as u16); // Room ID
+ command.put_u16(self.x as u16); // X
+ command.put_u16(self.y as u16); // Y
+ command.put_u16(self.z as u16); // Z
+ command.put_u16(self.direction as u16); // Direction
// Length
let mut command_as_vec = command.to_vec();
- command_as_vec.insert(0, command.len().as_(): u8 + 1);
+ command_as_vec.insert(0, command.len() as u8 + 1);
// Return
command_as_vec
diff --git a/crates/whirl_server/src/cmd/commands/buddy_list.rs b/crates/whirl_server/src/cmd/commands/buddy_list.rs
index 1deb442..05aae6d 100644
--- a/crates/whirl_server/src/cmd/commands/buddy_list.rs
+++ b/crates/whirl_server/src/cmd/commands/buddy_list.rs
@@ -4,7 +4,6 @@
use std::str::from_utf8;
use bytes::{BufMut, BytesMut};
-use num_traits::AsPrimitive;
use crate::cmd::extendable::{Creatable, Parsable};
@@ -20,7 +19,7 @@ impl Parsable for BuddyList {
.to_string(),
// Get the last byte
- add: data[data[0] as usize - 1].as_(): i8,
+ add: data[data[0] as usize - 1] as i8,
}
}
}
@@ -34,12 +33,12 @@ impl Creatable for BuddyList {
command.put_i8(crate::cmd::constants::Command::BuddyListNotify as i32 as i8); // Type
// Content
- command.put_u8(self.buddy.len().as_(): u8); // Buddy (name) length
+ command.put_u8(self.buddy.len() as u8); // Buddy (name) length
command.put_slice(self.buddy.as_bytes()); // Buddy (name)
- command.put_u8(self.add.as_(): u8); // "Is buddy logged on?" (?)
+ command.put_u8(self.add as u8); // "Is buddy logged on?" (?)
let mut command_as_vec = command.to_vec();
- command_as_vec.insert(0, command.len().as_(): u8 + 1);
+ command_as_vec.insert(0, command.len() as u8 + 1);
command_as_vec
}
diff --git a/crates/whirl_server/src/cmd/commands/redirect_id.rs b/crates/whirl_server/src/cmd/commands/redirect_id.rs
index dec6eb1..0771fa7 100644
--- a/crates/whirl_server/src/cmd/commands/redirect_id.rs
+++ b/crates/whirl_server/src/cmd/commands/redirect_id.rs
@@ -2,7 +2,6 @@
// SPDX-License-Identifier: GPL-3.0-only
use bytes::{BufMut, BytesMut};
-use num_traits::AsPrimitive;
use whirl_config::Config;
use crate::cmd::{constants::Command, extendable::Creatable};
@@ -22,21 +21,21 @@ impl Creatable for RedirectId {
command.put_i8(Command::RedirId as i32 as i8); // Type
// Content
- command.put_u8(self.room_name.len().as_(): u8); // Room name length
+ command.put_u8(self.room_name.len() as u8); // Room name length
command.put_slice(self.room_name.as_bytes()); // Room name
// command.put_u8(0x00); // Unimplemented byte (?)
// command.put_u8(room_id); // Room ID
- command.put_u16(self.room_number.as_(): u16); // Room ID
+ command.put_u16(self.room_number as u16); // Room ID
// IP
for byte in Config::get().whirlsplash.ip.split('.') {
command.put_u8(byte.parse::<u8>().unwrap());
}
- command.put_u16(Config::get().hub.port.as_(): u16); // Port
+ command.put_u16(Config::get().hub.port as u16); // Port
// Length
let mut command_as_vec = command.to_vec();
- command_as_vec.insert(0, command.len().as_(): u8 + 1);
+ command_as_vec.insert(0, command.len() as u8 + 1);
// Return
command_as_vec
diff --git a/crates/whirl_server/src/cmd/commands/register_object_id.rs b/crates/whirl_server/src/cmd/commands/register_object_id.rs
index 61e15a5..8e4cec7 100644
--- a/crates/whirl_server/src/cmd/commands/register_object_id.rs
+++ b/crates/whirl_server/src/cmd/commands/register_object_id.rs
@@ -2,7 +2,6 @@
// SPDX-License-Identifier: GPL-3.0-only
use bytes::{BufMut, BytesMut};
-use num_traits::AsPrimitive;
use crate::cmd::{constants::Command, extendable::Creatable};
@@ -21,13 +20,13 @@ impl Creatable for RegisterObjectId {
command.put_i8(Command::RegObjId as i32 as i8); // Type
// Content
- command.put_u8(self.long_object_id.len().as_(): u8); // Long object ID length
+ command.put_u8(self.long_object_id.len() as u8); // Long object ID length
command.put_slice(self.long_object_id.as_bytes()); // Long object ID
- command.put_i8(self.short_object_id.as_(): i8); // Short object ID
+ command.put_i8(self.short_object_id as i8); // Short object ID
// Length
let mut command_as_vec = command.to_vec();
- command_as_vec.insert(0, command.len().as_(): u8 + 1);
+ command_as_vec.insert(0, command.len() as u8 + 1);
// Return
command_as_vec
diff --git a/crates/whirl_server/src/cmd/commands/subscribe_room.rs b/crates/whirl_server/src/cmd/commands/subscribe_room.rs
index b48790a..667ae7f 100644
--- a/crates/whirl_server/src/cmd/commands/subscribe_room.rs
+++ b/crates/whirl_server/src/cmd/commands/subscribe_room.rs
@@ -3,7 +3,6 @@
use byteorder::{BigEndian, ReadBytesExt};
use bytes::{Buf, BytesMut};
-use num_traits::AsPrimitive;
use crate::cmd::extendable::Parsable;
@@ -21,11 +20,11 @@ impl Parsable for SubscribeRoom {
let mut data = BytesMut::from(data.as_slice()).reader();
Self {
- room_number: data.read_i16::<BigEndian>().unwrap().as_(): i8,
- x: f32::from(data.read_i16::<BigEndian>().unwrap().as_(): i8),
- y: f32::from(data.read_i16::<BigEndian>().unwrap().as_(): i8),
- z: f32::from(data.read_i16::<BigEndian>().unwrap().as_(): i8),
- distance: f32::from(data.read_i16::<BigEndian>().unwrap().as_(): i8), // + 100
+ room_number: data.read_i16::<BigEndian>().unwrap() as i8,
+ x: f32::from(data.read_i16::<BigEndian>().unwrap() as i8),
+ y: f32::from(data.read_i16::<BigEndian>().unwrap() as i8),
+ z: f32::from(data.read_i16::<BigEndian>().unwrap() as i8),
+ distance: f32::from(data.read_i16::<BigEndian>().unwrap() as i8), // + 100
}
}
}
diff --git a/crates/whirl_server/src/cmd/commands/teleport.rs b/crates/whirl_server/src/cmd/commands/teleport.rs
index 0357108..0493033 100644
--- a/crates/whirl_server/src/cmd/commands/teleport.rs
+++ b/crates/whirl_server/src/cmd/commands/teleport.rs
@@ -3,7 +3,6 @@
use byteorder::{BigEndian, ReadBytesExt};
use bytes::{Buf, BytesMut};
-use num_traits::AsPrimitive;
use crate::cmd::extendable::Parsable;
@@ -23,7 +22,7 @@ impl Parsable for Teleport {
let mut data = BytesMut::from(data.as_slice()).reader();
Self {
- room_id: data.read_u16::<BigEndian>().unwrap().as_(): i8,
+ room_id: data.read_u16::<BigEndian>().unwrap() as i8,
exit_type: data.read_u8().unwrap(),
entry_type: data.read_u8().unwrap(),
x: f32::from(data.read_i16::<BigEndian>().unwrap()),
diff --git a/crates/whirl_server/src/cmd/commands/text.rs b/crates/whirl_server/src/cmd/commands/text.rs
index 056d7d6..9a36521 100644
--- a/crates/whirl_server/src/cmd/commands/text.rs
+++ b/crates/whirl_server/src/cmd/commands/text.rs
@@ -4,7 +4,6 @@
use std::str::from_utf8;
use bytes::{BufMut, BytesMut};
-use num_traits::AsPrimitive;
use crate::cmd::{
constants::Command,
@@ -30,14 +29,14 @@ impl Creatable for Text {
// The below byte is suspected to be the sender's short ObjId.
command.put_i8(0x00);
- command.put_u8(self.sender.len().as_(): u8);
+ command.put_u8(self.sender.len() as u8);
command.put_slice(self.sender.as_bytes());
- command.put_u8(self.content.len().as_(): u8);
+ command.put_u8(self.content.len() as u8);
command.put_slice(self.content.as_bytes());
// Convert to vector and insert the length
let mut command_as_vec = command.to_vec();
- command_as_vec.insert(0, command.len().as_(): u8 + 1);
+ command_as_vec.insert(0, command.len() as u8 + 1);
// Return bytes
command_as_vec
diff --git a/crates/whirl_server/src/distributor.rs b/crates/whirl_server/src/distributor.rs
index 3d684ff..1213090 100644
--- a/crates/whirl_server/src/distributor.rs
+++ b/crates/whirl_server/src/distributor.rs
@@ -13,7 +13,6 @@
use std::{error::Error, net::SocketAddr, sync::Arc};
-use num_traits::cast::AsPrimitive;
use tokio::{io::AsyncWriteExt, net::TcpStream, sync::Mutex};
use tokio_stream::StreamExt;
use tokio_util::codec::{BytesCodec, Decoder};
@@ -66,7 +65,7 @@ impl Server for Distributor {
result = peer.bytes.next() => match result {
Some(Ok(msg)) => {
for msg in parse_commands_from_packet(msg) {
- match num_traits::FromPrimitive::from_i32(msg.get(2).unwrap().to_owned().as_(): i32) {
+ match num_traits::FromPrimitive::from_i32(msg.get(2).unwrap().to_owned() as i32) {
Some(Command::PropReq) => {
debug!("received property request from client");
@@ -120,7 +119,7 @@ impl Server for Distributor {
peer.bytes.get_mut().write_all(&RedirectId {
room_name: (&*room.room_name).to_string(),
- room_number: room_id.as_(): i8,
+ room_number: room_id as i8,
}.create()).await?;
trace!("sent redirect id to {}: {}", username, room.room_name);
}
diff --git a/crates/whirl_server/src/hub.rs b/crates/whirl_server/src/hub.rs
index 848862d..f271c28 100644
--- a/crates/whirl_server/src/hub.rs
+++ b/crates/whirl_server/src/hub.rs
@@ -10,7 +10,6 @@
use std::{error::Error, net::SocketAddr, sync::Arc};
-use num_traits::cast::AsPrimitive;
use tokio::{io::AsyncWriteExt, net::TcpStream, sync::Mutex};
use tokio_stream::StreamExt;
use tokio_util::codec::{BytesCodec, Decoder};
@@ -71,7 +70,7 @@ impl Server for Hub {
Some(Ok(msg)) => {
// trace!("got some bytes: {:?}", &msg);
for msg in parse_commands_from_packet(msg) {
- match num_traits::FromPrimitive::from_i32(msg.get(2).unwrap().to_owned().as_(): i32) {
+ match num_traits::FromPrimitive::from_i32(msg.get(2).unwrap().to_owned() as i32) {
Some(Command::PropReq) => {
debug!("received property request from client");
diff --git a/crates/whirl_server/src/lib.rs b/crates/whirl_server/src/lib.rs
index ad7d05e..2567cf7 100644
--- a/crates/whirl_server/src/lib.rs
+++ b/crates/whirl_server/src/lib.rs
@@ -3,13 +3,7 @@
//! Exposes the Distributor and Hub for further use.
-#![feature(
- type_ascription,
- hash_set_entry,
- type_name_of_val,
- decl_macro,
- proc_macro_hygiene
-)]
+#![feature(type_ascription, hash_set_entry, decl_macro, proc_macro_hygiene)]
#![deny(
warnings,
nonstandard_style,
@@ -24,6 +18,7 @@
html_logo_url = "https://raw.githubusercontent.com/Whirlsplash/assets/master/Whirl.png",
html_favicon_url = "https://raw.githubusercontent.com/Whirlsplash/assets/master/Whirl.png"
)]
+#![allow(non_local_definitions, dead_code)]
#[macro_use]
extern crate log;
diff --git a/crates/whirl_server/src/net/property_list.rs b/crates/whirl_server/src/net/property_list.rs
index a1c4b34..554f344 100644
--- a/crates/whirl_server/src/net/property_list.rs
+++ b/crates/whirl_server/src/net/property_list.rs
@@ -2,7 +2,6 @@
// SPDX-License-Identifier: GPL-3.0-only
use bytes::{BufMut, BytesMut};
-use num_traits::AsPrimitive;
use crate::{
cmd::constants::Command,
@@ -31,15 +30,15 @@ impl PropertyList {
let property = &property_list[0]; // Property we are currently iterating over
trace!("current prop: {}:{}", property.prop_id, property.value);
- command.put_u8(property.prop_id.as_(): u8); // Property ID
+ command.put_u8(property.prop_id as u8); // Property ID
// NOTE: THIS IS SUPER BAD DO NOT DO THIS! But it works!
if command_id == Command::PropUpd as i32 {
- command.put_u8(PROPFLAG_DBSTORE.as_(): u8); // Flag (s)
- command.put_u8(PROPACCESS_POSSESS.as_(): u8); // Access
+ command.put_u8(PROPFLAG_DBSTORE as u8); // Flag (s)
+ command.put_u8(PROPACCESS_POSSESS as u8); // Access
}
- command.put_u8(property.value.len().as_(): u8); // Property UTF-8 Length
+ command.put_u8(property.value.len() as u8); // Property UTF-8 Length
command.put_slice(property.value.as_bytes()); // Property UTF-8
property_list.reverse();
@@ -50,9 +49,9 @@ impl PropertyList {
// Convert to vector and insert the header
let mut command_as_vec = command.to_vec();
- command_as_vec.insert(0, command_id.as_(): u8); // Command ID
- command_as_vec.insert(0, obj_id.as_(): u8); // ObjId
- command_as_vec.insert(0, command.len().as_(): u8 + 3); // Data length
+ command_as_vec.insert(0, command_id as u8); // Command ID
+ command_as_vec.insert(0, obj_id as u8); // ObjId
+ command_as_vec.insert(0, command.len() as u8 + 3); // Data length
// Return bytes
command_as_vec