Skip to content

pamqp.common

pamqp.common

Common type aliases and classes.

FieldArray = list['FieldValue'] module-attribute

A data structure for holding an array of field values.

FieldTable = dict[str, 'FieldValue'] module-attribute

Field tables are data structures that contain packed name-value pairs.

The name-value pairs are encoded as short string defining the name, and octet defining the values type and then the value itself. The valid field types for tables are an extension of the native integer, bit, string, and timestamp types, and are shown in the grammar. Multi-octet integer fields are always held in network byte order.

Guidelines for implementers:

  • Field names MUST start with a letter, '$' or '#' and may continue with letters, $ or #, digits, or underlines, to a maximum length of 128 characters.
  • The server SHOULD validate field names and upon receiving an invalid field name, it SHOULD signal a connection exception with reply code 503 (syntax error).
  • Decimal values are not intended to support floating point values, but rather fixed-point business values such as currency rates and amounts. They are encoded as an octet representing the number of places followed by a long signed integer. The 'decimals' octet is not signed.
  • Duplicate fields are illegal. The behaviour of a peer with respect to a table containing duplicate fields is undefined.

FieldValue = bool | bytes | bytearray | decimal.Decimal | FieldArray | FieldTable | float | int | None | str | datetime.datetime module-attribute

Defines valid field values for a :const:FieldTable and a :const:FieldValue

Arguments = FieldTable | None module-attribute

Defines an AMQP method arguments argument data type

Struct

Simple object for getting to the struct objects for :mod:pamqp.decode / :mod:pamqp.encode.

Source code in pamqp/common.py
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
class Struct:
    """Simple object for getting to the struct objects for
    :mod:`pamqp.decode` / :mod:`pamqp.encode`.

    """

    byte = struct.Struct('B')
    double = struct.Struct('>d')
    float = struct.Struct('>f')
    integer = struct.Struct('>I')
    uint = struct.Struct('>i')
    long_long_int = struct.Struct('>q')
    short_short_int = struct.Struct('>b')
    short_short_uint = struct.Struct('>B')
    timestamp = struct.Struct('>Q')
    long = struct.Struct('>l')
    ulong = struct.Struct('>L')
    short = struct.Struct('>h')
    ushort = struct.Struct('>H')