Skip to content

Conversation

@DPlayer234
Copy link
Contributor

@DPlayer234 DPlayer234 commented Oct 11, 2025

Rather than having the ClientBuilder accept impl Into<Arc<H>> where H: HandlerTrait, directly accept the corresponding Arc<dyn HandlerTrait>.
This allows accepting non-concrete handler types (f.e. if constructed by a function that returns Arc<dyn HandlerTrait> already) and fixes type inference failures when passing an Arc<H> rather than H.

This affects the setters for EventHandler, RawEventHandler, Framework, and VoiceGatewayManager.

Framework is in a bit of a weird spot because it is only put in an Arc after Framework::init has been called, so a &mut can be taken to it for that call, so this PR has ClientBuilder accept Box<dyn Framework> for it.

Most of the PR diff is related to fixing examples.

@github-actions github-actions bot added gateway Related to the `gateway` module. examples Related to Serenity's examples. labels Oct 11, 2025
@Joshix-1
Copy link

the readme mentions the event_handler method. You should update that and check if there are other markdown files mentioning the methods you changed

@DPlayer234
Copy link
Contributor Author

The example in the README was horribly outdated, I've replaced it with a trimmed down version of the up-to-date ping bot example.
Didn't find any other places where these functions are used in non-Rust files.

@arqunis arqunis added enhancement An improvement to Serenity. breaking change The public API is changed, resulting in miscompilations or unexpected new behaviour for users labels Dec 11, 2025
@arqunis arqunis merged commit cf2283f into serenity-rs:next Dec 11, 2025
25 checks passed
@DPlayer234 DPlayer234 deleted the simplify-builder branch December 11, 2025 21:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking change The public API is changed, resulting in miscompilations or unexpected new behaviour for users enhancement An improvement to Serenity. examples Related to Serenity's examples. gateway Related to the `gateway` module.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants