Rename some public APIs regarding serialization/parsing. #276
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.
This diverges slightly from the names already discussed in #12, after some more discussion with @thomasvl. A brief summary:
Binary serialization is handled by
serializedData()andinit(serializedData: ...). I was less crazy about having "serialized" in the initializer label name, but as we'll see below with the text-based formats, this provides a consistency between the encoding function name and the parsing initializer's label that makes it very clear which APIs go together.Text format serialization is handled by
textFormatString()andinit(textFormatString: ...).Stringis part of the name because it clarifies the type of the argument (and makes it possible to introduce UTF-8Datavariants later). "Text format" is the official name of the format in protobuf land, so we use it instead of just "text".JSON serialization is handled by
jsonString()andinit(jsonString:). There's alsoinit(jsonUTF8Data:), andanyJSONString()for that specific use case.unknownbecomesunknownFields.Some other minor tweaks, like
decodeTextFormatinstead ofdecodeTextanddecodeBinaryinstead ofdecodeProtobufonMessagehelper methods.I want to make another pass through some of the internal helpers and change
ProtobuftoBinary, or possiblyCoded, where it refers to the binary encoding.Protobufsounds more like it's referring to the runtime in general and not specifically to the binary encoding—none of the other implementations useprotobufto mean that, whereasbinary/codedwould align nicely with those.Makes progress on #12.