From be76c2aa51733a0cf495e92659fbcbe527f41149 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20S=C3=B6rn=C3=A4s?= Date: Sun, 6 Jun 2021 23:26:24 +0200 Subject: cargo fmt --- mumd/src/main.rs | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'mumd/src/main.rs') 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::, mumlib::Error>(Some(CommandResponse::Pong))) = bincode::deserialize(&buf) { + if let Ok(Ok::, 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; -- cgit v1.2.1