From 85c1f17d451cf30800ea2f027bcbd15074451a78 Mon Sep 17 00:00:00 2001 From: Eskil Queseth Date: Sun, 13 Jun 2021 19:15:22 +0200 Subject: add elided-liftimes-in-paths lint --- mumd/src/state.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'mumd/src/state.rs') diff --git a/mumd/src/state.rs b/mumd/src/state.rs index d2d77b1..9d9e1c6 100644 --- a/mumd/src/state.rs +++ b/mumd/src/state.rs @@ -44,12 +44,12 @@ type Responses = Box Responses>)>), + TcpEventCallback(Vec<(TcpEvent, Box) -> Responses>)>), TcpEventSubscriber( TcpEvent, Box< dyn FnMut( - TcpEventData, + TcpEventData<'_>, &mut mpsc::UnboundedSender>>, ) -> bool, >, -- cgit v1.2.1 From 1f41a6b9a439bab3f05e464d621eb3607116646e Mon Sep 17 00:00:00 2001 From: Eskil Queseth Date: Sun, 13 Jun 2021 19:19:31 +0200 Subject: add meta_variable_misuse lint --- mumd/src/state.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mumd/src/state.rs') diff --git a/mumd/src/state.rs b/mumd/src/state.rs index 9d9e1c6..38d54d3 100644 --- a/mumd/src/state.rs +++ b/mumd/src/state.rs @@ -29,7 +29,7 @@ use tokio::sync::{mpsc, watch}; macro_rules! at { ( $( $event:expr => $generator:expr ),+ $(,)? ) => { ExecutionContext::TcpEventCallback(vec![ - $( ($event, Box::new($generator)), )* + $( ($event, Box::new($generator)), )+ ]) }; } -- cgit v1.2.1 From 465f21da46a7194e25894043ca2cca9ba958e11c Mon Sep 17 00:00:00 2001 From: Eskil Queseth Date: Sun, 13 Jun 2021 20:48:54 +0200 Subject: add unreachable_pub lint and fix debug impl --- mumd/src/state.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'mumd/src/state.rs') diff --git a/mumd/src/state.rs b/mumd/src/state.rs index 38d54d3..82810de 100644 --- a/mumd/src/state.rs +++ b/mumd/src/state.rs @@ -20,6 +20,7 @@ use mumlib::command::{ChannelTarget, Command, CommandResponse, MessageTarget, Mu use mumlib::config::Config; use mumlib::Error; use std::{ + fmt::Debug, iter, net::{SocketAddr, ToSocketAddrs}, sync::{Arc, RwLock}, @@ -63,6 +64,17 @@ pub enum ExecutionContext { ), } +impl Debug for ExecutionContext { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_tuple(match self { + ExecutionContext::TcpEventCallback(_) => "TcpEventCallback", + ExecutionContext::TcpEventSubscriber(_, _) => "TcpEventSubscriber", + ExecutionContext::Now(_) => "Now", + ExecutionContext::Ping(_, _) => "Ping", + }).finish() + } +} + #[derive(Clone, Copy, Debug, Eq, PartialEq)] pub enum StatePhase { Disconnected, @@ -70,6 +82,7 @@ pub enum StatePhase { Connected(VoiceStreamType), } +#[derive(Debug)] pub struct State { config: Config, server: Option, -- cgit v1.2.1 From f24f23faa240053b7ac8f65b69ff8d1ae0ad3ea1 Mon Sep 17 00:00:00 2001 From: Eskil Queseth Date: Mon, 14 Jun 2021 13:44:08 +0200 Subject: clippy --- mumd/src/state.rs | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) (limited to 'mumd/src/state.rs') diff --git a/mumd/src/state.rs b/mumd/src/state.rs index 82810de..a1344a1 100644 --- a/mumd/src/state.rs +++ b/mumd/src/state.rs @@ -43,18 +43,13 @@ macro_rules! now { type Responses = Box>>>; +type TcpEventCallback = Box) -> Responses>; +type TcpEventSubscriberCallback = Box,&mut mpsc::UnboundedSender>>,) -> bool>; + //TODO give me a better name pub enum ExecutionContext { - TcpEventCallback(Vec<(TcpEvent, Box) -> Responses>)>), - TcpEventSubscriber( - TcpEvent, - Box< - dyn FnMut( - TcpEventData<'_>, - &mut mpsc::UnboundedSender>>, - ) -> bool, - >, - ), + TcpEventCallback(Vec<(TcpEvent, TcpEventCallback)>), + TcpEventSubscriber(TcpEvent, TcpEventSubscriberCallback), Now(Box Responses>), Ping( Box mumlib::error::Result>, @@ -103,9 +98,9 @@ impl State { config.audio.input_volume.unwrap_or(1.0), phase_watcher.1.clone(), ) - .map_err(|e| StateError::AudioError(e))?; + .map_err(StateError::AudioError)?; let audio_output = AudioOutput::new(config.audio.output_volume.unwrap_or(1.0)) - .map_err(|e| StateError::AudioError(e))?; + .map_err(StateError::AudioError)?; let mut state = Self { config, server: None, @@ -321,7 +316,7 @@ impl State { } pub fn initialized(&self) { - self.broadcast_phase(StatePhase::Connected(VoiceStreamType::TCP)); + self.broadcast_phase(StatePhase::Connected(VoiceStreamType::Tcp)); self.audio_output .play_effect(NotificationEvents::ServerConnect); } @@ -786,7 +781,7 @@ pub fn handle_command( .unwrap() .users() .iter() - .find(|(_, user)| user.name() == &name) + .find(|(_, user)| user.name() == name) .map(|(e, _)| *e); let id = match id { -- cgit v1.2.1 From 9aca7a8c930b179b6ae539234296f529928a3f3a Mon Sep 17 00:00:00 2001 From: Eskil Queseth Date: Sat, 19 Jun 2021 19:13:11 +0200 Subject: add line breaks --- mumd/src/state.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'mumd/src/state.rs') diff --git a/mumd/src/state.rs b/mumd/src/state.rs index a1344a1..1992884 100644 --- a/mumd/src/state.rs +++ b/mumd/src/state.rs @@ -44,7 +44,12 @@ macro_rules! now { type Responses = Box>>>; type TcpEventCallback = Box) -> Responses>; -type TcpEventSubscriberCallback = Box,&mut mpsc::UnboundedSender>>,) -> bool>; +type TcpEventSubscriberCallback = Box< + dyn FnMut( + TcpEventData<'_>, + &mut mpsc::UnboundedSender>>, + ) -> bool +>; //TODO give me a better name pub enum ExecutionContext { -- cgit v1.2.1