pub struct DBus { /* private fields */ }
Expand description
This struct represents an object to communicate with the DBus daemon.
Implementations§
Source§impl DBus
impl DBus
Sourcepub async fn session(
introspectable: bool,
peer: bool,
) -> DBusResult<(DBus, JoinHandle<()>)>
pub async fn session( introspectable: bool, peer: bool, ) -> DBusResult<(DBus, JoinHandle<()>)>
Connect to the session DBus.
If the first argument (introspectable
) is true
then the Peer is introspectable.
If the second argument (peer
) is true
then the Peer has the
org.freedesktop.DBus.Peer
.
The DBUS_SESSION_BUS_ADDRESS
environment variable have to be defined.
Sourcepub async fn system(
introspectable: bool,
peer: bool,
) -> DBusResult<(DBus, JoinHandle<()>)>
pub async fn system( introspectable: bool, peer: bool, ) -> DBusResult<(DBus, JoinHandle<()>)>
Connect to the system DBus.
If the first argument (introspectable
) is true
then the Peer is introspectable.
If the second argument (peer
) is true
then the Peer has the
org.freedesktop.DBus.Peer
.
If there DBUS_SYSTEM_BUS_ADDRESS
environment variable is defined then this path will be
used, else unix:path=/var/run/dbus/system_bus_socket
.
Sourcepub async fn new(
addressses: &str,
introspectable: bool,
peer: bool,
) -> DBusResult<(DBus, JoinHandle<()>)>
pub async fn new( addressses: &str, introspectable: bool, peer: bool, ) -> DBusResult<(DBus, JoinHandle<()>)>
Connect to the specific (addressses
) DBus daemon.
If the second argument (introspectable
) is true
then the Peer is introspectable.
If the third argument (peer
) is true
then the Peer has the
org.freedesktop.DBus.Peer
.
Sourcepub async fn call(&self, msg: Message) -> DBusResult<Message>
pub async fn call(&self, msg: Message) -> DBusResult<Message>
Sourcepub async fn call_reply_serial(
&self,
msg: Message,
msg_sender: MpscSender<Message>,
) -> DBusResult<u32>
pub async fn call_reply_serial( &self, msg: Message, msg_sender: MpscSender<Message>, ) -> DBusResult<u32>
Sourcepub async fn request_name(
&self,
name: Bus,
flags: &DBusNameFlag,
) -> DBusResult<Message>
pub async fn request_name( &self, name: Bus, flags: &DBusNameFlag, ) -> DBusResult<Message>
Register a name for the peer. This calls the RequestName(String, UInt32)
method of the
DBus daemon.
Sourcepub fn add_method_call(
&self,
object_path: ObjectPath,
sender: MpscSender<Message>,
) -> DBusResult<()>
pub fn add_method_call( &self, object_path: ObjectPath, sender: MpscSender<Message>, ) -> DBusResult<()>
Add a channel to a specific ObjectPath
.
The channel will receive all MethodCall
messages for the specified ObjectPath
.
If there is already channel added for this ObjectPath
then it will be replace. So the
old channel will not receive any MethodCall
messages for the ObjectPath
anymore.
Sourcepub fn delete_object_path(&self, object_path: ObjectPath) -> DBusResult<()>
pub fn delete_object_path(&self, object_path: ObjectPath) -> DBusResult<()>
Delete the channel for a specific ObjectPath
(see add_method_call
).
Even if there is no channel for this ObjectPath
the function will return Ok()
.
Sourcepub fn delete_method_call_sender(
&self,
sender: MpscSender<Message>,
) -> DBusResult<()>
pub fn delete_method_call_sender( &self, sender: MpscSender<Message>, ) -> DBusResult<()>
Delete the channel for every ObjectPath
, which the given sender is connected to
(see add_method_call
).
Sourcepub fn delete_method_call_receiver(
&self,
receiver: MpscReceiver<Message>,
) -> DBusResult<()>
pub fn delete_method_call_receiver( &self, receiver: MpscReceiver<Message>, ) -> DBusResult<()>
Delete the channel for every ObjectPath
, which the given sender is connected to
(see add_method_call
).
Sourcepub fn add_method_call_interface(
&self,
interface: Interface,
sender: MpscSender<Message>,
) -> DBusResult<()>
pub fn add_method_call_interface( &self, interface: Interface, sender: MpscSender<Message>, ) -> DBusResult<()>
Add a channel to a specific Interface
.
The channel will only receive all MethodCall
messages for the specified Interface
,
if there is no channel by the ObjectPath
.
If there is already channel added for this Interface
then it will be replace. So the old
channel will not receive any MethodCall
messages for the Interface
anymore.
Sourcepub fn delete_method_call_interface_sender(
&self,
sender: MpscSender<Message>,
) -> DBusResult<()>
pub fn delete_method_call_interface_sender( &self, sender: MpscSender<Message>, ) -> DBusResult<()>
Delete the channel for every Interface
, which the given sender is connected to
(see add_method_call_interface
).
Sourcepub fn delete_method_call_interface_receiver(
&self,
receiver: MpscReceiver<Message>,
) -> DBusResult<()>
pub fn delete_method_call_interface_receiver( &self, receiver: MpscReceiver<Message>, ) -> DBusResult<()>
Delete the channel for every Interface
, which the given sender is connected to
(see add_method_call_interface
).
Sourcepub fn add_signal(
&self,
object_path: ObjectPath,
filter: Option<fn(&Message) -> bool>,
sender: MpscSender<Message>,
) -> DBusResult<()>
pub fn add_signal( &self, object_path: ObjectPath, filter: Option<fn(&Message) -> bool>, sender: MpscSender<Message>, ) -> DBusResult<()>
Add a channel to a specific ObjectPath
.
The channel will receive all Signal
messages for the specified ObjectPath
.
The second argument specify a closure to filter the Message
. If the closure returns true
then the Message
will not be send to the channel.
There can be multiple channels, which will receive message of the specific ObjectPath
.
Sourcepub fn delete_signal_sender(
&self,
sender: MpscSender<Message>,
) -> DBusResult<()>
pub fn delete_signal_sender( &self, sender: MpscSender<Message>, ) -> DBusResult<()>
Delete the channel for every ObjectPath
, which the given sender is connected to
(see add_signal
).
Sourcepub fn delete_signal_receiver(
&self,
receiver: MpscReceiver<Message>,
) -> DBusResult<()>
pub fn delete_signal_receiver( &self, receiver: MpscReceiver<Message>, ) -> DBusResult<()>
Delete the channel for every ObjectPath
, which the given sender is connected to
(see add_signal
).
Sourcepub fn add_match_rules(
&self,
match_rules: Vec<MatchRule>,
sender: MpscSender<Message>,
) -> DBusResult<()>
pub fn add_match_rules( &self, match_rules: Vec<MatchRule>, sender: MpscSender<Message>, ) -> DBusResult<()>
Sourcepub fn delete_match_rules_sender(
&self,
sender: MpscSender<Message>,
) -> DBusResult<()>
pub fn delete_match_rules_sender( &self, sender: MpscSender<Message>, ) -> DBusResult<()>
Delete the channel for every MatchRule
s, which the given sender is connected to
(see add_match_rules
).
Sourcepub fn delete_match_rules_receiver(
&self,
receiver: MpscReceiver<Message>,
) -> DBusResult<()>
pub fn delete_match_rules_receiver( &self, receiver: MpscReceiver<Message>, ) -> DBusResult<()>
Delete the channel for every MatchRule
s, which the given sender is connected to
(see add_match_rules
).
Sourcepub async fn list_method_call(
&self,
object_path: ObjectPath,
) -> DBusResult<HashSet<String>>
pub async fn list_method_call( &self, object_path: ObjectPath, ) -> DBusResult<HashSet<String>>
List all ObjectPath
s under the given ObjectPath
.
This will only list the ObjectPath
for the MethodCall
messages
(see add_method_call
).
Sourcepub fn close(&self) -> DBusResult<()>
pub fn close(&self) -> DBusResult<()>
Close the DBus connection.
Sourcepub fn get_address(&self) -> &Address
pub fn get_address(&self) -> &Address
Get the current path of the DBus daemon.