aboutsummaryrefslogtreecommitdiffstats
path: root/mumd/src/state.rs
diff options
context:
space:
mode:
authorEskil Queseth <eskilq@kth.se>2021-06-14 13:44:08 +0200
committerEskil Queseth <eskilq@kth.se>2021-06-14 13:44:08 +0200
commitf24f23faa240053b7ac8f65b69ff8d1ae0ad3ea1 (patch)
treeb3c6406951d9e09836336290b63ceaa9d7efc04b /mumd/src/state.rs
parentf4beab72096060f513d6b22c0ee891688595dcbd (diff)
downloadmum-f24f23faa240053b7ac8f65b69ff8d1ae0ad3ea1.tar.gz
clippy
Diffstat (limited to 'mumd/src/state.rs')
-rw-r--r--mumd/src/state.rs23
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 {