-
Notifications
You must be signed in to change notification settings - Fork 628
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support preserving unknown fields in ProtoBuf format #2860
base: dev
Are you sure you want to change the base?
Support preserving unknown fields in ProtoBuf format #2860
Conversation
@sandwwraith Hi, please take a look here? |
@xiaozhikang0916 Sure, when I'll have time |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The structure you use to represent protobuf content is somewhat complex, especially considering the protobuf wire format. You probably want to think a bit more how to represent protobuf data where the wire based information permits that. In particular you may want to distinguish primitives, "blobs", packed arrays. You may also allow users to observe a protobuf with provided metadata.
/** | ||
* A data representation of a protobuf field in [ProtoField.data], without the field number and wire type. | ||
*/ | ||
internal sealed interface ProtoContentHolder { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that protobuf is a recursive format, it would make sense for ProgoMessage and ProtoContentHolder to be the same. It may also make sense to have support for proto primitives (with fixed size) rather than storing that data as bytearray.
@pdvrieze Actually I don't want to decode the protobuf wire data into a tree-structure type like what The raw content in protobuf wire data is quite ambiguous that, you can even not possible to tell whether a Base on it, |
Introducing new annotation
@ProtoUnknownFields
and built-in typeProtoMessage
, to store any fields with proto ids that are undefined in current message class.In my understanding, both ktx-serialization and protocol buffer are designed in strong typing, all messages used in code should be well defined in kt class or proto message. Therefore I would like to keep
ProtoMessage
andProtoField
minimun published. Not likeJsonObject
in json format, users cannot retrieve detailed data from it.Close #2655