diwic / dbus-rs

D-Bus binding for the Rust language
Other
588 stars 134 forks source link

too much arguments : Arg is not satisfied #488

Open bachrc opened 1 day ago

bachrc commented 1 day ago

I have a method that exceeds 12 args in a XML file.

I used the codegen to generate a file that uses crossroads.

Though, my method has 18 args, and tells that is does not implement AppendAll.

This is quite similar though to the closed issue here : https://github.com/diwic/dbus-rs/issues/310 but I saw in the dbus@0.9.7 that this is fixed until 26 args, why doesn't it work?

I saw that crossroads uses the version 0.9.3 of dbus, and it makes my code break. Could you update the dependency?

Thank you for your hard work, please have a great day

bachrc commented 1 day ago

Because I am actually not sure of the issue origin, here is the error I have

error[E0277]: the trait bound `(u8, u16, u64, u64, u16, u64, u16, u64, u16, u64, u16, std::string::String, u16, u16, u16, u16, u64): Arg` is not satisfied
  --> crates/dbus-api/src/managet.rs:59:11
   |
59 |         b.method("GetDetails", (), ("details",), |_, t: &mut T, ()| {
   |           ^^^^^^ the trait `Arg` is not implemented for `(u8, u16, u64, u64, u16, u64, u16, u64, u16, u64, u16, std::string::String, u16, u16, u16, u16, u64)`, which is required by `((u8, u16, u64, u64, u16, u64, u16, u64, u16, u64, u16, std::string::String, u16, u16, u16, u16, u64),): ArgAll`
   |
   = help: the following other types implement trait `Arg`:
             (A, B)
             (A, B, C)
             (A, B, C, D)
             (A, B, C, D, E)
             (A, B, C, D, E, F)
             (A, B, C, D, E, F, G)
             (A, B, C, D, E, F, G, H)
             (A, B, C, D, E, F, G, H, I)
           and 4 others
   = note: required for `((u8, u16, u64, u64, u16, u64, u16, u64, u16, u64, u16, std::string::String, u16, u16, u16, u16, u64),)` to implement `ArgAll`
bachrc commented 1 day ago

I changed the subject of the issue because after a cargo tree, it seems that I have the version 0.9.7 of dbus used by crossroads.. 12 arguments are okay, but 13 are not.

bachrc commented 1 day ago

Okay found it : https://github.com/diwic/dbus-rs/blob/master/dbus/src/arg/variantstruct_impl.rs

We should have as well more arguments here. I tried to repeat some more struct_impl, but it seems stucked:

error[E0277]: `(A, B, C, D, E, F, G, H, I, J, K, L, M)` doesn't implement `Debug`
   --> /home/wudi/.local/cargo/registry/src/proxy-repositoi.zca.enedis.fr-c600039f8bc00812/dbus-0.9.7/src/arg/variantstruct_impl.rs:131:34
    |
131 | impl<$($t: RefArg),*> RefArg for ($($t,)*) {
    |                                  ^^^^^^^^^ `(A, B, C, D, E, F, G, H, I, J, K, L, M)` cannot be formatted using `{:?}` because it doesn't implement `Debug`
...
182 | struct_impl!(a A, b B, c C, d D, e E, f F, g G, h H, i I, j J, k K, l L, m M,);
    | ------------------------------------------------------------------------------ in this macro invocation
    |
    = help: the trait `Debug` is not implemented for `(A, B, C, D, E, F, G, H, I, J, K, L, M)`
    = help: the following other types implement trait `Debug`:
              ()
              (A, Z, Y, X, W, V, U, T)
              (B, A, Z, Y, X, W, V, U, T)
              (C, B, A, Z, Y, X, W, V, U, T)
              (D, C, B, A, Z, Y, X, W, V, U, T)
              (E, D, C, B, A, Z, Y, X, W, V, U, T)
              (T,)
              (U, T)
            and 5 others
note: required by a bound in `msgarg::RefArg`
   --> /home/wudi/.local/cargo/registry/src/proxy-repositoi.zca.enedis.fr-c600039f8bc00812/dbus-0.9.7/src/arg/msgarg.rs:59:19
    |
59  | pub trait RefArg: fmt::Debug + Send + Sync {
    |                   ^^^^^^^^^^ required by this bound in `RefArg`
    = note: this error originates in the macro `struct_impl` (in Nightly builds, run with -Z macro-backtrace for more info)
diwic commented 1 day ago

It is indeed a limit in std that Debug is only able to do up to twelve items: https://doc.rust-lang.org/std/fmt/trait.Debug.html

diwic commented 1 day ago

I've added a commit in dbus-codegen causing us not to try to return invalid rust types but to fall back to VecDeque<Box<RefArg>> instead. Could you test it and see if it resolves your issue?

If not, could you supply the xml file to test with?

diwic commented 1 day ago

Related commit that might help: https://github.com/diwic/dbus-rs/commit/cabf790b909582e9c75cd5f4ff57e22b4d25fb23

bachrc commented 14 hours ago

Thank you for your quick answer! I have to compile dbus-codegen from main branch right? I'll give you a feedback on Monday

diwic commented 13 hours ago

I have to compile dbus-codegen from main branch right?

Both dbus and dbus-codegen need to be the version from the master branch since I added two commits to dbus as well.