aboutsummaryrefslogtreecommitdiff
path: root/crates/whirl_server/src/interaction
diff options
context:
space:
mode:
authorFuwn <[email protected]>2024-06-03 15:23:14 -0700
committerFuwn <[email protected]>2024-06-03 15:23:14 -0700
commit19010055c88fd7aac23f3ce39fa6a5ec1cbf9a52 (patch)
tree22353b8c7a78b83c992b7bfb60c024fee6f78e3e /crates/whirl_server/src/interaction
parentchore(rustfmt): add new rules (diff)
downloadwhirl-19010055c88fd7aac23f3ce39fa6a5ec1cbf9a52.tar.xz
whirl-19010055c88fd7aac23f3ce39fa6a5ec1cbf9a52.zip
format: rustfmt with new rules
Diffstat (limited to 'crates/whirl_server/src/interaction')
-rw-r--r--crates/whirl_server/src/interaction/peer.rs25
-rw-r--r--crates/whirl_server/src/interaction/shared.rs10
2 files changed, 12 insertions, 23 deletions
diff --git a/crates/whirl_server/src/interaction/peer.rs b/crates/whirl_server/src/interaction/peer.rs
index e12c075..9993c7b 100644
--- a/crates/whirl_server/src/interaction/peer.rs
+++ b/crates/whirl_server/src/interaction/peer.rs
@@ -1,15 +1,15 @@
// Copyright (C) 2021-2021 The Whirlsplash Collective
// SPDX-License-Identifier: GPL-3.0-only
-use std::sync::Arc;
-
-use tokio::{
- net::TcpStream,
- sync::{mpsc, Mutex},
+use {
+ crate::interaction::shared::Shared,
+ std::sync::Arc,
+ tokio::{
+ net::TcpStream,
+ sync::{mpsc, Mutex},
+ },
+ tokio_util::codec::{BytesCodec, Framed},
};
-use tokio_util::codec::{BytesCodec, Framed};
-
-use crate::interaction::shared::Shared;
pub struct Peer {
pub bytes: Framed<TcpStream, BytesCodec>,
@@ -24,10 +24,7 @@ impl Peer {
let (tx, rx) = mpsc::unbounded_channel();
state.lock().await.peers.insert(username, tx);
- Ok(Self {
- bytes,
- rx,
- })
+ Ok(Self { bytes, rx })
}
pub async fn _change_username(
@@ -42,8 +39,6 @@ impl Peer {
}
// Add the peer back with the new username
- Self::new(state, self.bytes, new_username.to_string())
- .await
- .unwrap();
+ Self::new(state, self.bytes, new_username.to_string()).await.unwrap();
}
}
diff --git a/crates/whirl_server/src/interaction/shared.rs b/crates/whirl_server/src/interaction/shared.rs
index eb712b4..fc8674e 100644
--- a/crates/whirl_server/src/interaction/shared.rs
+++ b/crates/whirl_server/src/interaction/shared.rs
@@ -1,19 +1,13 @@
// Copyright (C) 2021-2021 The Whirlsplash Collective
// SPDX-License-Identifier: GPL-3.0-only
-use std::collections::HashMap;
-
-use bytes::BytesMut;
+use {bytes::BytesMut, std::collections::HashMap};
pub struct Shared {
pub peers: HashMap<String, tokio::sync::mpsc::UnboundedSender<BytesMut>>,
}
impl Shared {
- pub fn new() -> Self {
- Self {
- peers: HashMap::new(),
- }
- }
+ pub fn new() -> Self { Self { peers: HashMap::new() } }
pub async fn broadcast(&mut self, message: &[u8]) {
for peer in &mut self.peers {