Skip to content

runtime: json adapter newtypes replace per-site _W serialize wrappers#197

Draft
iainmcgin wants to merge 1 commit into
runtime/default-instance-macrosfrom
runtime/json-adapters
Draft

runtime: json adapter newtypes replace per-site _W serialize wrappers#197
iainmcgin wants to merge 1 commit into
runtime/default-instance-macrosfrom
runtime/json-adapters

Conversation

@iainmcgin

Copy link
Copy Markdown
Collaborator

What this does

Replaces the per-site _W* serialize wrapper newtypes in generated JSON code with shared adapter newtypes in buffa::json_helpers. 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 function — ~65 struct _W* blocks of ~8 lines apiece.

The existing private ProtoElemSer bridge is promoted to a public json_helpers::ProtoJson adapter (ProtoElemJson already covers every type serde_helper_path matches), plus the sibling adapters the view paths need: BytesJson, ClosedEnumJson, MapKeyJson, 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 — the adapters call the exact helper functions the inline impls called.

Checked-in generated trees regenerated (net −328 lines).

How we know it works

  • json_helpers adapter unit tests; full workspace suite green (2,093 tests), task lint clean; regenerating the checked-in trees after rebase produced zero diff.
  • Conformance (14/14 suites incl. the JSON modes, Docker-less scripts from tooling: run the conformance suite without Docker #192) run at this PR's head.

Stacked on #196.

@github-actions

github-actions Bot commented Jun 12, 2026

Copy link
Copy Markdown

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant