mirror of
https://github.com/librespot-org/librespot.git
synced 2024-12-18 17:11:53 +00:00
commit
ce2821408b
8 changed files with 13 additions and 14 deletions
|
@ -14,7 +14,7 @@ pub struct APResolveData {
|
|||
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 client = Client::new(handle);
|
||||
|
@ -44,10 +44,9 @@ pub fn apresolve(handle: &Handle) -> Box<Future<Item=String, Error=Error>> {
|
|||
Box::new(ap)
|
||||
}
|
||||
|
||||
pub fn apresolve_or_fallback<E>(handle: &Handle)
|
||||
-> Box<Future<Item=String, Error=E>>
|
||||
where E: 'static
|
||||
{
|
||||
pub(crate) fn apresolve_or_fallback<E>(handle: &Handle)
|
||||
-> Box<Future<Item=String, Error=E>>
|
||||
where E: 'static {
|
||||
let ap = apresolve(handle).or_else(|e| {
|
||||
warn!("Failed to resolve Access Point: {}", e.description());
|
||||
warn!("Using fallback \"{}\"", AP_FALLBACK);
|
||||
|
|
|
@ -22,7 +22,7 @@ component! {
|
|||
}
|
||||
|
||||
impl AudioKeyManager {
|
||||
pub fn dispatch(&self, cmd: u8, mut data: Bytes) {
|
||||
pub(crate) fn dispatch(&self, cmd: u8, mut data: Bytes) {
|
||||
let seq = BigEndian::read_u32(data.split_to(4).as_ref());
|
||||
|
||||
let sender = self.lock(|inner| inner.pending.remove(&seq));
|
||||
|
|
|
@ -121,23 +121,23 @@ impl Credentials {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn from_reader<R: Read>(mut reader: R) -> Credentials {
|
||||
fn from_reader<R: Read>(mut reader: R) -> Credentials {
|
||||
let mut contents = String::new();
|
||||
reader.read_to_string(&mut contents).unwrap();
|
||||
|
||||
serde_json::from_str(&contents).unwrap()
|
||||
}
|
||||
|
||||
pub fn from_file<P: AsRef<Path>>(path: P) -> Option<Credentials> {
|
||||
pub(crate) fn from_file<P: AsRef<Path>>(path: P) -> Option<Credentials> {
|
||||
File::open(path).ok().map(Credentials::from_reader)
|
||||
}
|
||||
|
||||
pub fn save_to_writer<W: Write>(&self, writer: &mut W) {
|
||||
fn save_to_writer<W: Write>(&self, writer: &mut W) {
|
||||
let contents = serde_json::to_string(&self.clone()).unwrap();
|
||||
writer.write_all(contents.as_bytes()).unwrap();
|
||||
}
|
||||
|
||||
pub fn save_to_file<P: AsRef<Path>>(&self, path: P) {
|
||||
pub(crate) fn save_to_file<P: AsRef<Path>>(&self, path: P) {
|
||||
let mut file = File::create(path).unwrap();
|
||||
self.save_to_writer(&mut file)
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ impl ChannelManager {
|
|||
(seq, channel)
|
||||
}
|
||||
|
||||
pub fn dispatch(&self, cmd: u8, mut data: Bytes) {
|
||||
pub(crate) fn dispatch(&self, cmd: u8, mut data: Bytes) {
|
||||
use std::collections::hash_map::Entry;
|
||||
|
||||
let id: u16 = BigEndian::read_u16(data.split_to(2).as_ref());
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
#[allow(unused_mut)]
|
||||
pub mod connection;
|
||||
mod connection;
|
||||
|
|
|
@ -27,7 +27,7 @@ extern crate uuid;
|
|||
extern crate librespot_protocol as protocol;
|
||||
|
||||
#[macro_use] mod component;
|
||||
pub mod apresolve;
|
||||
mod apresolve;
|
||||
pub mod audio_key;
|
||||
pub mod authentication;
|
||||
pub mod cache;
|
||||
|
|
|
@ -136,7 +136,7 @@ impl MercuryManager {
|
|||
}))
|
||||
}
|
||||
|
||||
pub fn dispatch(&self, cmd: u8, mut data: Bytes) {
|
||||
pub(crate) fn dispatch(&self, cmd: u8, mut data: Bytes) {
|
||||
let seq_len = BigEndian::read_u16(data.split_to(2).as_ref()) as usize;
|
||||
let seq = data.split_to(seq_len).as_ref().to_owned();
|
||||
|
||||
|
|
Loading…
Reference in a new issue