Skip to main content

Module connection

Module connection 

Source
Expand description

A D-Bus connection: authenticate, dispatch, serve.

§Authentication

Before any message, the client sends a single NUL byte — a relic of the credential-passing handshake — then a line-based SASL exchange:

  AUTH EXTERNAL <uid, in ASCII, hex-encoded>
  OK <server guid>
  BEGIN

EXTERNAL means “the kernel already told you who I am”, which is true of a Unix socket. ANONYMOUS is tried as a fallback for buses configured to allow it, which is how some test harnesses are set up.

§Dispatch

One reader thread owns the read half and routes by message type: replies to the caller waiting on that serial, signals to match handlers, and inbound method calls to registered objects — the last being what the peripheral role needs, since BlueZ calls back into the application to read a characteristic.

Calls are callback-based rather than blocking, so the async layer above can wrap them without a thread per request. Connection::call_blocking is provided for setup paths and tests.

Structs§

Connection
A connection to a message bus.

Enums§

Error
Something went wrong on the bus.

Traits§

ObjectHandler
Handles inbound method calls on an exported object.

Type Aliases§

Result
A D-Bus result: this module’s Error, not the crate’s.
SignalHandler
Called for every signal that arrives.