runtime: json adapter newtypes replace per-site _W serialize wrappers#197
Draft
iainmcgin wants to merge 1 commit into
Draft
runtime: json adapter newtypes replace per-site _W serialize wrappers#197iainmcgin wants to merge 1 commit into
iainmcgin wants to merge 1 commit into
Conversation
|
All contributors have signed the CLA ✍️ ✅ |
Generated Serialize impls (oneof variant entries, view map keys/values, view repeated elements, view optional/singular scalars) each emitted a local newtype + impl Serialize block delegating one call to a json_helpers module — ~65 `struct _W*` blocks of ~8 lines apiece. Promote the existing private ProtoElemSer bridge to a public json_helpers::ProtoJson adapter (ProtoElemJson already covers every type serde_helper_path matches) and add the sibling adapters the view paths need: BytesJson (&[u8] has no ProtoElemJson impl), ClosedEnumJson, MapKeyJson (collect_str key stringification), RepeatedJson, BytesSeqJson, EnumSeqJson, ClosedEnumSeqJson. Each generated site is now a single serialize_entry call with an adapter borrow. The bespoke _WM map-composite wrappers (which own a serialize_map loop) keep their generated form; only pure-delegation newtypes moved. JSON output is unchanged — adapters call the exact helper fns the inline impls called. Checked-in generated trees regenerated.
4eadcd2 to
dac24e0
Compare
2d6f508 to
87e0d71
Compare
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.
What this does
Replaces the per-site
_W*serialize wrapper newtypes in generated JSON code with shared adapter newtypes inbuffa::json_helpers. GeneratedSerializeimpls (oneof variant entries, view map keys/values, view repeated elements, view optional/singular scalars) each emitted a local newtype +impl Serializeblock delegating one call to ajson_helpersfunction — ~65struct _W*blocks of ~8 lines apiece.The existing private
ProtoElemSerbridge is promoted to a publicjson_helpers::ProtoJsonadapter (ProtoElemJsonalready covers every typeserde_helper_pathmatches), plus the sibling adapters the view paths need:BytesJson,ClosedEnumJson,MapKeyJson,RepeatedJson,BytesSeqJson,EnumSeqJson,ClosedEnumSeqJson. Each generated site is now a singleserialize_entrycall with an adapter borrow.The bespoke
_WMmap-composite wrappers (which own aserialize_maploop) keep their generated form; only pure-delegation newtypes moved. JSON output is unchanged — the adapters call the exact helper functions the inline impls called.Checked-in generated trees regenerated (net −328 lines).
How we know it works
task lintclean; regenerating the checked-in trees after rebase produced zero diff.Stacked on #196.