aboutsummaryrefslogtreecommitdiff
path: root/src/server/cmd/commands/text/create.rs
diff options
context:
space:
mode:
authorFuwn <[email protected]>2021-04-30 17:59:18 +0000
committerFuwn <[email protected]>2021-04-30 17:59:18 +0000
commit5ec0a47413d8623660156dc4049f98dffee7b35b (patch)
treeb1f5d5b860ffd48ad9c36fdc8b378bb1326d855e /src/server/cmd/commands/text/create.rs
parentfeat(hub): *implement* new commands; subscribe room, subscribe distance, tele... (diff)
downloadwhirl-5ec0a47413d8623660156dc4049f98dffee7b35b.tar.xz
whirl-5ec0a47413d8623660156dc4049f98dffee7b35b.zip
refactor(cmds): more orphan module functions to methods within struct
The rest of the current commands will also receive this refactor... when I have time.
Diffstat (limited to 'src/server/cmd/commands/text/create.rs')
-rw-r--r--src/server/cmd/commands/text/create.rs31
1 files changed, 0 insertions, 31 deletions
diff --git a/src/server/cmd/commands/text/create.rs b/src/server/cmd/commands/text/create.rs
deleted file mode 100644
index 8fa8cbb..0000000
--- a/src/server/cmd/commands/text/create.rs
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyleft (ɔ) 2021-2021 The Whirlsplash Collective
-// SPDX-License-Identifier: GPL-3.0-only
-
-use bytes::{BufMut, BytesMut};
-
-use crate::server::cmd::{commands::text::structure::Text, constants::TEXT};
-
-pub fn create_text(text: Text) -> Vec<u8> {
- let mut command = BytesMut::new();
-
- // Header
- command.put_u8(0x01);
- command.put_u8(TEXT as u8);
-
- // Content
- // The fourth and fifth elements are presumed to be interpreted as a short by
- // the client, however, usernames aren't (?) allowed to be long enough that
- // they reach a number high enough to be converted to a short.
- command.put_u8(0x00);
- command.put_u8(text.sender.len() as u8);
- command.put_slice(text.sender.as_bytes());
- command.put_u8(text.content.len() as u8);
- command.put_slice(text.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);
-
- // Return bytes
- command_as_vec
-}