Bump dependency versions
Diff
Cargo.toml | 4 ++--
src/device.rs | 22 ++++++++++++++--------
2 files changed, 14 insertions(+), 12 deletions(-)
@@ -9,10 +9,10 @@
readme = "README.md"
[dependencies]
reqwest = "0.9"
reqwest = { version = "0.10", features = ["blocking"] }
log = "0.4"
ssdp = "0.7"
xmltree = "0.8"
xmltree = "0.10"
error-chain = "0.12"
regex = "1"
lazy_static = "1"
@@ -7,7 +7,7 @@
use std::time::Duration;
use error::*;
pub(crate) use self::xmltree::ParseError;
use self::xmltree::Element;
use self::xmltree::{Element, XMLNode};
use self::reqwest::header::HeaderMap;
use self::regex::Regex;
@@ -51,13 +51,13 @@
fn element_to_string(el: &Element) -> String {
el.text.to_owned().unwrap_or_default()
el.get_text().map(std::borrow::Cow::into_owned).unwrap_or_default()
}
impl Speaker {
pub fn from_ip(ip: IpAddr) -> Result<Speaker> {
let resp = reqwest::get(&format!("http://{}:1400/xml/device_description.xml", ip))
let resp = reqwest::blocking::get(&format!("http://{}:1400/xml/device_description.xml", ip))
.chain_err(|| ErrorKind::DeviceUnreachable)?;
if !resp.status().is_success() {
@@ -99,7 +99,7 @@
pub fn coordinator(&self) -> Result<IpAddr> {
let mut resp = reqwest::get(&format!("http://{}:1400/status/topology", self.ip))
let mut resp = reqwest::blocking::get(&format!("http://{}:1400/status/topology", self.ip))
.chain_err(|| ErrorKind::DeviceUnreachable)?;
if !resp.status().is_success() {
@@ -126,12 +126,18 @@
let group = &zone_players
.children
.iter()
.map(XMLNode::as_element)
.filter(Option::is_some)
.map(Option::unwrap)
.find(|child| child.attributes["uuid"] == self.uuid)
.chain_err(|| ErrorKind::DeviceNotFound(self.uuid.to_string()))?
.attributes["group"];
Ok(COORDINATOR_REGEX
.captures(zone_players.children.iter()
.map(XMLNode::as_element)
.filter(Option::is_some)
.map(Option::unwrap)
.find(|child|
child.attributes.get("coordinator").unwrap_or(&"false".to_string()) == "true" &&
@@ -167,7 +173,7 @@
headers.insert("SOAPAction", format!("\"{}#{}\"", service, action).parse()
.map_err(|_| "service/action caused an invalid header")?);
let client = reqwest::Client::new();
let client = reqwest::blocking::Client::new();
let coordinator = if coordinator {
self.coordinator()?
} else {
@@ -428,11 +434,7 @@
false,
)?;
let volume = res.get_child("CurrentVolume")
.chain_err(|| ErrorKind::ParseError)?
.text
.to_owned()
.chain_err(|| ErrorKind::ParseError)?
let volume = element_to_string(res.get_child("CurrentVolume").chain_err(|| ErrorKind::ParseError)?)
.parse::<u8>()
.chain_err(|| ErrorKind::ParseError)?;