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