From c69ccf77e99c6d19ca10818d4841de12e6329c33 Mon Sep 17 00:00:00 2001 From: ashthespy Date: Sat, 23 Jan 2021 22:21:42 +0000 Subject: [PATCH] [Connect] Migrate to `tokio` 0.1 --- connect/Cargo.toml | 3 ++- connect/src/discovery.rs | 14 ++++++-------- connect/src/lib.rs | 2 +- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/connect/Cargo.toml b/connect/Cargo.toml index f21faef..b5cd4fd 100644 --- a/connect/Cargo.toml +++ b/connect/Cargo.toml @@ -28,7 +28,7 @@ rand = "0.7" serde = "1.0" serde_derive = "1.0" serde_json = "1.0" -tokio-core = "0.1" +tokio = "0.1" url = "1.7" sha-1 = "0.8" hmac = "0.7" @@ -38,6 +38,7 @@ block-modes = "0.3" dns-sd = { version = "0.1.3", optional = true } libmdns = { version = "0.2.7", optional = true } + [features] default = ["libmdns"] with-dns-sd = ["dns-sd"] diff --git a/connect/src/discovery.rs b/connect/src/discovery.rs index e3bc227..6c542e6 100644 --- a/connect/src/discovery.rs +++ b/connect/src/discovery.rs @@ -22,7 +22,7 @@ use rand; use std::collections::BTreeMap; use std::io; use std::sync::Arc; -use tokio_core::reactor::Handle; +use tokio::runtime::current_thread::Handle; use url; use librespot_core::authentication::Credentials; @@ -235,11 +235,9 @@ pub fn discovery( let serve = { let http = Http::new(); - http.serve_addr_handle( - &format!("0.0.0.0:{}", port).parse().unwrap(), - handle.new_tokio_handle(), - move || Ok(discovery.clone()), - ) + http.serve_addr(&format!("0.0.0.0:{}", port).parse().unwrap(), move || { + Ok(discovery.clone()) + }) .unwrap() }; @@ -254,13 +252,13 @@ pub fn discovery( hyper::server::conn::AddrStream, futures::Failed<_, hyper::Error>, >| { - handle.spawn(connecting.then(|_| Ok(()))); + handle.spawn(connecting.flatten().then(|_| Ok(()))).unwrap(); Ok(()) }, ) .then(|_| Ok(())) }; - handle.spawn(server_future); + handle.spawn(server_future).unwrap(); #[cfg(feature = "with-dns-sd")] let svc = DNSService::register( diff --git a/connect/src/lib.rs b/connect/src/lib.rs index 118c85d..4777760 100644 --- a/connect/src/lib.rs +++ b/connect/src/lib.rs @@ -12,7 +12,7 @@ extern crate hyper; extern crate num_bigint; extern crate protobuf; extern crate rand; -extern crate tokio_core; +extern crate tokio; extern crate url; extern crate aes_ctr;