vendor/github.com/godbus/dbus/v5/doc.go
71 lines · 2634 bytes
1/*
2Package dbus implements bindings to the D-Bus message bus system.
3
4To use the message bus API, you first need to connect to a bus (usually the
5session or system bus). The acquired connection then can be used to call methods
6on remote objects and emit or receive signals. Using the Export method, you can
7arrange D-Bus methods calls to be directly translated to method calls on a Go
8value.
9
10Conversion Rules
11
12For outgoing messages, Go types are automatically converted to the
13corresponding D-Bus types. See the official specification at
14https://dbus.freedesktop.org/doc/dbus-specification.html#type-system for more
15information on the D-Bus type system. The following types are directly encoded
16as their respective D-Bus equivalents:
17
18 Go type | D-Bus type
19 ------------+-----------
20 byte | BYTE
21 bool | BOOLEAN
22 int16 | INT16
23 uint16 | UINT16
24 int | INT32
25 uint | UINT32
26 int32 | INT32
27 uint32 | UINT32
28 int64 | INT64
29 uint64 | UINT64
30 float64 | DOUBLE
31 string | STRING
32 ObjectPath | OBJECT_PATH
33 Signature | SIGNATURE
34 Variant | VARIANT
35 interface{} | VARIANT
36 UnixFDIndex | UNIX_FD
37
38Slices and arrays encode as ARRAYs of their element type.
39
40Maps encode as DICTs, provided that their key type can be used as a key for
41a DICT.
42
43Structs other than Variant and Signature encode as a STRUCT containing their
44exported fields in order. Fields whose tags contain `dbus:"-"` and unexported
45fields will be skipped.
46
47Pointers encode as the value they're pointed to.
48
49Types convertible to one of the base types above will be mapped as the
50base type.
51
52Trying to encode any other type or a slice, map or struct containing an
53unsupported type will result in an InvalidTypeError.
54
55For incoming messages, the inverse of these rules are used, with the exception
56of STRUCTs. Incoming STRUCTS are represented as a slice of empty interfaces
57containing the struct fields in the correct order. The Store function can be
58used to convert such values to Go structs.
59
60Unix FD passing
61
62Handling Unix file descriptors deserves special mention. To use them, you should
63first check that they are supported on a connection by calling SupportsUnixFDs.
64If it returns true, all method of Connection will translate messages containing
65UnixFD's to messages that are accompanied by the given file descriptors with the
66UnixFD values being substituted by the correct indices. Similarly, the indices
67of incoming messages are automatically resolved. It shouldn't be necessary to use
68UnixFDIndex.
69
70*/
71package dbus