Replies: 2 comments 1 reply
-
For error handling, I think there should be an exported |
Beta Was this translation helpful? Give feedback.
-
One challenge in this approach is that these enums are meant to be defined in a shared crate that is included from both the client and server -- think of Cosmic Verge or PliantDb, both have a crate that defines the network types that the clients and servers include. The derive in this case would have to live inside of the shared crate, but that doesn't feel right. Feature flags might be able to make it workable, however. I'm trying to figure out a way to allow the match statement and handler code all to live in the server crate and the enum in another crate, but without introducing a new enum that lives in the server crate, I'm not sure how to pull that off. Any ideas? |
Beta Was this translation helpful? Give feedback.
-
I've been thinking about how to make permission handling as automatic as possible for consumers of PliantDb. Here's an idea of how to implement a derive-driven API with the permissions model:
In this example, the derive enum would generate an API implementation that takes an
Api
and a&Permissions
. It would generate a match statement, and using the customizations noted, it would generate the glue code to initialize the handler, execute is_allowed, and if true, invoke execute.I like this approach enough that I think I can dogfood the internal PliantDb Api itself off of this.
Any thoughts on this overall approach? This was written in a notepad, so the traits themselves may have some issues I didn't catch, but the general idea should be understandable.
Beta Was this translation helpful? Give feedback.
All reactions