anoond
anoond

Reputation: 23

Zbus create proxy builder without destination

How do i set a null desination using zbus? I want to recieve a signal that has a (null desination) but the ProxyBuilder doens't allow me to do this.

This is how I'm sending the signal. dbus-send --system --type=signal / com.example.greeting.GreetingSignal string:"wotcha"

use tokio::runtime::Runtime;
use tokio_stream::StreamExt;
use zbus::{Connection, ProxyBuilder, Proxy, zvariant::NoneValue};

#[tokio::main]
async fn main() -> zbus::Result<()> {
    // Connect to the system bus
    let connection = Connection::system().await?;

    // Create a proxy builder for the signal interface
    let proxy_builder = ProxyBuilder::new(&connection)
        .destination(zbus::names::BusName::null_value())?
        .path("/")?
        .interface("com.example.greeting")?;

    let proxy: Proxy<'_> = proxy_builder.build().await?;

    let mut signal_rec = proxy.receive_signal("GreetingSignal").await?;

    while let Some(msg) = signal_rec.next().await {

        let grt: String = msg.body().deserialize()?;

        println!("{}", grt);
    }

    Ok(())
}

I tried using None, and an empty string but those still failed.

Upvotes: 1

Views: 126

Answers (1)

corsel
corsel

Reputation: 325

I ran into the same issue and solved it by None::<zbus::names::BusName>. If you just say None, compiler complains about not being able to infer the optional type, so you need to specify that. dbus-monitor also showed (null destination) like this.

Upvotes: 1

Related Questions