-
Notifications
You must be signed in to change notification settings - Fork 67
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
Contract Spec: Define how to encode user defined Rust structs into RawVal objs #24
Comments
@jonjove suggested implementing |
Not necessarily |
Note to self to look at CAP-54 that demonstrates one way to do this, using SCO_VEC's to both encode enums and types: stellar/stellar-protocol#1224. This is a pattern we've discussed a few times in different contexts, but CAP-54 is the first CAP or SEP that concretely demonstrates the pattern in use. |
@jonjove found a good way to encode enums/unions using a tuple and a EnvVal tail, that will probably work pretty well. There's little need to make enums a map and so they could be implemented as a tuple/vec like this.
We could probably do some work to make enums that have unit values more concise. |
UDT mappings to host types: StructStructs use the Host Map as their underlying structure. There is a single item in the map for each field of the struct. The struct field name is the key and its value is the value. This is implemented, although there are plenty of TODOs. Union (Rust enums where the values are not integers)Unions use the Host Vec as their underlying structure. The Union is a two element Vec, where the first element is the name of the variant, and the second is the value of the variant. Unit type variants are stored as a void. This is implemented, although there are plenty of TODOs, and the discriminant is currently implemented as an integer index, but will be changed to be a symbol. Enums (Rust enums where the values are integers)Enums merely use the primitive integer type of their representation. This is not yet implemented. Note that in all there is no storing of the type name, etc, and they are rendered purely as their structural components. |
Follow up issues to this task that complete the definition above (#24 (comment)): |
No description provided.
The text was updated successfully, but these errors were encountered: