Debian Codegraph @

python/docs/types.rst

raw
1 .. _types:
2
3 ##########
4 AMQP Types
5 ##########
6
7 These tables summarize the various AMQP types and their Python API equivalents as used in the API.
8
9 |
10
11 ============
12 Scalar Types
13 ============
14
15 |
16
17 +------------+-------------------+---------------------------+------------------------------------------------------------------------+
18 | AMQP Type | Proton C API Type | Proton Python API Type | Description |
19 +============+===================+===========================+========================================================================+
20 | null | PN_NONE | ``None`` | Indicates an empty value. |
21 +------------+-------------------+---------------------------+------------------------------------------------------------------------+
22 | boolean | PN_BOOL | ``bool`` | Represents a true or false value. |
23 +------------+-------------------+---------------------------+------------------------------------------------------------------------+
24 | ubyte | PN_UBYTE | :class:`proton.ubyte` | Integer in the range :math:`0` to :math:`2^8 - 1` inclusive. |
25 +------------+-------------------+---------------------------+------------------------------------------------------------------------+
26 | byte | PN_BYTE | :class:`proton.byte` | Integer in the range :math:`-(2^7)` to :math:`2^7 - 1` inclusive. |
27 +------------+-------------------+---------------------------+------------------------------------------------------------------------+
28 | ushort | PN_USHORT | :class:`proton.ushort` | Integer in the range :math:`0` to :math:`2^{16} - 1` inclusive. |
29 +------------+-------------------+---------------------------+------------------------------------------------------------------------+
30 | short | PN_SHORT | :class:`proton.short` | Integer in the range :math:`-(2^{15})` to :math:`2^{15} - 1` inclusive.|
31 +------------+-------------------+---------------------------+------------------------------------------------------------------------+
32 | uint | PN_UINT | :class:`proton.uint` | Integer in the range :math:`0` to :math:`2^{32} - 1` inclusive. |
33 +------------+-------------------+---------------------------+------------------------------------------------------------------------+
34 | int | PN_INT | :class:`proton.int32` | Integer in the range :math:`-(2^{31})` to :math:`2^{31} - 1` inclusive.|
35 +------------+-------------------+---------------------------+------------------------------------------------------------------------+
36 | char | PN_CHAR | :class:`proton.char` | A single Unicode character. |
37 +------------+-------------------+---------------------------+------------------------------------------------------------------------+
38 | ulong | PN_ULONG | :class:`proton.ulong` | Integer in the range :math:`0` to :math:`2^{64} - 1` inclusive. |
39 +------------+-------------------+---------------------------+------------------------------------------------------------------------+
40 | long | PN_LONG | ``int`` or ``long`` | Integer in the range :math:`-(2^{63})` to :math:`2^{63} - 1` inclusive.|
41 +------------+-------------------+---------------------------+------------------------------------------------------------------------+
42 | timestamp | PN_TIMESTAMP | :class:`proton.timestamp` | An absolute point in time with millisecond precision. |
43 +------------+-------------------+---------------------------+------------------------------------------------------------------------+
44 | float | PN_FLOAT | :class:`proton.float32` | 32-bit floating point number (IEEE 754-2008 binary32). |
45 +------------+-------------------+---------------------------+------------------------------------------------------------------------+
46 | double | PN_DOUBLE | ``double`` | 64-bit floating point number (IEEE 754-2008 binary64). |
47 +------------+-------------------+---------------------------+------------------------------------------------------------------------+
48 | decimal32 | PN_DECIMAL32 | :class:`proton.decimal32` | 32-bit decimal number (IEEE 754-2008 decimal32). |
49 +------------+-------------------+---------------------------+------------------------------------------------------------------------+
50 | decimal64 | PN_DECIMAL64 | :class:`proton.decimal64` | 64-bit decimal number (IEEE 754-2008 decimal64). |
51 +------------+-------------------+---------------------------+------------------------------------------------------------------------+
52 | decimal128 | PN_DECIMAL128 | :class:`proton.decimal128`| 128-bit decimal number (IEEE 754-2008 decimal128). |
53 +------------+-------------------+---------------------------+------------------------------------------------------------------------+
54 | uuid | PN_UUID | ``uuid.UUID`` | A universally unique identifier as defined by RFC-4122 section 4.1.2. |
55 +------------+-------------------+---------------------------+------------------------------------------------------------------------+
56 | binary | PN_BINARY | ``bytes`` | A sequence of octets. |
57 +------------+-------------------+---------------------------+------------------------------------------------------------------------+
58 | string | PN_STRING | ``str`` | A sequence of Unicode characters. |
59 +------------+-------------------+---------------------------+------------------------------------------------------------------------+
60 | symbol | PN_SYMBOL | :class:`proton.symbol` | Symbolic values from a constrained domain. |
61 +------------+-------------------+---------------------------+------------------------------------------------------------------------+
62
63 |
64
65 ==============
66 Compound Types
67 ==============
68
69 |
70
71 +-----------+-------------------+---------------------------+-----------------------------------------------------+
72 | AMQP Type | Proton C API Type | Proton Python API Type | Description |
73 +===========+===================+===========================+=====================================================+
74 | array | PN_ARRAY | :class:`proton.Array` | A sequence of values of a single type. |
75 +-----------+-------------------+---------------------------+-----------------------------------------------------+
76 | list | PN_LIST | ``list`` | A sequence of polymorphic values. |
77 +-----------+-------------------+---------------------------+-----------------------------------------------------+
78 | map | PN_MAP | ``dict`` | A polymorphic mapping from distinct keys to values. |
79 +-----------+-------------------+---------------------------+-----------------------------------------------------+
80
81 |
82
83 =================
84 Specialized Types
85 =================
86
87 The following classes implement specialized or restricted types to help
88 enforce type restrictions in the AMQP specification.
89
90 |
91
92 +-------------------------------+------------------------------------------------------------------------------------+------------------------------------------------+
93 | Proton Python API Type | Description | Where used in API |
94 +===============================+====================================================================================+================================================+
95 | :class:`proton.SymbolList` | A ``list`` that only accepts :class:`proton.symbol` elements. However, will | :attr:`proton.Connection.desired_capabilities` |
96 | | silently convert strings to symbols. | :attr:`proton.Connection.offered_capabilities` |
97 +-------------------------------+------------------------------------------------------------------------------------+------------------------------------------------+
98 | :class:`proton.PropertyDict` | A ``dict`` that only accppts :class:`proton.symbol` keys. However, will silently | :attr:`proton.Connection.properties` |
99 | | convert strings to symbols. | |
100 +-------------------------------+------------------------------------------------------------------------------------+------------------------------------------------+
101 | :class:`proton.AnnotationDict`| A ``dict`` that only accppts :class:`proton.symbol` or :class:`proton.ulong` keys. | :attr:`proton.Message.annotations` |
102 | | However, will silently convert strings to symbols. | :attr:`proton.Message.instructions` |
103 +-------------------------------+------------------------------------------------------------------------------------+------------------------------------------------+
104
105 |
106
107 These types would typically be used where the the above attributes are set. They will silently convert strings to symbols,
108 but will raise an error if a not-allowed type is used. For example:
109
110 >>> from proton import symbol, ulong, Message, AnnotationDict
111 >>> msg = Message()
112 >>> msg.annotations = AnnotationDict({'one':1, symbol('two'):2, ulong(3):'three'})
113 >>> msg.annotations
114 AnnotationDict({symbol('one'): 1, symbol('two'): 2, ulong(3): 'three'})
115 >>> m.instructions = AnnotationDict({'one':1, symbol('two'):2, ulong(3):'three', 4:'four'})
116 ...
117 KeyError: "invalid non-symbol key: <class 'int'>: 4"
118 >>> m.instructions
119 >>>
120