krruzic / pulsectl

Easy to use Rust PulseAudio API
Other
8 stars 19 forks source link

libpulse-binding v2.18+ compatibility issue #4

Open jnqnfe opened 3 years ago

jnqnfe commented 3 years ago

Hi,

Just a heads up: version v2.18 (just released) of libpulse-binding comes with a minor compatibility breaking change which affects your crate. I was browsing the set of dependant crates and noticed the problem so I thought I'd point it out.

The change in question is that the From impl for converting PAErr to Code has been replaced with a TryFrom impl, now that TryFrom has been stable for a while and considering that the conversion is fallible (in the unlikely event that PulseAudio emitted an error number that did not match a Code enum variant, it would be silently converted to Code::Unknown, which is not really a problem but not perfectly correct, so a change was made to allow users the choice of how to deal with it).

You can fix this by:

  1. Bumping the dependency to 2.18+ obviously.
  2. Adding use std::convert::TryFrom; to src/errors.rs.
  3. Replacing let code: Code = error.into(); with let code = Code::try_from(error).unwrap_or(Code::Unknown);.

Btw, there's also a warning being generated due to unnecessary parenthesis within volume_from_percent().

(I thought I'd let you make the change rather than submitting a PR)

cars10 commented 3 years ago

+1. Sadly libpulse-binding does not compile on any version between 2.14 and 2.17, so this crate is not usably right now.