Proto Reader32
Reads and decodes protocol message fields using an Int
as a cursor.
This is an alternative to ProtoReader, which uses Long
as a cursor. It originates as an optimization for Kotlin/JS, where Long
cursors are prohibitively expensive. It doesn't subclass ProtoReader because nextTag and forEachTag must each return the appropriate cursor type.
Functions
Store an already read field temporarily. Once the entire message is read, call endMessageAndGetUnknownFields to retrieve unknown fields.
Returns a ProtoReader that reads the same data as this using a different type.
Prepares to read a value and returns true if the read should proceed. If there's nothing to read (because a packed value has length 0), this will clear the reader state.
Begin a nested message. A call to this method will restrict the reader so that nextTag returns -1 when the message is complete. An accompanying call to endMessage must then occur with the opaque token returned from this method.
End a length-delimited nested message. Calls to this method must be symmetric with calls to beginMessage.
Reads each tag, handles it, and returns a byte string with the unknown fields.
Returns the min length of the next field in bytes. Some encodings have a fixed length, while others have a variable length. LENGTH_DELIMITED fields have a known variable length, while VARINT fields could be as small as a single byte.
Reads and returns the length of the next message in a length-delimited stream.
Reads and returns the next tag of the message, or -1 if there are no further tags. Use peekFieldEncoding after calling this method to query its encoding. This silently skips groups.
Returns the encoding of the next field value. nextTag must be called before this method.
Reads a 32-bit little-endian integer from the stream.
Reads a 64-bit little-endian integer from the stream.
Reads a string
field value from the stream.
Read an unknown field and store temporarily. Once the entire message is read, call endMessageAndGetUnknownFields to retrieve unknown fields.
Reads a raw varint from the stream. If larger than 32 bits, discard the upper bits.
Reads a raw varint up to 64 bits in length from the stream.