warp icon indicating copy to clipboard operation
warp copied to clipboard

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

Open JonahPlusPlus opened this issue 2 years ago • 1 comments

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 avatar Oct 20 '21 21:10 JonahPlusPlus

See also #903 and #821

FSMaxB avatar Oct 20 '21 21:10 FSMaxB