Struct tokio_dbus::Client
source · pub struct Client { /* private fields */ }Expand description
An asynchronous D-Bus client.
Implementations§
source§impl Client
impl Client
sourcepub async fn session_bus() -> Result<Self>
pub async fn session_bus() -> Result<Self>
Shorthand for connecting the client to the system bus using the default configuration.
sourcepub async fn system_bus() -> Result<Self>
pub async fn system_bus() -> Result<Self>
Shorthand for connecting the client to the system bus using the default configuration.
sourcepub async fn process(&mut self) -> Result<MessageRef, Error>
pub async fn process(&mut self) -> Result<MessageRef, Error>
Process the current connection.
This is the main entry of this connection, and is required to call to have it make progress when passing D-Bus messages.
Examples
use tokio_dbus::{Client, Message};
let mut c = Client::session_bus().await?;
let message = c.process().await?;
let message: Message<'_> = c.read_message(&message)?;sourcepub async fn flush(&mut self) -> Result<(), Error>
pub async fn flush(&mut self) -> Result<(), Error>
Flush all outgoing messages and return when the send buffer is empty.
Examples
use tokio_dbus::Client;
let mut c = Client::session_bus().await?;
c.flush().await?;sourcepub fn method_call<'a>(
&mut self,
path: &'a ObjectPath,
member: &'a str
) -> Message<'a>
pub fn method_call<'a>( &mut self, path: &'a ObjectPath, member: &'a str ) -> Message<'a>
Construct a new Message corresponding to a method call.
sourcepub fn write_message(&mut self, message: &Message<'_>) -> Result<()>
pub fn write_message(&mut self, message: &Message<'_>) -> Result<()>
sourcepub fn read_message(&self, message_ref: &MessageRef) -> Result<Message<'_>>
pub fn read_message(&self, message_ref: &MessageRef) -> Result<Message<'_>>
Read a MessageRef into a Message.
Note that if the MessageRef is outdated by calling process again,
the behavior of this function is not well-defined (but safe).
Errors
Errors if the message reference is out of date, such as if another message has been received.
sourcepub fn buffers(&mut self) -> (&RecvBuf, &mut SendBuf, &mut BodyBuf)
pub fn buffers(&mut self) -> (&RecvBuf, &mut SendBuf, &mut BodyBuf)
Access the underlying buffers of the connection.
This is usually needed to solve lifetime issues, such as holding onto a
message constructed from a MessageRef while buffering a response.
The RecvBuf is used to translate MessageRef as returned by
process() into Message instances and SendBuf is used to
queue messages to be sent.
The returned BodyBuf is the internal buffer that the client uses to
construct message bodies. It is empty when it’s returned.