-
Notifications
You must be signed in to change notification settings - Fork 3.5k
[rust] add deser support for enum type #8803
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
Conversation
|
@jtdavis777 Hello, I'm sorry to disturb you. Regarding this modification, I tried running generate_code.py, and found that this script modified a large number of files. However, I don't think those are related to my modifications. Do you have any suggestions on this? |
|
hey! I just pulled master and ran the code gen script for the root directory, and had no changes. are you rebased on latest master? I would recommend going through the same steps and reporting back -- check out master and run the script, see what happens, then go to your commit and try again. let me know! |
|
I switched to the master branch and used the flatc program that I had compiled. I successfully obtained the modified content (7 files, all related to my current modifications). I'm going to try updating now. |
adaf739 to
6d3d80a
Compare
|
@jtdavis777 Hello, could you spare some time to review this PR? Thank you very much! |
|
Hello! I know effectively nothing about rust :( and do not feel confident in merging this code without having review from someone with a bit more experience and context in the flatbuffers rust implementation. I can, however, kick off the pipeline and make sure all is well there -- I do not see any tests provided which cover this new functionality, would that be something you could work on? |
|
@jtdavis777 Thank you for your reply. I have already conducted the relevant tests. |
|
Could you also please fill in your PR description? |
done. |
|
Don't know Rust either, but this seems mostly fine.. surprised we have serde serialize by string, but that is apparently a problem of the existing code already. If anything, generating error strings deep down in low level code like this seems bad design to me, it should return something from which higher level / user code can decide to report an error, and how. In this case, an unknown variant isn't even an error, it is an expected thing part of forwards/backwards compatibility so generating errors is even more inappropriate. This should probably return an |
The serialization and deserialization of the type T generated by flatc is the core of its functionality and necessary. However, implementing deserialization for |
|
@aardappel Hello, I would like to ask if the differences in ideas regarding implementing deserialization features for |
|
I was referring to replacing |
refer: https://github.com/serde-rs/serde/blob/master/serde_core/src/de/mod.rs#L561 In my understanding, the serde library has already defined the Result return type, and it is impossible to replace Result with Option unless we change other serialization systems or modify the source code of this project. If we consider modifying the source code of the serde library, the problem is that this serialization feature has been widely used and it is impossible to modify it to Option |
|
If my understanding is incorrect, please provide the source code at your convenience so that I can understand your thoughts |
|
Ok, that is interestingly bad design, but that's not your fault, so LGTM. |
enumeration types generated by flatc. This enables users to freely use the objects generated by flatc, and after being serialized into various formats, they can also be deserialized back to their original state. A more intuitive example is that the user may want to store the objects generated by flatc as a JSON string (for storage purposes), and then restore them when needed.