-
Notifications
You must be signed in to change notification settings - Fork 30
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
How to represent BitFlags
?
#119
Comments
Another possibility is to capture the |
sidenote: the Encode/Decode implementation on IdentityField is wrong and should be removed paritytech/substrate#9445 |
Then should I reconsider the removal of |
if the only use of discriminant is bitflag maybe it is better to have dedicated syntax. But otherwise it is true that the discriminant gives useful information in this specific case. |
In substrate we have the following type:
It is wrapped in a
BitFlags
in the following wrapper type to allow custom encoding/decoding.Question is how to represent this with
scale_info
: it is encoded as a rawu64
but we need to also have access to theIdentityField
enum definition which maps the discriminants reduced tou8
indices.A temporary workaround is to provide the following
TypeInfo
implementationSee how it represents
BitFlags<IdentityField>
including theIdentityField
as a type parameter, and the field itself as typeu64
.However this requires some string matching for downstream type generators, so a preferable solution might be to add fist class support for a
BitFlags
likeTypeDef
variant.On the other we might not want to be adding a new
TypeDef
variant for each corner case, be curious to see what others think./cc @jacogr
The text was updated successfully, but these errors were encountered: