hoodie / notify-rust

☝️send desktop notifications from your Rust app.
Apache License 2.0
1.17k stars 74 forks source link

`Deserialize<'_>` is not implemented for `xdg::ServerInformation` #221

Open matthiasbeyer opened 4 months ago

matthiasbeyer commented 4 months ago

https://github.com/hoodie/notify-rust/blob/c253a82f53c24ad29d4aeecec84952e53a886d52/src/xdg/zbus_rs.rs#L217

This line makes the compiler unhappy if I use notify-rust with default-features = false, features = ["zbus"].

You may want to check the feature gates on this particular code piece :wink:


Full error:

    Checking notify-rust v4.11.0
error[E0277]: the trait bound `xdg::ServerInformation: DynamicDeserialize<'_>` is not satisfied
   --> /home/m/.cargo/registry/src/index.crates.io-6f17d22bba15001f/notify-rust-4.11.0/src/xdg/zbus_rs.rs:217:10
    |
217 |         .deserialize()?;
    |          ^^^^^^^^^^^ the trait `Deserialize<'_>` is not implemented for `xdg::ServerInformation`, which is required by `xdg::ServerInformation: DynamicDeserialize<'_>`
    |
    = help: the following other types implement trait `DynamicDeserialize<'de>`:
              <DynamicTuple<(T0, T1)> as DynamicDeserialize<'de>>
              <DynamicTuple<(T0, T1, T2)> as DynamicDeserialize<'de>>
              <DynamicTuple<(T0, T1, T2, T3)> as DynamicDeserialize<'de>>
              <DynamicTuple<(T0, T1, T2, T3, T4)> as DynamicDeserialize<'de>>
              <DynamicTuple<(T0, T1, T2, T3, T4, T5)> as DynamicDeserialize<'de>>
              <DynamicTuple<(T0, T1, T2, T3, T4, T5, T6)> as DynamicDeserialize<'de>>
              <DynamicTuple<(T0, T1, T2, T3, T4, T5, T6, T7)> as DynamicDeserialize<'de>>
              <DynamicTuple<(T0, T1, T2, T3, T4, T5, T6, T7, T8)> as DynamicDeserialize<'de>>
            and 11 others
    = note: required for `xdg::ServerInformation` to implement `DynamicDeserialize<'_>`
note: required by a bound in `Body::deserialize`
   --> /home/m/.cargo/registry/src/index.crates.io-6f17d22bba15001f/zbus-4.3.1/src/message/body.rs:25:12
    |
23  |     pub fn deserialize<'s, B>(&'s self) -> Result<B>
    |            ----------- required by a bound in this associated function
24  |     where
25  |         B: zvariant::DynamicDeserialize<'s>,
    |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Body::deserialize`
hoodie commented 4 months ago

Thanks for letting me know, I was a bit confused how this was possible until I looked at the combination of things. The feature flag for using zbus is "z" not "zbus". I think I could technically just change that. Or document that better. Not sure. Any suggestion?

matthiasbeyer commented 4 months ago

Well for me it was unclear that z is the feature flag I need. You could add a compiler error if a user only enables zbus but not serde, but I am not sure whether this is actually an error... can the crate work without serde when `zbus is used? If not, why have it as seperate features?