diff options
| -rw-r--r-- | mumctl/src/main.rs | 59 | ||||
| -rw-r--r-- | mumd/src/audio/output.rs | 7 | ||||
| -rw-r--r-- | mumd/src/state.rs | 16 | ||||
| -rw-r--r-- | mumlib/src/error.rs | 4 | ||||
| -rw-r--r-- | mumlib/src/state.rs | 25 |
5 files changed, 68 insertions, 43 deletions
diff --git a/mumctl/src/main.rs b/mumctl/src/main.rs index 478ecaa..22e08ec 100644 --- a/mumctl/src/main.rs +++ b/mumctl/src/main.rs @@ -111,30 +111,32 @@ fn main() { .arg(Arg::with_name("user").required(true)) .setting(AppSettings::SubcommandsNegateReqs), ) - .subcommand(SubCommand::with_name("mute") - .subcommand(SubCommand::with_name("true") - .alias("1")) - .subcommand(SubCommand::with_name("false") - .alias("0")) - .subcommand(SubCommand::with_name("toggle")) - .setting(AppSettings::SubcommandRequiredElseHelp)) - .subcommand(SubCommand::with_name("deafen") - .subcommand(SubCommand::with_name("true") - .alias("1")) - .subcommand(SubCommand::with_name("false") - .alias("0")) - .subcommand(SubCommand::with_name("toggle")) - .setting(AppSettings::SubcommandRequiredElseHelp)) - .subcommand(SubCommand::with_name("user") - .arg(Arg::with_name("user").required(true)) - .subcommand(SubCommand::with_name("mute") - .subcommand(SubCommand::with_name("true") - .alias("1")) - .subcommand(SubCommand::with_name("false") - .alias("0")) + .subcommand( + SubCommand::with_name("mute") + .subcommand(SubCommand::with_name("true").alias("1")) + .subcommand(SubCommand::with_name("false").alias("0")) .subcommand(SubCommand::with_name("toggle")) - .setting(AppSettings::SubcommandRequiredElseHelp)) - .setting(AppSettings::SubcommandRequiredElseHelp)); + .setting(AppSettings::SubcommandRequiredElseHelp), + ) + .subcommand( + SubCommand::with_name("deafen") + .subcommand(SubCommand::with_name("true").alias("1")) + .subcommand(SubCommand::with_name("false").alias("0")) + .subcommand(SubCommand::with_name("toggle")) + .setting(AppSettings::SubcommandRequiredElseHelp), + ) + .subcommand( + SubCommand::with_name("user") + .arg(Arg::with_name("user").required(true)) + .subcommand( + SubCommand::with_name("mute") + .subcommand(SubCommand::with_name("true").alias("1")) + .subcommand(SubCommand::with_name("false").alias("0")) + .subcommand(SubCommand::with_name("toggle")) + .setting(AppSettings::SubcommandRequiredElseHelp), + ) + .setting(AppSettings::SubcommandRequiredElseHelp), + ); let matches = app.clone().get_matches(); @@ -155,7 +157,8 @@ fn main() { if config.servers.len() == 0 { println!("{} No servers in config", "warning:".yellow()); } - for (server, response) in config.servers + for (server, response) in config + .servers .iter() .map(|e| { let response = send_command(Command::ServerStatus { @@ -251,8 +254,8 @@ fn main() { //needs work on mumd to implement } } else if let Some(matches) = matches.subcommand_matches("mute") { - let command = Command::MuteSelf( - if let Some(_matches) = matches.subcommand_matches("true") { + let command = + Command::MuteSelf(if let Some(_matches) = matches.subcommand_matches("true") { Some(true) } else if let Some(_matches) = matches.subcommand_matches("false") { Some(false) @@ -263,8 +266,8 @@ fn main() { }); err_print!(send_command(command)); } else if let Some(matches) = matches.subcommand_matches("deafen") { - let command = Command::DeafenSelf( - if let Some(_matches) = matches.subcommand_matches("true") { + let command = + Command::DeafenSelf(if let Some(_matches) = matches.subcommand_matches("true") { Some(true) } else if let Some(_matches) = matches.subcommand_matches("false") { Some(false) diff --git a/mumd/src/audio/output.rs b/mumd/src/audio/output.rs index 450bcc8..ce116a8 100644 --- a/mumd/src/audio/output.rs +++ b/mumd/src/audio/output.rs @@ -85,7 +85,12 @@ pub fn curry_callback<T: Sample + AddAssign + SaturatingAdd>( let mut lock = buf.lock().unwrap(); for (id, client_stream) in &mut *lock { - let (user_volume, muted) = user_volumes.lock().unwrap().get(id).cloned().unwrap_or((1.0, false)); + let (user_volume, muted) = user_volumes + .lock() + .unwrap() + .get(id) + .cloned() + .unwrap_or((1.0, false)); for sample in data.iter_mut() { let s = client_stream.buffer.pop_front().unwrap_or(0.0) * volume * user_volume; if !muted { diff --git a/mumd/src/state.rs b/mumd/src/state.rs index f04e6f1..5781df3 100644 --- a/mumd/src/state.rs +++ b/mumd/src/state.rs @@ -71,7 +71,8 @@ impl State { let config = mumlib::config::read_default_cfg(); let audio = Audio::new( config.audio.input_volume.unwrap_or(1.0), - config.audio.output_volume.unwrap_or(1.0)); + config.audio.output_volume.unwrap_or(1.0), + ); let mut state = Self { config, server: None, @@ -245,7 +246,7 @@ impl State { None } } - None => Some(!self.server().unwrap().deafened()) + None => Some(!self.server().unwrap().deafened()), }; if let Some(action) = action { @@ -273,7 +274,7 @@ impl State { None } } - None => Some(!self.server().unwrap().muted()) + None => Some(!self.server().unwrap().muted()), }; if let Some(action) = action { @@ -293,7 +294,12 @@ impl State { return now!(Err(Error::DisconnectedError)); } - let id = self.server_mut().unwrap().users_mut().iter_mut().find(|(_, user)| user.name() == &string); + let id = self + .server_mut() + .unwrap() + .users_mut() + .iter_mut() + .find(|(_, user)| user.name() == &string); let (id, user) = match id { Some(id) => (*id.0, id.1), @@ -308,7 +314,7 @@ impl State { None } } - None => Some(!user.suppressed()) + None => Some(!user.suppressed()), }; debug!("{:?}", action); diff --git a/mumlib/src/error.rs b/mumlib/src/error.rs index c9eff52..5b82fbd 100644 --- a/mumlib/src/error.rs +++ b/mumlib/src/error.rs @@ -20,7 +20,9 @@ impl Display for Error { Error::DisconnectedError => write!(f, "Not connected to a server"), Error::AlreadyConnectedError => write!(f, "Already connected to a server"), Error::ChannelIdentifierError(id, kind) => write!(f, "{}: {}", kind, id), - Error::InvalidServerAddrError(addr, port) => write!(f, "Invalid server address: {}: {}", addr, port), + Error::InvalidServerAddrError(addr, port) => { + write!(f, "Invalid server address: {}: {}", addr, port) + } Error::InvalidUserIdentifierError(name) => write!(f, "Invalid username: {}", name), Error::InvalidUsernameError(username) => write!(f, "Invalid username: {}", username), } diff --git a/mumlib/src/state.rs b/mumlib/src/state.rs index 0540f14..3b1da56 100644 --- a/mumlib/src/state.rs +++ b/mumlib/src/state.rs @@ -131,18 +131,27 @@ pub struct User { } macro_rules! true_to_str { - ($condition:expr, $res:expr) => {if $condition { $res } else { "" }}; + ($condition:expr, $res:expr) => { + if $condition { + $res + } else { + "" + } + }; } impl Display for User { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { - write!(f, "{} {}{}{}{}{}", - self.name, - true_to_str!(self.suppress, "s"), - true_to_str!(self.self_mute, "M"), - true_to_str!(self.self_deaf, "D"), - true_to_str!(self.mute, "m"), - true_to_str!(self.deaf, "d")) + write!( + f, + "{} {}{}{}{}{}", + self.name, + true_to_str!(self.suppress, "s"), + true_to_str!(self.self_mute, "M"), + true_to_str!(self.self_deaf, "D"), + true_to_str!(self.mute, "m"), + true_to_str!(self.deaf, "d") + ) } } |
