Class ProtoReader

java.lang.Object
dev.lavalink.youtube.sabr.protobuf.ProtoReader

public class ProtoReader extends Object
A minimal protocol buffers decoder that iterates over the fields of a single message. Only the subset of functionality required to parse SABR responses is implemented.

Usage: repeatedly call readTag() until it returns -1, inspecting getFieldNumber() and getWireType(), then pulling the value with the relevant read* method (or skip() to ignore the field).

  • Constructor Details

    • ProtoReader

      public ProtoReader(byte[] data)
    • ProtoReader

      public ProtoReader(byte[] data, int offset, int length)
  • Method Details

    • readTag

      public int readTag()
      Returns:
      The tag of the next field, or -1 if the end of the message was reached.
    • getFieldNumber

      public int getFieldNumber()
    • getWireType

      public int getWireType()
    • readVarint

      public long readVarint()
    • readSInt32

      public int readSInt32()
    • readSInt64

      public long readSInt64()
    • readBytes

      public byte[] readBytes()
    • readString

      public String readString()
    • readMessage

      public ProtoReader readMessage()
      Reads a length-delimited field as a nested message reader.
    • skip

      public void skip()
      Skips the value of the current field, based on its wire type.
    • concat

      @Nullable public static @org.jetbrains.annotations.Nullable byte[] concat(@Nullable @org.jetbrains.annotations.Nullable byte[] a, @Nullable @org.jetbrains.annotations.Nullable byte[] b)