Skip to content

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

Open
@JonahPlusPlus

Description

@JonahPlusPlus

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions