Appearance
aivi.dbus
Types for D-Bus calls, signals, and values.
D-Bus is the message bus GNOME apps and system services use to talk to each other. This module gives you the data shapes for that conversation plus the DbusSource handle marker.
Current status: public D-Bus work goes through @source dbus; this module is the shared type vocabulary for that capability family.
Import
aivi
use aivi.dbus (
DbusSource
DbusValue
DbusString
DbusInt
DbusBool
DbusList
DbusStruct
DbusVariant
DbusCall
DbusSignal
BusNameFlag
AllowReplacement
ReplaceExisting
DoNotQueue
BusNameState
Owned
Queued
Lost
DbusError
NameNotOwned
ServiceUnknown
NoReply
AccessDenied
InvalidArgs
DbusProtocolError
DbusCallResult
DbusTask
DbusMatchRule
)Overview
| Type | Purpose |
|---|---|
DbusValue | One value carried over the bus |
DbusSource | Handle annotation for @source dbus |
DbusCall | A method call request |
DbusSignal | A broadcast message from a service |
DbusMatchRule | Optional filters for selecting signals |
BusNameFlag | How to request ownership of a bus name |
BusNameState | Current ownership state of a bus name |
DbusError | Structured D-Bus failures |
DbusCallResult | Result of a call returning D-Bus values |
DbusTask A | Background D-Bus work returning A |
DbusValue
aivi
type DbusValue =
| DbusString Text
| DbusInt Int
| DbusBool Bool
| DbusList (List DbusValue)
| DbusStruct (List DbusValue)
| DbusVariant DbusValueThe current value model covers strings, integers, booleans, lists, structs, and variants.
DbusListgroups a list of bus valuesDbusStructgroups several fields into one ordered payloadDbusVariantwraps a value when the protocol expects a runtime-typed value inside another value
aivi
use aivi.dbus (
DbusValue
DbusString
DbusBool
DbusStruct
)
value loginHint : DbusValue =
DbusStruct [
DbusString "ada@example.com",
DbusBool True
]DbusCall
aivi
type DbusCall = {
destination: Text,
path: Text,
interface: Text,
member: Text,
body: List DbusValue
}A method call sent to a D-Bus service.
destination— the bus name to talk topath— the object path on that serviceinterface— the interface name that owns the methodmember— the method namebody— the ordered argument list
aivi
use aivi.dbus (DbusCall)
value pingCall : DbusCall = {
destination: "org.freedesktop.DBus",
path: "/org/freedesktop/DBus",
interface: "org.freedesktop.DBus.Peer",
member: "Ping",
body: []
}DbusSignal
aivi
type DbusSignal = {
path: Text,
interface: Text,
member: Text,
body: List DbusValue
}A broadcast message emitted by a service. The shape is close to DbusCall, but there is no destination because signals are observed rather than directly addressed.
DbusMatchRule
aivi
type DbusMatchRule = {
path: Option Text,
interface: Option Text,
member: Option Text
}Optional filters for selecting only the signals you care about. Leave a field as None when you do not want to filter on it.
aivi
use aivi.dbus (DbusMatchRule)
value syncSignals : DbusMatchRule = {
path: Some "/org/gnome/AiviMail/Daemon",
interface: Some "org.gnome.AiviMail.IDaemon",
member: Some "SyncStateChanged"
}BusNameFlag
aivi
type BusNameFlag =
| AllowReplacement
| ReplaceExisting
| DoNotQueueFlags that control how a service asks for a bus name.
AllowReplacement— let another process replace this name laterReplaceExisting— take over an existing name if the current owner allows itDoNotQueue— fail instead of waiting in a queue
BusNameState
aivi
type BusNameState =
| Owned
| Queued
| LostCurrent state after requesting a bus name.
Owned— this process owns the name nowQueued— the request is waitingLost— the name was lost or could not be kept
DbusError
aivi
type DbusError =
| NameNotOwned Text
| ServiceUnknown Text
| NoReply
| AccessDenied Text
| InvalidArgs Text
| DbusProtocolError TextStructured failure reasons for D-Bus work.
NameNotOwned Text— a required bus name is not ownedServiceUnknown Text— the destination service could not be foundNoReply— the service did not answer in timeAccessDenied Text— the bus rejected the requestInvalidArgs Text— the call arguments were rejectedDbusProtocolError Text— another protocol-level failure occurred
aivi
use aivi.dbus (
DbusError
NameNotOwned
ServiceUnknown
NoReply
AccessDenied
InvalidArgs
DbusProtocolError
)
type DbusError -> Text
func describeBusError = error => error
||> NameNotOwned name -> "name not owned: {name}"
||> ServiceUnknown name -> "service not found: {name}"
||> NoReply -> "service did not reply"
||> AccessDenied msg -> "access denied: {msg}"
||> InvalidArgs msg -> "invalid arguments: {msg}"
||> DbusProtocolError msg -> "D-Bus protocol error: {msg}"DbusCallResult and DbusTask
aivi
type DbusCallResult = Result DbusError (List DbusValue)
type DbusTask A = Task DbusError AUse DbusCallResult when you want the raw values returned by a method call. Use DbusTask A when a higher-level helper decodes those values into some application type A.