aboutsummaryrefslogtreecommitdiffstats
path: root/mumd/src/main.rs
diff options
context:
space:
mode:
authorGustav Sörnäs <gustav@sornas.net>2021-06-06 23:26:24 +0200
committerGustav Sörnäs <gustav@sornas.net>2021-06-06 23:26:24 +0200
commitbe76c2aa51733a0cf495e92659fbcbe527f41149 (patch)
tree617fb1caa999c076a45233b4bedea6a78192db25 /mumd/src/main.rs
parent7fc5a1a36404ee4cbc09d20c955e6edd3d2ac523 (diff)
downloadmum-be76c2aa51733a0cf495e92659fbcbe527f41149.tar.gz
cargo fmt
Diffstat (limited to 'mumd/src/main.rs')
-rw-r--r--mumd/src/main.rs22
1 files changed, 16 insertions, 6 deletions
diff --git a/mumd/src/main.rs b/mumd/src/main.rs
index 0c175c2..bc72779 100644
--- a/mumd/src/main.rs
+++ b/mumd/src/main.rs
@@ -14,12 +14,18 @@ use log::*;
use mumlib::command::{Command, CommandResponse};
use mumlib::setup_logger;
use std::io::ErrorKind;
-use tokio::{net::{UnixListener, UnixStream}, sync::mpsc};
+use tokio::{
+ net::{UnixListener, UnixStream},
+ sync::mpsc,
+};
use tokio_util::codec::{FramedRead, FramedWrite, LengthDelimitedCodec};
#[tokio::main]
async fn main() {
- if std::env::args().find(|s| s.as_str() == "--version").is_some() {
+ if std::env::args()
+ .find(|s| s.as_str() == "--version")
+ .is_some()
+ {
println!("mumd {}", env!("VERSION"));
return;
}
@@ -38,7 +44,10 @@ async fn main() {
bincode::serialize_into((&mut command).writer(), &Command::Ping).unwrap();
if let Ok(()) = writer.send(command.freeze()).await {
if let Some(Ok(buf)) = reader.next().await {
- if let Ok(Ok::<Option<CommandResponse>, mumlib::Error>(Some(CommandResponse::Pong))) = bincode::deserialize(&buf) {
+ if let Ok(Ok::<Option<CommandResponse>, mumlib::Error>(Some(
+ CommandResponse::Pong,
+ ))) = bincode::deserialize(&buf)
+ {
error!("Another instance of mumd is already running");
return;
}
@@ -94,7 +103,7 @@ async fn receive_commands(
let (reader, writer) = incoming.into_split();
let mut reader = FramedRead::new(reader, LengthDelimitedCodec::new());
let mut writer = FramedWrite::new(writer, LengthDelimitedCodec::new());
-
+
while let Some(next) = reader.next().await {
let buf = match next {
Ok(buf) => buf,
@@ -115,8 +124,9 @@ async fn receive_commands(
bincode::serialize_into((&mut serialized).writer(), &response).unwrap();
if let Err(e) = writer.send(serialized.freeze()).await {
- if e.kind() != ErrorKind::BrokenPipe { //if the client closed the connection, ignore logging the error
- //we just assume that they just don't want any more packets
+ if e.kind() != ErrorKind::BrokenPipe {
+ //if the client closed the connection, ignore logging the error
+ //we just assume that they just don't want any more packets
error!("Error sending response: {:?}", e);
}
break;