Struct tokio_dbus::Client

source ·
pub struct Client { /* private fields */ }
Expand description

An asynchronous D-Bus client.

Implementations§

source§

impl Client

source

pub async fn session_bus() -> Result<Self>

Shorthand for connecting the client to the system bus using the default configuration.

source

pub async fn system_bus() -> Result<Self>

Shorthand for connecting the client to the system bus using the default configuration.

source

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)?;
source

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?;
source

pub fn method_call<'a>( &mut self, path: &'a ObjectPath, member: &'a str ) -> Message<'a>

Construct a new Message corresponding to a method call.

source

pub fn write_message(&mut self, message: &Message<'_>) -> Result<()>

Write a message to the send buffer.

This can be used to queue messages to be sent during the next call to process(). To both receive and send in parallel, see the buffers() method.

source

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.

source

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.

source

pub async fn request_name( &mut self, name: &str, flags: NameFlag ) -> Result<NameReply>

Request the given well-known name.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Client

§

impl !Send for Client

§

impl !Sync for Client

§

impl Unpin for Client

§

impl !UnwindSafe for Client

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.