Open aaronjeline opened 1 year ago
In addition to policy and entity ids, we can also do this for Name
s in general.
I wrote a prototype in #744, which proposes a different syntax. Instead of having an argument which is the string representation of entity uids, it asks for two argument: an entity type and an eid. The eid is simply a string. This design avoids the nuance around string escaping and provides users a more flexible way to specify eids. For instance, they can use raw string syntax when they need literal backslashes like euid!(Foo, r#"\"#)
.
Category
User level API changes
Describe the feature you'd like to request
It would be nice to have more ergonomic ways of writing down policy and entity ids. Currently you have write them as a string, and then call
.parse()
on them. For fully static data, this is cumbersome and delays error detection until runtime.Describe the solution you'd like
One solution here would be to have macros for writing ids. You could image something like:
Parse rules would be checked at compile time, allowing you skip calling
.unwrap
or handling the error, and making it compile time error if the ID was invalid.Describe alternatives you've considered
The current situation is workable.
Additional context
This is somewhat inspired by
serde_json
sjson!
macro.Is this something that you'd be interested in working on?