Handle optional volume. Build dynamic libs too.
[package]
-
name = "connectr"
version = "0.0.1"
authors = [ "Trevor Bentley <trevor@trevorbentley.com>" ]
build = "build.rs"
+[lib]
+crate-type = ["rlib", "dylib"]
+
+[profile.release]
+opt-level = 3
+debug = false
+rpath = false
+lto = true
+debug-assertions = false
+codegen-units = 1
+panic = 'unwind'
+
[dependencies]
curl = "0.4.6"
open = "1.2.0"
rustc-serialize = "0.3.23"
url = "1.4.0"
rust-ini = "0.9"
+
+[target."cfg(windows)".dependencies]
+[target."cfg(all(unix, not(target_os = \"macos\")))".dependencies]
+[target."cfg(macos)".dependencies]
-
extern crate connectr;
use connectr::settings;
use connectr::SpotifyResponse;
pub is_restricted: bool,
pub name: String,
pub device_type: String,
- pub volume_percent: u32
+ pub volume_percent: Option<u32>
}
impl Decodable for ConnectDevice {
let is_restricted = try!(d.read_struct_field("is_restricted", 2, |d| { d.read_bool() }));
let name = try!(d.read_struct_field("name", 3, |d| { d.read_str() }));
let device_type = try!(d.read_struct_field("type", 4, |d| { d.read_str() }));
- let volume_percent = try!(d.read_struct_field("volume_percent", 5, |d| { d.read_u32() }));
+ let volume_percent = try!(d.read_struct_field("volume_percent", 5, |d| {
+ match d.read_u32() {
+ Ok(x) => Ok(Some(x)),
+ // 'null' triggers a decode error. Convert error to valid None:
+ Err(_) => Ok(None),
+ }}));
Ok(ConnectDevice{ id: id,
is_active: is_active,
is_restricted: is_restricted,