aboutsummaryrefslogtreecommitdiff
path: root/crates/whirl_server/src/net
diff options
context:
space:
mode:
authorFuwn <[email protected]>2021-05-28 00:06:40 -0700
committerFuwn <[email protected]>2021-05-28 00:06:40 -0700
commit179ce3277ece536cae41b834469f4065e3600d82 (patch)
treea96d55a34531c9761f6309c35f8d9cfab9879db6 /crates/whirl_server/src/net
parentMerge branch 'develop' of https://github.com/Whirlsplash/whirl into develop (diff)
downloadwhirl-179ce3277ece536cae41b834469f4065e3600d82.tar.xz
whirl-179ce3277ece536cae41b834469f4065e3600d82.zip
fix(global): a lot of clippy warnings
This change makes clippy **a lot** more strict.
Diffstat (limited to 'crates/whirl_server/src/net')
-rw-r--r--crates/whirl_server/src/net/converter.rs15
-rw-r--r--crates/whirl_server/src/net/property_parser.rs2
-rw-r--r--crates/whirl_server/src/net/structure.rs2
3 files changed, 10 insertions, 9 deletions
diff --git a/crates/whirl_server/src/net/converter.rs b/crates/whirl_server/src/net/converter.rs
index c976dff..d337d1a 100644
--- a/crates/whirl_server/src/net/converter.rs
+++ b/crates/whirl_server/src/net/converter.rs
@@ -2,6 +2,7 @@
// SPDX-License-Identifier: GPL-3.0-only
use bytes::{BufMut, BytesMut};
+use num_traits::AsPrimitive;
use crate::{
cmd::constants::PROPUPD,
@@ -29,15 +30,15 @@ pub fn property_list_to_bytes(
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 == PROPUPD {
- 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();
@@ -48,9 +49,9 @@ pub fn property_list_to_bytes(
// 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
diff --git a/crates/whirl_server/src/net/property_parser.rs b/crates/whirl_server/src/net/property_parser.rs
index bce457d..ac363d2 100644
--- a/crates/whirl_server/src/net/property_parser.rs
+++ b/crates/whirl_server/src/net/property_parser.rs
@@ -23,7 +23,7 @@ pub fn parse_network_property(mut data: Vec<u8>) -> Vec<NetworkProperty> {
let property_length = data[1] + 2;
property_list.push(NetworkProperty {
- prop_id: data[0] as i32,
+ prop_id: i32::from(data[0]),
value: from_utf8(&data[2..data[1] as usize + 2])
.unwrap()
.to_string(),
diff --git a/crates/whirl_server/src/net/structure.rs b/crates/whirl_server/src/net/structure.rs
index 8c9d137..1549340 100644
--- a/crates/whirl_server/src/net/structure.rs
+++ b/crates/whirl_server/src/net/structure.rs
@@ -10,7 +10,7 @@ pub struct NetworkProperty {
// }
impl Default for NetworkProperty {
fn default() -> Self {
- NetworkProperty {
+ Self {
prop_id: 0,
value: "".to_string(),
}