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.
Hello. Thanks for your work on this repo. I'm interested in maximizing support for protobufs in rust.
In the interest of increasing protobuf conformance score, this pull request adds support for the deprecated proto2 group syntax.
Groups are generated similarly to messages; a rust struct is created to match the contents of the group.
Groups use a delimited merge operation when reading from a
CodedInputStream
. To avoid making a change to the publicMessage
trait, an inherent method is generated in each group- and message-derived struct calledmerge_delimited
, which takes anend_tag
, and merges into the struct until that end tag is found. The Message impl for a struct leverages the inherentmerge_delimited
method on its message field for groups. Example:When an unknown type is encountered, if the tag is of type StartGroup, a
CodedOutputStream
is created on top of aVec<u8>
, and all values are written to it until the corresponding end tag is found. TheCodedOutputStream
is then flushed, and the raw bytes returned for storage.The computed serialized size of a group is the size of the message plus twice the size of the tag.
Generated code compiles with
repeated
,required
, andoptional
groups.This pull request addresses and provides a fix for Issue#742.
This feature addition covers a large surface area and I am happy to incorporate any feedback. Please let me know if I missed anything or if my implementation does not suit the coding style of this project.