aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFuwn <[email protected]>2024-06-12 01:38:03 +0000
committerFuwn <[email protected]>2024-06-12 01:38:03 +0000
commit85ea8e518291d58d086f2b56bd9b76c79555aa70 (patch)
tree6d98d99fc11d0b826b6bb170583802c1b34160c5
parentfeat(whirl_server): short object id sending (diff)
downloadwhirl-85ea8e518291d58d086f2b56bd9b76c79555aa70.tar.xz
whirl-85ea8e518291d58d086f2b56bd9b76c79555aa70.zip
refactor(buddy_list): clearer naming
-rw-r--r--crates/whirl_server/src/cmd/commands/buddy_list.rs22
1 files changed, 11 insertions, 11 deletions
diff --git a/crates/whirl_server/src/cmd/commands/buddy_list.rs b/crates/whirl_server/src/cmd/commands/buddy_list.rs
index f8c76f6..6e103e3 100644
--- a/crates/whirl_server/src/cmd/commands/buddy_list.rs
+++ b/crates/whirl_server/src/cmd/commands/buddy_list.rs
@@ -1,4 +1,4 @@
-// Copyright (C) 2021-2021 The Whirlsplash Collective
+// Copyright (C) 2021-2024 The Whirlsplash Collective
// SPDX-License-Identifier: GPL-3.0-only
use {
@@ -8,16 +8,16 @@ use {
};
pub struct BuddyList {
- pub buddy: String,
- pub add: i8,
+ pub buddy: String,
+ pub add_or_logged_on: i8,
}
impl Parsable for BuddyList {
fn parse(data: Vec<u8>) -> Self {
Self {
- buddy: from_utf8(&data[4..data[0] as usize - 1]).unwrap().to_string(),
-
- // Get the last byte
- add: data[data[0] as usize - 1] as i8,
+ buddy: from_utf8(&data[4..data[0] as usize - 1])
+ .unwrap()
+ .to_string(),
+ add_or_logged_on: data[data[0] as usize - 1] as i8,
}
}
}
@@ -26,17 +26,17 @@ impl Creatable for BuddyList {
let mut command = BytesMut::new();
// Header
- command.put_u8(0x01); // ObjId
+ command.put_u8(0x01); // Object ID
#[allow(clippy::cast_possible_truncation)]
command
- .put_i8(crate::cmd::constants::Command::BuddyListNotify as i32 as i8); // Type
-
+ .put_i8(crate::cmd::constants::Command::BuddyListNotify as i32 as i8); // Command type
// Content
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_or_logged_on 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