diff --git a/audio/Cargo.toml b/audio/Cargo.toml index f9d232b3..5e950cdc 100644 --- a/audio/Cargo.toml +++ b/audio/Cargo.toml @@ -16,11 +16,11 @@ bit-set = "0.5" byteorder = "1.4" bytes = "1.0" futures = "0.3" -lewton = "0.9" +lewton = "0.10" log = "0.4" num-bigint = "0.3" num-traits = "0.2" -pin-project = "1.0" +pin-project-lite = "0.2.4" tempfile = "3.1" librespot-tremor = { version = "0.1.0", optional = true } diff --git a/audio/src/fetch.rs b/audio/src/fetch.rs index 5d15866c..51dddc6b 100644 --- a/audio/src/fetch.rs +++ b/audio/src/fetch.rs @@ -502,8 +502,8 @@ async fn audio_file_fetch_receive_data( future::ready(if request_length == 0 { Err(TryFoldErr::FinishEarly) - } else { - Ok(()) + } else { + Ok(()) }) }) .await; @@ -532,7 +532,7 @@ async fn audio_file_fetch_receive_data( ); } } -/* +/* async fn audio_file_fetch( session: Session, shared: Arc, @@ -689,20 +689,21 @@ async fn audio_file_fetch( future::select_all(vec![f1, f2, f3]).await }*/ -#[pin_project] -struct AudioFileFetch { - session: Session, - shared: Arc, - output: Option, +pin_project! { + struct AudioFileFetch { + session: Session, + shared: Arc, + output: Option, - file_data_tx: mpsc::UnboundedSender, - #[pin] - file_data_rx: mpsc::UnboundedReceiver, + file_data_tx: mpsc::UnboundedSender, + #[pin] + file_data_rx: mpsc::UnboundedReceiver, - #[pin] - stream_loader_command_rx: mpsc::UnboundedReceiver, - complete_tx: Option>, - network_response_times_ms: Vec, + #[pin] + stream_loader_command_rx: mpsc::UnboundedReceiver, + complete_tx: Option>, + network_response_times_ms: Vec, + } } impl AudioFileFetch { @@ -853,8 +854,6 @@ impl AudioFileFetch { } } - - fn poll_file_data_rx(&mut self, cx: &mut Context<'_>) -> Poll<()> { loop { match Pin::new(&mut self.file_data_rx).poll_next(cx) { @@ -923,12 +922,10 @@ impl AudioFileFetch { if full { self.finish(); - return Poll::Ready(()) + return Poll::Ready(()); } } - Poll::Pending => { - return Poll::Pending - } + Poll::Pending => return Poll::Pending, } } } @@ -936,27 +933,22 @@ impl AudioFileFetch { fn poll_stream_loader_command_rx(&mut self, cx: &mut Context<'_>) -> Poll<()> { loop { match Pin::new(&mut self.stream_loader_command_rx).poll_next(cx) { - Poll::Ready(None) => - return Poll::Ready(()), - Poll::Ready(Some(cmd)) => { - match cmd { - StreamLoaderCommand::Fetch(request) => { - self.download_range(request.start, request.length); - } - StreamLoaderCommand::RandomAccessMode() => { - *(self.shared.download_strategy.lock().unwrap()) = - DownloadStrategy::RandomAccess(); - } - StreamLoaderCommand::StreamMode() => { - - *(self.shared.download_strategy.lock().unwrap()) = - DownloadStrategy::Streaming(); - } - StreamLoaderCommand::Close() => return Poll::Ready(()) - + Poll::Ready(None) => return Poll::Ready(()), + Poll::Ready(Some(cmd)) => match cmd { + StreamLoaderCommand::Fetch(request) => { + self.download_range(request.start, request.length); } - } - Poll::Pending => return Poll::Pending + StreamLoaderCommand::RandomAccessMode() => { + *(self.shared.download_strategy.lock().unwrap()) = + DownloadStrategy::RandomAccess(); + } + StreamLoaderCommand::StreamMode() => { + *(self.shared.download_strategy.lock().unwrap()) = + DownloadStrategy::Streaming(); + } + StreamLoaderCommand::Close() => return Poll::Ready(()), + }, + Poll::Pending => return Poll::Pending, } } } @@ -974,11 +966,11 @@ impl Future for AudioFileFetch { fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<()> { if let Poll::Ready(()) = self.poll_stream_loader_command_rx(cx) { - return Poll::Ready(()) + return Poll::Ready(()); } if let Poll::Ready(()) = self.poll_file_data_rx(cx) { - return Poll::Ready(()) + return Poll::Ready(()); } if let DownloadStrategy::Streaming() = self.get_download_strategy() { diff --git a/audio/src/lib.rs b/audio/src/lib.rs index 69555887..1be1ba88 100644 --- a/audio/src/lib.rs +++ b/audio/src/lib.rs @@ -1,7 +1,9 @@ +#![allow(clippy::unused_io_amount)] + #[macro_use] extern crate log; #[macro_use] -extern crate pin_project; +extern crate pin_project_lite; extern crate aes_ctr; extern crate bit_set; diff --git a/core/Cargo.toml b/core/Cargo.toml index a9fcc246..c092c04d 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -20,14 +20,14 @@ bytes = "1.0" futures = { version = "0.3", features = ["bilock", "unstable"] } hmac = "0.7" httparse = "1.3" -hyper = { version = "0.14", features = ["client", "tcp", "http1", "http2", "stream"] } +hyper = { version = "0.14", features = ["client", "tcp", "http1", "http2"] } log = "0.4" num-bigint = "0.3" num-integer = "0.1" num-traits = "0.2" once_cell = "1.5.2" pbkdf2 = "0.3" -pin-project = "1.0" +pin-project-lite = "0.2.4" protobuf = "~2.14.0" rand = "0.7" serde = "1.0" @@ -35,7 +35,7 @@ serde_derive = "1.0" serde_json = "1.0" sha-1 = "~0.8" shannon = "0.2.0" -tokio = { version = "1.0", features = ["io-util", "rt-multi-thread", "macros" ] } +tokio = { version = "1.0", features = ["io-util", "rt-multi-thread"] } tokio-util = { version = "0.6", features = ["codec"] } url = "1.7" uuid = { version = "0.8", features = ["v4"] } @@ -43,3 +43,6 @@ uuid = { version = "0.8", features = ["v4"] } [build-dependencies] rand = "0.7" vergen = "3.0.4" + +[dev-dependencies] +tokio = {version = "1.0", features = ["macros"] } \ No newline at end of file diff --git a/core/src/lib.rs b/core/src/lib.rs index 65f6f81b..a15aa7a2 100644 --- a/core/src/lib.rs +++ b/core/src/lib.rs @@ -5,7 +5,7 @@ extern crate log; #[macro_use] extern crate serde_derive; #[macro_use] -extern crate pin_project; +extern crate pin_project_lite; extern crate aes; extern crate base64; extern crate byteorder; @@ -25,7 +25,7 @@ extern crate serde; extern crate serde_json; extern crate sha1; extern crate shannon; -extern crate tokio; +pub extern crate tokio; extern crate tokio_util; extern crate url; extern crate uuid; diff --git a/core/src/mercury/mod.rs b/core/src/mercury/mod.rs index e77b4a45..72360c97 100644 --- a/core/src/mercury/mod.rs +++ b/core/src/mercury/mod.rs @@ -31,14 +31,18 @@ pub struct MercuryPending { callback: Option>>, } -#[pin_project] -pub struct MercuryFuture(#[pin] oneshot::Receiver>); +pin_project! { + pub struct MercuryFuture { + #[pin] + receiver: oneshot::Receiver> + } +} impl Future for MercuryFuture { type Output = Result; fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { - match self.project().0.poll(cx) { + match self.project().receiver.poll(cx) { Poll::Ready(Ok(x)) => Poll::Ready(x), Poll::Ready(Err(_)) => Poll::Ready(Err(MercuryError)), Poll::Pending => Poll::Pending, @@ -73,7 +77,7 @@ impl MercuryManager { let data = req.encode(&seq); self.session().send_packet(cmd, data); - MercuryFuture(rx) + MercuryFuture { receiver: rx } } pub fn get>(&self, uri: T) -> MercuryFuture {