[go: up one dir, main page]

SignalArgs

Trait SignalArgs 

Source
pub trait SignalArgs {
    const NAME: &'static str;
    const INTERFACE: &'static str;

    // Provided methods
    fn to_emit_message(&self, path: &Path<'_>) -> Message
       where Self: AppendAll { ... }
    fn from_message(m: &Message) -> Option<Self>
       where Self: Sized + ReadAll { ... }
    fn match_rule<'a>(
        sender: Option<&'a BusName<'_>>,
        path: Option<&'a Path<'_>>,
    ) -> MatchRule<'a> { ... }
    fn match_str(
        sender: Option<&BusName<'_>>,
        path: Option<&Path<'_>>,
    ) -> String { ... }
}
Expand description

Helper methods for structs representing a Signal

§Example

Listen to InterfacesRemoved signal from org.bluez.obex.

use dbus::blocking::Connection;
use dbus::message::SignalArgs;
use dbus::blocking::stdintf::org_freedesktop_dbus::ObjectManagerInterfacesRemoved as IR;
use std::time::Duration;

let c = Connection::new_session().unwrap();
// Add a match for this signal
let mr = IR::match_rule(Some(&"org.bluez.obex".into()), None).static_clone();
c.add_match(mr, |ir: IR, _, _| {
     println!("Interfaces {:?} have been removed from bluez on path {}.", ir.interfaces, ir.object);
     true
});

// Wait for the signal to arrive.
loop { c.process(Duration::from_millis(1000)).unwrap(); }

Required Associated Constants§

Source

const NAME: &'static str

D-Bus name of signal

Source

const INTERFACE: &'static str

D-Bus name of interface this signal belongs to

Provided Methods§

Source

fn to_emit_message(&self, path: &Path<'_>) -> Message
where Self: AppendAll,

Returns a message that emits the signal.

Source

fn from_message(m: &Message) -> Option<Self>
where Self: Sized + ReadAll,

If the message is a signal of the correct type, return its arguments, otherwise return None.

This does not check sender and path of the message, which is likely relevant to you as well.

Source

fn match_rule<'a>( sender: Option<&'a BusName<'_>>, path: Option<&'a Path<'_>>, ) -> MatchRule<'a>

Returns a match rule matching this signal.

If sender and/or path is None, matches all senders and/or paths.

Source

fn match_str(sender: Option<&BusName<'_>>, path: Option<&Path<'_>>) -> String

Returns a string that can be sent to Connection::add_match.

If sender and/or path is None, matches all senders and/or paths.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl SignalArgs for dbus::blocking::stdintf::org_freedesktop_dbus::ObjectManagerInterfacesAdded

Source§

const NAME: &'static str = "InterfacesAdded"

Source§

const INTERFACE: &'static str = "org.freedesktop.DBus.ObjectManager"

Source§

impl SignalArgs for dbus::blocking::stdintf::org_freedesktop_dbus::ObjectManagerInterfacesRemoved

Source§

const NAME: &'static str = "InterfacesRemoved"

Source§

const INTERFACE: &'static str = "org.freedesktop.DBus.ObjectManager"

Source§

impl SignalArgs for dbus::blocking::stdintf::org_freedesktop_dbus::PropertiesPropertiesChanged

Source§

const NAME: &'static str = "PropertiesChanged"

Source§

const INTERFACE: &'static str = "org.freedesktop.DBus.Properties"

Source§

impl SignalArgs for dbus::ffidisp::stdintf::org_freedesktop_dbus::ObjectManagerInterfacesAdded

Source§

const NAME: &'static str = "InterfacesAdded"

Source§

const INTERFACE: &'static str = "org.freedesktop.DBus.ObjectManager"

Source§

impl SignalArgs for dbus::ffidisp::stdintf::org_freedesktop_dbus::ObjectManagerInterfacesRemoved

Source§

const NAME: &'static str = "InterfacesRemoved"

Source§

const INTERFACE: &'static str = "org.freedesktop.DBus.ObjectManager"

Source§

impl SignalArgs for dbus::ffidisp::stdintf::org_freedesktop_dbus::PropertiesPropertiesChanged

Source§

const NAME: &'static str = "PropertiesChanged"

Source§

const INTERFACE: &'static str = "org.freedesktop.DBus.Properties"

Source§

impl SignalArgs for dbus::nonblock::stdintf::org_freedesktop_dbus::ObjectManagerInterfacesAdded

Source§

const NAME: &'static str = "InterfacesAdded"

Source§

const INTERFACE: &'static str = "org.freedesktop.DBus.ObjectManager"

Source§

impl SignalArgs for dbus::nonblock::stdintf::org_freedesktop_dbus::ObjectManagerInterfacesRemoved

Source§

const NAME: &'static str = "InterfacesRemoved"

Source§

const INTERFACE: &'static str = "org.freedesktop.DBus.ObjectManager"

Source§

impl SignalArgs for dbus::nonblock::stdintf::org_freedesktop_dbus::PropertiesPropertiesChanged

Source§

const NAME: &'static str = "PropertiesChanged"

Source§

const INTERFACE: &'static str = "org.freedesktop.DBus.Properties"