Repository navigation
Conversation
|
All contributors have signed the CLA ✍️ ✅ |
…ointers generate_text(true) did not compile together with map_type_custom, repeated_type_custom or a custom pointer on a message member of a oneof. The text encoder iterated `&self.field`, the map decoder called an inherent `insert`, the repeated decoder passed the field to a reader that takes `&mut Vec<T>`, and the oneof decoder always wrapped a new member in `Box::new`. The text impl now uses the same trait surface as the binary codec for these fields: MapStorage::storage_iter and storage_insert for any map other than the default HashMap, the Deref slice and ProtoList::push for a custom collection (read into a temporary Vec first, so the decoder API is unchanged), and ProtoBox::new for a custom oneof pointer. Output for the default HashMap, Vec and Box is byte-identical, so no checked-in code changes. buffa-test turns text on for the box_type, map_type_custom, repeated_type and tc5 fixtures, dropping the workaround that kept it off for tc5, and adds text round-trip and merge tests for each.
v0ropaev
force-pushed
the
fix/text-custom-containers
branch
from
October 28, 2026 10:16
3ac89cc to
96ec18b
Compare
This branch has not been deployed
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.
generate_text(true)did not compile together withmap_type_custom,repeated_type_custom, or abox_type_custompointer on a message member of a oneof. The text encoder looped over&self.field, which a newtype map or list doesn't implementIntoIteratorfor. The map decoder called an inherentinsert, the repeated decoder passed the field toread_repeated_scalar_intoandread_repeated_into, which take&mut Vec<T>, and the oneof decoder wrapped a new member inBox::newwhatever pointer was configured. buffa-test worked around the last one by turning text off for the tc5 fixture, and the other custom fixtures never had text on.To reproduce, build a small crate per knob with
generate_text(true). On main the custom map gives E0277 (&CustomMap<..>is not an iterator) and E0599 (no method namedinsert), the custom list gives 27 errors, E0277 at the encoder loops and E0308 where theVecreaders get the field, and the custom pointer gives one E0308 at theBox::newin the oneof merge arm.The text impl now uses what the binary codec already uses for these fields. A map other than the default
HashMapgoes throughMapStorage::storage_iterandstorage_insert. A custom collection is written through itsDerefslice with the samerepeated_for_iterhelper the binary encoder uses, and read into a temporaryVecwhose elements are then appended withProtoList::push, so theTextDecoderAPI stays as it is. A custom oneof pointer is built withProtoBox::newthroughPointerRepr::pointer_new. Output for the defaultHashMap,VecandBoxdoesn't change, and regenerating the WKT, option and bootstrap types gives no diff.buffa-test turns text on for the box_type, map_type_custom, repeated_type and tc5 fixtures, so building the crate now compiles those text paths, and adds text round-trip and merge tests for each. The merge tests cover appending to a custom list in both repeated forms, last-write-wins on a custom map, and merging into a oneof member behind the custom pointer. buffa-codegen gets two tests that pin the emitted calls for custom and default containers. The
MapStorage,ProtoListandProtoBoxdocs now say text needs nothing beyond the trait.With only the test changes on top of main, buffa-test fails to build (26 errors from the generated box_type, map_type_custom, repeated_type and tc5 code) and
custom_containers_go_through_their_traitsfails in buffa-codegen.fmt, clippy with
-D warnings, the buffa-codegen and buffa-test suites andcargo docwith-D warningsare clean on 1.95.0.