mirror of
https://github.com/librespot-org/librespot.git
synced 2025-10-04 10:19:27 +02:00
Update to Rust 2018
- Fix deprecated Error::cause warnings and missing dyn - Reset max_width - Add rustfmt to Travis - Run rustfmt on full codebase with `cargo fmt --all` - Add rustfmt to Travis - Complete migration to edition 2018 - Replace try! shorthand - Use explicit `dyn Trait`
This commit is contained in:
parent
be2ad9059a
commit
d26590afc5
45 changed files with 331 additions and 238 deletions
|
@ -10,7 +10,7 @@ use std::str::FromStr;
|
|||
use tokio_core::reactor::Handle;
|
||||
use url::Url;
|
||||
|
||||
error_chain!{}
|
||||
error_chain! {}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
pub struct APResolveData {
|
||||
|
@ -21,7 +21,7 @@ fn apresolve(
|
|||
handle: &Handle,
|
||||
proxy: &Option<Url>,
|
||||
ap_port: &Option<u16>,
|
||||
) -> Box<Future<Item = String, Error = Error>> {
|
||||
) -> Box<dyn Future<Item = String, Error = Error>> {
|
||||
let url = Uri::from_str(APRESOLVE_ENDPOINT).expect("invalid AP resolve URL");
|
||||
let use_proxy = proxy.is_some();
|
||||
|
||||
|
@ -52,19 +52,20 @@ fn apresolve(
|
|||
})
|
||||
});
|
||||
let body = body.then(|result| result.chain_err(|| "HTTP error"));
|
||||
let body = body.and_then(|body| String::from_utf8(body).chain_err(|| "invalid UTF8 in response"));
|
||||
let body =
|
||||
body.and_then(|body| String::from_utf8(body).chain_err(|| "invalid UTF8 in response"));
|
||||
|
||||
let data =
|
||||
body.and_then(|body| serde_json::from_str::<APResolveData>(&body).chain_err(|| "invalid JSON"));
|
||||
let data = body
|
||||
.and_then(|body| serde_json::from_str::<APResolveData>(&body).chain_err(|| "invalid JSON"));
|
||||
|
||||
let p = ap_port.clone();
|
||||
|
||||
let ap = data.and_then(move |data| {
|
||||
let mut aps = data.ap_list.iter().filter(|ap| {
|
||||
if p.is_some() {
|
||||
Uri::from_str(ap)
|
||||
.ok()
|
||||
.map_or(false, |uri| uri.port().map_or(false, |port| port == p.unwrap()))
|
||||
Uri::from_str(ap).ok().map_or(false, |uri| {
|
||||
uri.port().map_or(false, |port| port == p.unwrap())
|
||||
})
|
||||
} else if use_proxy {
|
||||
// It is unlikely that the proxy will accept CONNECT on anything other than 443.
|
||||
Uri::from_str(ap)
|
||||
|
@ -86,7 +87,7 @@ pub(crate) fn apresolve_or_fallback<E>(
|
|||
handle: &Handle,
|
||||
proxy: &Option<Url>,
|
||||
ap_port: &Option<u16>,
|
||||
) -> Box<Future<Item = String, Error = E>>
|
||||
) -> Box<dyn Future<Item = String, Error = E>>
|
||||
where
|
||||
E: 'static,
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue