-
Notifications
You must be signed in to change notification settings - Fork 24
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
Implement server actions via an enum #144
Conversation
This moves the server actions to use a typed enum to represent the possible actions that can be performed on a server. This will make it easier to implement the rest of the actions in the future.
I'm not sure I want ALL OF THEM as methods. Maybe the most popular ones. This approach makes sense - please see the comments. |
It no longer needs to be Copy in this case, and shouldn't be anyway.
4fdffa5
to
9927dae
Compare
I think I've resolved the requested changes. Let me know if there's anything else. |
Sigh, it still fails because of missing_copy_implementation. I suggest you add an override for it (bonus for reporting it to the Rust team). |
As we will be adding more actions to this enum in the future, it will soon become non-Copyable so we don't want this lint triggering.
I've disabled the lint for now. As soon as I add some more actions (in a future PR), it will stop being needed (since they will be holding Also, bug Rust report raised at rust-lang/rust#116766. |
80a5b61
to
a4ecd39
Compare
Your CI patch is in a merge conflict now, could you split it away? |
a4ecd39
to
6c82cd3
Compare
This moves the server actions to use a typed enum to represent the possible actions that can be performed on a server.
In the future, I wouldn't expect that every single action would have a special method associated with it, so I opted for a generic
action
method which takes the new enum as an argument.This now allows you to do:
which is equivalent to (the still-present)
This is more verbose but will make it easier to implement the rest of the actions in the future as I would like to add the
createImage
action next, but I wanted to do the refactor separately first.I'm happy to take feedback on API and code structure, or of you think there's another way to implement it. For example, if you think that you'd rather have each future-implemented action done as a
Server
method then this new approach gains less. Also, if the definition of theServerAction
enum orunit_to_null
function make more sense in another file, I'm happy to move them.