Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make warp::ws::Message more usable with a MessageType enum #910

Open
JonahPlusPlus opened this issue Oct 20, 2021 · 1 comment
Open

Make warp::ws::Message more usable with a MessageType enum #910

JonahPlusPlus opened this issue Oct 20, 2021 · 1 comment
Labels
feature New feature or request

Comments

@JonahPlusPlus
Copy link

Is your feature request related to a problem? Please describe.
Not really an issue, but it is a bit annoying to make a bunch of if statements rather than one nice match statement.

Describe the solution you'd like
In Actix, the message was an enum, making it easier to match the message itself and handle the content. That won't work here, since Message is just a wrapper, but you could add a field or method that gives an enum (it could be called MessageType or something) that can be Binary, Text, Ping, Pong, etc. Then you could just match message.value and then handle the message differently for each branch.

Describe alternatives you've considered
You could try doing what Actix did and turn it into an enum itself, but that likely would require too much work refactoring the internals.

Additional context
Rust has made me love match statements.

@JonahPlusPlus JonahPlusPlus added the feature New feature or request label Oct 20, 2021
@FSMaxB
Copy link
Contributor

FSMaxB commented Oct 20, 2021

See also #903 and #821

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants