aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFuwn <[email protected]>2021-05-27 12:09:18 +0000
committerFuwn <[email protected]>2021-05-27 12:09:18 +0000
commita82a69c53f064fbeb4715db4ce7e973991bab4b7 (patch)
treecbe691e7dc46d82315a7bece38a92ee3deb838f7
parentstyle(cli): remove unneeded else branch (diff)
downloadwhirl-a82a69c53f064fbeb4715db4ce7e973991bab4b7.tar.xz
whirl-a82a69c53f064fbeb4715db4ce7e973991bab4b7.zip
fix(server): create method no longer moves self, but takes reference
-rw-r--r--crates/whirl_server/src/cmd/commands/buddy_list.rs2
-rw-r--r--crates/whirl_server/src/cmd/commands/redirect_id.rs2
-rw-r--r--crates/whirl_server/src/cmd/commands/text.rs2
-rw-r--r--crates/whirl_server/src/cmd/extendable.rs2
-rw-r--r--crates/whirl_server/src/distributor.rs2
-rw-r--r--crates/whirl_server/src/hub.rs2
6 files changed, 6 insertions, 6 deletions
diff --git a/crates/whirl_server/src/cmd/commands/buddy_list.rs b/crates/whirl_server/src/cmd/commands/buddy_list.rs
index 931db52..14e65bb 100644
--- a/crates/whirl_server/src/cmd/commands/buddy_list.rs
+++ b/crates/whirl_server/src/cmd/commands/buddy_list.rs
@@ -28,7 +28,7 @@ impl Parsable for BuddyList {
}
}
impl Creatable for BuddyList {
- fn create(self) -> Vec<u8> {
+ fn create(&self) -> Vec<u8> {
let mut command = BytesMut::new();
// Header
diff --git a/crates/whirl_server/src/cmd/commands/redirect_id.rs b/crates/whirl_server/src/cmd/commands/redirect_id.rs
index 8f56c86..942c06d 100644
--- a/crates/whirl_server/src/cmd/commands/redirect_id.rs
+++ b/crates/whirl_server/src/cmd/commands/redirect_id.rs
@@ -12,7 +12,7 @@ pub struct RedirectId {
pub room_number: i8,
}
impl Creatable for RedirectId {
- fn create(self) -> Vec<u8> {
+ fn create(&self) -> Vec<u8> {
let mut command = BytesMut::new();
// Header
diff --git a/crates/whirl_server/src/cmd/commands/text.rs b/crates/whirl_server/src/cmd/commands/text.rs
index 2bf7e17..9f3fb00 100644
--- a/crates/whirl_server/src/cmd/commands/text.rs
+++ b/crates/whirl_server/src/cmd/commands/text.rs
@@ -15,7 +15,7 @@ pub struct Text {
pub content: String,
}
impl Creatable for Text {
- fn create(self) -> Vec<u8> {
+ fn create(&self) -> Vec<u8> {
let mut command = BytesMut::new();
// Header
diff --git a/crates/whirl_server/src/cmd/extendable.rs b/crates/whirl_server/src/cmd/extendable.rs
index e6f3c2b..2bf4d6e 100644
--- a/crates/whirl_server/src/cmd/extendable.rs
+++ b/crates/whirl_server/src/cmd/extendable.rs
@@ -6,7 +6,7 @@ pub trait Parsable {
}
pub trait Creatable {
- fn create(self) -> Vec<u8>;
+ fn create(&self) -> Vec<u8>;
}
/// Having to do this makes me with there was operator overloading in Rust.
diff --git a/crates/whirl_server/src/distributor.rs b/crates/whirl_server/src/distributor.rs
index 3aae901..a22316e 100644
--- a/crates/whirl_server/src/distributor.rs
+++ b/crates/whirl_server/src/distributor.rs
@@ -98,7 +98,7 @@ impl Server for Distributor {
BUDDYLISTUPDATE => {
let buddy = BuddyList::parse(msg.to_vec());
debug!("received buddy list update from {}: {}", username, buddy.buddy);
- peer.bytes.get_mut().write_all(&buddy.clone().create()).await?;
+ peer.bytes.get_mut().write_all(&buddy.create()).await?;
trace!("sent buddy list notify to {}: {}", username, buddy.buddy);
}
ROOMIDRQ => {
diff --git a/crates/whirl_server/src/hub.rs b/crates/whirl_server/src/hub.rs
index 10f3518..55c23eb 100644
--- a/crates/whirl_server/src/hub.rs
+++ b/crates/whirl_server/src/hub.rs
@@ -98,7 +98,7 @@ impl Server for Hub {
BUDDYLISTUPDATE => {
let buddy = BuddyList::parse(msg.to_vec());
debug!("received buddy list update from {}: {}", username, buddy.buddy);
- peer.bytes.get_mut().write_all(&buddy.clone().create()).await?;
+ peer.bytes.get_mut().write_all(&buddy.create()).await?;
trace!("sent buddy list notify to {}: {}", username, buddy.buddy);
}
// TODO: Figure out if this is actually even needed.