dbus2 / zbus-old

Rust D-Bus crate.
https://gitlab.freedesktop.org/dbus/zbus
Other
49 stars 13 forks source link

Property changed signal is only generated for properties with setter method #166

Closed zeenix closed 1 year ago

zeenix commented 3 years ago

In GitLab by @tmuehlbacher on Apr 16, 2021, 20:13

Using zbus v2.0.0-beta.3, the following code doesn't compile unless the set_prop() method is uncommented.

use zbus::dbus_interface;

struct Smth;

#[dbus_interface(name = "org.example.Smth")]
impl Smth {
    #[dbus_interface(property)]
    pub fn prop(&self) -> i32 {
        unimplemented!()
    }

    /*
    #[dbus_interface(property)]
    pub fn set_prop(&mut self, _prop: i32) {
        unimplemented!()
    }
    */
}

fn main() {
    let smth = Smth;
    smth.prop_changed().unwrap();
}

With the following error output.

error[E0599]: no method named `prop_changed` found for struct `Smth` in the current scope
  --> src/main.rs:22:10
   |
3  | struct Smth;
   | ------------ method `prop_changed` not found for this
...
22 |     smth.prop_changed().unwrap();
   |          ^^^^^^^^^^^^ method not found in `Smth`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0599`.
zeenix commented 3 years ago

@xou816 Could you please have a look? It's something we missed in !239.

zeenix commented 3 years ago

In GitLab by @xou816 on May 5, 2021, 15:10

Sure, let me have a look a bit later!

I guess it should be fine to generate this method when either a getter or a setter is present.

zeenix commented 3 years ago

mentioned in commit ca5da70c86119b3d06d98ffa3e62d7ac9deb23ac