docs: def read_variant(variant):
      """Read and parse a binary protobuf variant value."""
      result = 0
      cnt = 0
      for data in variant:
          result |= (data & 0x7f) << (7 * cnt)
          cnt += 1
          if not data & 0x80:
              return result, variant[cnt:]
      raise Exception('invalid variant')