MCPcopy
hub / github.com/pika/pika / decode_table

Function decode_table

pika/data.py:146–164  ·  view source on GitHub ↗

Decode the AMQP table passed in from the encoded value returning the decoded result and the number of bytes read plus the offset. :param str encoded: The binary encoded data to decode :param int offset: The starting byte offset :rtype: tuple

(encoded: bytes,
                 offset: int)

Source from the content-addressed store, hash-verified

144
145
146def decode_table(encoded: bytes,
147 offset: int) -> Tuple[Dict[Union[str, bytes], Any], int]:
148 """Decode the AMQP table passed in from the encoded value returning the
149 decoded result and the number of bytes read plus the offset.
150
151 :param str encoded: The binary encoded data to decode
152 :param int offset: The starting byte offset
153 :rtype: tuple
154
155 """
156 result = {}
157 tablesize = struct.unpack_from('>I', encoded, offset)[0]
158 offset += 4
159 limit = offset + tablesize
160 while offset < limit:
161 key, offset = decode_short_string(encoded, offset)
162 value, offset = decode_value(encoded, offset)
163 result[key] = value
164 return result, offset
165
166
167def decode_value(encoded: bytes, offset: int) -> Tuple[Any, int]: # pylint: disable=R0912,R0915

Callers 1

decode_valueFunction · 0.85

Calls 2

decode_short_stringFunction · 0.85
decode_valueFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…