Add serde feature gated support for (de)serialization of packed protos.#628
Open
spwilson27 wants to merge 4 commits into
Open
Add serde feature gated support for (de)serialization of packed protos.#628spwilson27 wants to merge 4 commits into
serde feature gated support for (de)serialization of packed protos.#628spwilson27 wants to merge 4 commits into
Conversation
Author
|
Note, code was mostly AI generated. I've manually reviewed it all for anything egregious. Potential Optimizations:
I'm willing to make changes as requested, sharing this patchset as I've wanted this ability across multiple projects. |
Contributor
|
I think this PR needs some tests. (I am not a maintainer of this project.) |
Previously, the serde Serialize/Deserialize code generation skipped structs with union (discriminant) fields. This extends it to handle them: - Serialize: non-union fields serialized normally, active union variant serialized via match on self.which() - Deserialize: union field keys handled same as non-union (init sets the discriminant) - Recursive types: cycle detection now returns true instead of false, since serde handles recursion at runtime - Fix list deserialization borrow: use reborrow() before init and mut self on visit_seq - Guard deserialize_serde method on supports_serde_struct check Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add support for serde to enable deserialization inter-op with JSON.
Use Case
I'd like to define a typed config specification using capnp definitions, both to support strong typing and because the config will be sent across IPC boundaries. I'd like to write the actual config file in JSON since it's easily human readable.
Testing
Verified all existing tests pass with
cargo nextest runon M4 MAX Mac. Verified example builds and prints expected output: