From 745592803eaacc34d8197f027f4e64629672b419 Mon Sep 17 00:00:00 2001 From: David Thomas Date: Tue, 5 Dec 2023 10:31:22 +0000 Subject: [PATCH 1/3] Get rid of event_handler_arc --- src/client/mod.rs | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/src/client/mod.rs b/src/client/mod.rs index 0a61031d894..9cb832a9505 100644 --- a/src/client/mod.rs +++ b/src/client/mod.rs @@ -268,18 +268,11 @@ impl ClientBuilder { } /// Adds an event handler with multiple methods for each possible event. - pub fn event_handler(mut self, event_handler: H) -> Self { - self.event_handlers.push(Arc::new(event_handler)); - - self - } - - /// Adds an event handler with multiple methods for each possible event. Passed by Arc. - pub fn event_handler_arc( - mut self, - event_handler_arc: Arc, - ) -> Self { - self.event_handlers.push(event_handler_arc); + pub fn event_handler(mut self, event_handler: impl Into>) -> Self + where + H: EventHandler + 'static, + { + self.event_handlers.push(event_handler.into()); self } From b1e41d94ebb5503f4d8629f7272e2a581488821c Mon Sep 17 00:00:00 2001 From: David Thomas Date: Tue, 5 Dec 2023 10:33:11 +0000 Subject: [PATCH 2/3] Get rid of voice_manager_arc --- src/client/mod.rs | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/src/client/mod.rs b/src/client/mod.rs index 9cb832a9505..9ec0f70fbd7 100644 --- a/src/client/mod.rs +++ b/src/client/mod.rs @@ -202,31 +202,12 @@ impl ClientBuilder { /// Sets the voice gateway handler to be used. It will receive voice events sent over the /// gateway and then consider - based on its settings - whether to dispatch a command. - /// - /// *Info*: If a reference to the voice_manager is required for manual dispatch, use the - /// [`Self::voice_manager_arc`]-method instead. #[cfg(feature = "voice")] - pub fn voice_manager(mut self, voice_manager: V) -> Self + pub fn voice_manager_arc(mut self, voice_manager: impl Into>) -> Self where V: VoiceGatewayManager + 'static, { - self.voice_manager = Some(Arc::new(voice_manager)); - - self - } - - /// This method allows to pass an [`Arc`]'ed `voice_manager` - this step is done for you in the - /// [`voice_manager`]-method, if you don't need the extra control. You can provide a clone and - /// keep the original to manually dispatch. - /// - /// [`voice_manager`]: Self::voice_manager - #[cfg(feature = "voice")] - pub fn voice_manager_arc( - mut self, - voice_manager: Arc, - ) -> Self { - self.voice_manager = Some(voice_manager); - + self.voice_manager = Some(voice_manager.into()); self } From 29925cb0de1037c290e5c6f01a88c55d846ac39a Mon Sep 17 00:00:00 2001 From: Gnome! Date: Fri, 8 Dec 2023 11:10:28 +0000 Subject: [PATCH 3/3] Fix small whoopsie Co-authored-by: Alex M. M. --- src/client/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/mod.rs b/src/client/mod.rs index 9ec0f70fbd7..0074c50193e 100644 --- a/src/client/mod.rs +++ b/src/client/mod.rs @@ -203,7 +203,7 @@ impl ClientBuilder { /// Sets the voice gateway handler to be used. It will receive voice events sent over the /// gateway and then consider - based on its settings - whether to dispatch a command. #[cfg(feature = "voice")] - pub fn voice_manager_arc(mut self, voice_manager: impl Into>) -> Self + pub fn voice_manager(mut self, voice_manager: impl Into>) -> Self where V: VoiceGatewayManager + 'static, {