Skip to main content

Crate tokio_dbus_runtime

Crate tokio_dbus_runtime 

Source
Expand description

github crates.io docs.rs

Runtime support for the code generated by tokio-dbus-codegen.

Where tokio-dbus speaks in borrowed views over a message buffer, this crate speaks in the owned Rust types a caller would reach for anyway: String, Vec, HashMap and tuples, with a Value standing in for a variant. That convenience is paid for with a copy of every message which crosses the boundary, so reach for the low level API when that matters.


§Examples

use tokio_dbus::{ObjectPath, Signature};
use tokio_dbus_runtime::{Arguments, Connection};

const PATH: &ObjectPath = ObjectPath::new_const(b"/org/freedesktop/DBus");

let mut c = Connection::session_bus().await?;

let mut arguments = Arguments::new(Signature::STRING)?;
arguments.store("org.freedesktop.DBus");

let reply = c
    .call(
        "org.freedesktop.DBus",
        PATH,
        "org.freedesktop.DBus",
        "GetNameOwner",
        &arguments,
    )
    .await?;

let owner = reply.read::<String>()?;
println!("{owner}");

Structs§

Arguments
The body of a message being built.
Call
An incoming method call.
Connection
A connection to a bus which speaks in owned Rust values.
Error
An error raised while talking to the bus.
NameOwnerChanged
The org.freedesktop.DBus.NameOwnerChanged signal, which the bus emits when the ownership of a well known name changes.
Reply
The reply to a method call.
SignalMessage
An incoming signal.
VariantDict
A writer for an a{sv}, where every value is a variant of its own type.

Enums§

Incoming
A message which arrived on the connection and is not a reply.
Value
A D-Bus value whose type is only known at runtime.

Traits§

Decode
A Rust value which can be read from a D-Bus message body.
Encode
A Rust value which can be written to a D-Bus message body.

Functions§

decode_variant
Read a variant which is expected to contain a value of type T.

Type Aliases§

Result
Result alias defaulting to the error type of this crate.