The few wire-format operations that are identical in every generated message.
Deliberately small. Per-field encoding stays inlined in the generated code, where the field number and type are constants the JIT can see; what is factored out here is only the length-prefix bookkeeping, which is verbose, easy to get subtly wrong, and the same every time.
def embeddedSize(fieldNumber: Int, size: Int): Int
Size of an embedded message field, tag and length prefix included.
Size of an embedded message field, tag and length prefix included.
size is passed in rather than computed, because the caller has usually memoized it.
Attributes
def packedSize(fieldNumber: Int, dataSize: Int): Int
Size of a packed repeated field, tag and length prefix included.
Size of a packed repeated field, tag and length prefix included.
Attributes
def readEmbedded[A](input: CodedInputStream)(parse: CodedInputStream=>A): A
Reads a length-delimited value, with the limit pushed while it is read.
Reads a length-delimited value, with the limit pushed while it is read.
The limit is what stops the nested parser: a generated parseFrom reads tags until the stream ends, and inside a pushLimit the end of the field looks like the end of the stream.
Attributes
def readPacked[A](input: CodedInputStream, builder: Builder[A, _])(read: CodedInputStream=>A): Unit
Reads a packed repeated field into a builder.
Reads a packed repeated field into a builder.
A parser has to accept both encodings for any packable field whatever the schema says, because the schema may have changed since the message was written. Generated parsers therefore have a case for the packed tag and a case for the unpacked one.
Attributes
def writeEmbedded(output: CodedOutputStream, fieldNumber: Int, size: Int)(write: CodedOutputStream=>Unit): Unit