data

The data module is for encoding and decoding of AMQP binary encoded data.

Note

This class is not intended for use by those using Pika in their applications. This documentation is for those who are extending Pika or otherwise working on the driver itself.

AMQP Table Encoding/Decoding

pika.data.encode_table(pieces, table)[source]

Encode a dict as an AMQP table appending the encded table to the pieces list passed in.

Parameters:
  • pieces (list) – Already encoded frame pieces
  • table (dict) – The dict to encode
Return type:

int

pika.data.encode_value(pieces, value)[source]

Encode the value passed in and append it to the pieces list returning the the size of the encoded value.

Parameters:
  • pieces (list) – Already encoded values
  • value (any) – The value to encode
Return type:

int

pika.data.decode_table(encoded, offset)[source]

Decode the AMQP table passed in from the encoded value returning the decoded result and the number of bytes read plus the offset.

Parameters:
  • encoded (str) – The binary encoded data to decode
  • offset (int) – The starting byte offset
Return type:

tuple

pika.data.decode_value(encoded, offset)[source]

Decode the value passed in returning the decoded value and the number of bytes read in addition to the starting offset.

Parameters:
  • encoded (str) – The binary encoded data to decode
  • offset (int) – The starting byte offset
Return type:

tuple

Raises:

pika.exceptions.InvalidFieldTypeException