core API: apresolve

This commit is contained in:
awiouy 2018-02-09 20:57:49 +01:00
parent bd59ded224
commit d34068c5a7
2 changed files with 5 additions and 6 deletions

View file

@ -14,7 +14,7 @@ pub struct APResolveData {
ap_list: Vec<String> ap_list: Vec<String>
} }
pub fn apresolve(handle: &Handle) -> Box<Future<Item=String, Error=Error>> { fn apresolve(handle: &Handle) -> Box<Future<Item=String, Error=Error>> {
let url = Uri::from_str(APRESOLVE_ENDPOINT).expect("invalid AP resolve URL"); let url = Uri::from_str(APRESOLVE_ENDPOINT).expect("invalid AP resolve URL");
let client = Client::new(handle); let client = Client::new(handle);
@ -44,10 +44,9 @@ pub fn apresolve(handle: &Handle) -> Box<Future<Item=String, Error=Error>> {
Box::new(ap) Box::new(ap)
} }
pub fn apresolve_or_fallback<E>(handle: &Handle) pub(crate) fn apresolve_or_fallback<E>(handle: &Handle)
-> Box<Future<Item=String, Error=E>> -> Box<Future<Item=String, Error=E>>
where E: 'static where E: 'static {
{
let ap = apresolve(handle).or_else(|e| { let ap = apresolve(handle).or_else(|e| {
warn!("Failed to resolve Access Point: {}", e.description()); warn!("Failed to resolve Access Point: {}", e.description());
warn!("Using fallback \"{}\"", AP_FALLBACK); warn!("Using fallback \"{}\"", AP_FALLBACK);

View file

@ -27,7 +27,7 @@ extern crate uuid;
extern crate librespot_protocol as protocol; extern crate librespot_protocol as protocol;
#[macro_use] mod component; #[macro_use] mod component;
pub mod apresolve; mod apresolve;
pub mod audio_key; pub mod audio_key;
pub mod authentication; pub mod authentication;
pub mod cache; pub mod cache;