Explorar o código

Merge pull request #136 from awiouy/core_API

core API
Paul Liétar %!s(int64=7) %!d(string=hai) anos
pai
achega
ce2821408b

+ 4 - 5
core/src/apresolve.rs

@@ -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);

+ 1 - 1
core/src/audio_key.rs

@@ -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));

+ 4 - 4
core/src/authentication.rs

@@ -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)
     }

+ 0 - 0
core/src/cache/mod.rs → core/src/cache.rs


+ 1 - 1
core/src/channel.rs

@@ -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 - 1
core/src/lib.in.rs

@@ -1,2 +1,2 @@
 #[allow(unused_mut)]
-pub mod connection;
+mod connection;

+ 1 - 1
core/src/lib.rs

@@ -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;

+ 1 - 1
core/src/mercury/mod.rs

@@ -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();