diff options
Diffstat (limited to 'mumd/src/state.rs')
| -rw-r--r-- | mumd/src/state.rs | 23 |
1 files changed, 9 insertions, 14 deletions
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<dyn Iterator<Item = mumlib::error::Result<Option<CommandResponse>>>>; +type TcpEventCallback = Box<dyn FnOnce(TcpEventData<'_>) -> Responses>; +type TcpEventSubscriberCallback = Box<dyn FnMut(TcpEventData<'_>,&mut mpsc::UnboundedSender<mumlib::error::Result<Option<CommandResponse>>>,) -> bool>; + //TODO give me a better name pub enum ExecutionContext { - TcpEventCallback(Vec<(TcpEvent, Box<dyn FnOnce(TcpEventData<'_>) -> Responses>)>), - TcpEventSubscriber( - TcpEvent, - Box< - dyn FnMut( - TcpEventData<'_>, - &mut mpsc::UnboundedSender<mumlib::error::Result<Option<CommandResponse>>>, - ) -> bool, - >, - ), + TcpEventCallback(Vec<(TcpEvent, TcpEventCallback)>), + TcpEventSubscriber(TcpEvent, TcpEventSubscriberCallback), Now(Box<dyn FnOnce() -> Responses>), Ping( Box<dyn FnOnce() -> mumlib::error::Result<SocketAddr>>, @@ -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 { |
