The Type System¶
Values that are sent or received over the message bus always have an associated signature that specifies the types of those values. For the high-level client and service, these signatures are specified in XML data which is advertised in a standard DBus interface. The high-level client dynamically creates classes based on this introspection data with methods and signals with arguments based on the type signature. The high-level service does the inverse by introspecting the class to create the introspection XML data which is advertised on the bus for clients.
Each token in the signature is mapped to a Python type as shown in the table below.
Name |
Token |
Python Type |
Notes |
BYTE |
y |
int |
An integer 0-255. In an array, it has type |
BOOLEAN |
b |
bool |
|
INT16 |
n |
int |
|
UINT16 |
q |
int |
|
INT32 |
i |
int |
|
UINT32 |
u |
int |
|
INT64 |
x |
int |
|
UINT64 |
t |
int |
|
DOUBLE |
d |
float |
|
STRING |
s |
str |
|
OBJECT_PATH |
o |
str |
Must be a valid object path. |
SIGNATURE |
g |
str |
Must be a valid signature. |
UNIX_FD |
h |
int |
In the low-level interface, an index pointing to a file descriptor
in the |
ARRAY |
a |
list |
Must be followed by a complete type which specifies the child type. |
STRUCT |
( |
list |
Types in the Python |
VARIANT |
v |
This class is provided by the library. |
|
DICT_ENTRY |
{ |
dict |
Must be included in an array to be a |
The types a
, (
, v
, and {
are container types that hold
other values. Examples of container types and Python examples are in the
table below.
Signature |
Example |
Notes |
---|---|---|
|
|
Each element in the array must match the corresponding type of the struct member. |
|
|
The child type comes immediately after the |
|
|
An “array of dict entries” is represented by a
|
|
|
Special case: an array of bytes is represented by
Python |
|
|
Signature must be a single type. A variant may hold a container type. |
|
|
Containers may be nested. |
For more information on the DBus type system, see the specification.