Skip to content

wire_format

Constants and static functions to support protocol buffer wire format.

IsTypePackable(field_type)

Return true iff packable = true is valid for fields of this type.

Parameters:

Name Type Description Default
field_type

a FieldDescriptor::Type value.

required

Returns:

Type Description

True iff fields of this type are packable.

Source code in client/ayon_hiero/vendor/google/protobuf/internal/wire_format.py
259
260
261
262
263
264
265
266
267
268
def IsTypePackable(field_type):
  """Return true iff packable = true is valid for fields of this type.

  Args:
    field_type: a FieldDescriptor::Type value.

  Returns:
    True iff fields of this type are packable.
  """
  return field_type not in NON_PACKABLE_TYPES

PackTag(field_number, wire_type)

Returns an unsigned 32-bit integer that encodes the field number and wire type information in standard protocol message wire format.

Parameters:

Name Type Description Default
field_number

Expected to be an integer in the range [1, 1 << 29)

required
wire_type

One of the WIRETYPE_* constants.

required
Source code in client/ayon_hiero/vendor/google/protobuf/internal/wire_format.py
80
81
82
83
84
85
86
87
88
89
90
def PackTag(field_number, wire_type):
  """Returns an unsigned 32-bit integer that encodes the field number and
  wire type information in standard protocol message wire format.

  Args:
    field_number: Expected to be an integer in the range [1, 1 << 29)
    wire_type: One of the WIRETYPE_* constants.
  """
  if not 0 <= wire_type <= _WIRETYPE_MAX:
    raise message.EncodeError('Unknown wire type: %d' % wire_type)
  return (field_number << TAG_TYPE_BITS) | wire_type

TagByteSize(field_number)

Returns the bytes required to serialize a tag with this field number.

Source code in client/ayon_hiero/vendor/google/protobuf/internal/wire_format.py
224
225
226
227
def TagByteSize(field_number):
  """Returns the bytes required to serialize a tag with this field number."""
  # Just pass in type 0, since the type won't affect the tag+type size.
  return _VarUInt64ByteSizeNoTag(PackTag(field_number, 0))

UnpackTag(tag)

The inverse of PackTag(). Given an unsigned 32-bit number, returns a (field_number, wire_type) tuple.

Source code in client/ayon_hiero/vendor/google/protobuf/internal/wire_format.py
93
94
95
96
97
def UnpackTag(tag):
  """The inverse of PackTag().  Given an unsigned 32-bit number,
  returns a (field_number, wire_type) tuple.
  """
  return (tag >> TAG_TYPE_BITS), (tag & TAG_TYPE_MASK)

ZigZagDecode(value)

Inverse of ZigZagEncode().

Source code in client/ayon_hiero/vendor/google/protobuf/internal/wire_format.py
110
111
112
113
114
def ZigZagDecode(value):
  """Inverse of ZigZagEncode()."""
  if not value & 0x1:
    return value >> 1
  return (value >> 1) ^ (~0)

ZigZagEncode(value)

ZigZag Transform: Encodes signed integers so that they can be effectively used with varint encoding. See wire_format.h for more details.

Source code in client/ayon_hiero/vendor/google/protobuf/internal/wire_format.py
100
101
102
103
104
105
106
107
def ZigZagEncode(value):
  """ZigZag Transform:  Encodes signed integers so that they can be
  effectively used with varint encoding.  See wire_format.h for
  more details.
  """
  if value >= 0:
    return value << 1
  return (value << 1) ^ (~0)