Struct zbus::Connection[][src]

pub struct Connection { /* fields omitted */ }
Expand description

A D-Bus connection.

A connection to a D-Bus bus, or a direct peer.

Once created, the connection is authenticated and negotiated and messages can be sent or received, such as method calls or signals.

For higher-level message handling (typed functions, introspection, documentation reasons etc), it is recommended to wrap the low-level D-Bus messages into Rust functions with the dbus_proxy and dbus_interface macros instead of doing it directly on a Connection.

Typically, a connection is made to the session bus with session, or to the system bus with system. Then the connection is shared with the Proxy and ObjectServer instances.

Connection implements Clone and cloning it is a very cheap operation, as the underlying data is not cloned. This makes it very convenient to share the connection between different parts of your code. Connection also implements std::marker::Sync andstd::marker::Send so you can send and share a connection instance across threads as well.

Connection keeps an internal ringbuffer of incoming message. The maximum capacity of this ringbuffer is configurable through the set_max_queued method. The default size is 64. When the buffer is full, messages are dropped to create room, starting from the oldest one.

Implementations

Create a Connection to the session/user message bus.

Create a Connection to the system-wide message bus.

Max number of messages to queue.

Set the max number of messages to queue.

The server’s GUID.

The unique name as assigned by the message bus or None if not a message bus connection.

Fetch the next message from the connection.

Read from the connection until a message is received or an error is reached. Return the message on success.

Send msg to the peer.

The connection sets a unique serial number on the message before sending it off.

On successfully sending off msg, the assigned serial number is returned.

Send a method call.

Create a method-call message, send it over the connection, then wait for the reply. Incoming messages are received through receive_message until the matching method reply (error or return) is received.

On successful reply, an Ok(Message) is returned. On error, an Err is returned. D-Bus error replies are returned as MethodError.

Emit a signal.

Create a signal message, and send it over the connection.

Reply to a message.

Given an existing message (likely a method call), send a reply back to the caller with the given body.

Returns the message serial number.

Reply an error to a message.

Given an existing message (likely a method call), send an error reply back to the caller with the given error_name and body.

Returns the message serial number.

Checks if self is a connection to a message bus.

This will return false for p2p connections.

Get a reference to the underlying async Connection.

Get the underlying async Connection, consuming self.

Trait Implementations

Extracts the raw file descriptor. Read more

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Performs the conversion.

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.