Fix compilation for with-dns-sd

This commit is contained in:
Roderick van Domburg 2021-12-27 00:21:42 +01:00
parent 8aa23ed0c6
commit 95776de74a
No known key found for this signature in database
GPG key ID: A9EF5222A26F0451
5 changed files with 17 additions and 3 deletions

1
Cargo.lock generated
View file

@ -1303,6 +1303,7 @@ dependencies = [
"byteorder",
"bytes",
"chrono",
"dns-sd",
"env_logger",
"form_urlencoded",
"futures-core",

View file

@ -72,7 +72,7 @@ rodiojack-backend = ["librespot-playback/rodiojack-backend"]
sdl-backend = ["librespot-playback/sdl-backend"]
gstreamer-backend = ["librespot-playback/gstreamer-backend"]
with-dns-sd = ["librespot-discovery/with-dns-sd"]
with-dns-sd = ["librespot-core/with-dns-sd", "librespot-discovery/with-dns-sd"]
default = ["rodio-backend"]

View file

@ -18,6 +18,7 @@ base64 = "0.13"
byteorder = "1.4"
bytes = "1"
chrono = "0.4"
dns-sd = { version = "0.1.3", optional = true }
form_urlencoded = "1.0"
futures-core = { version = "0.3", default-features = false }
futures-util = { version = "0.3", default-features = false, features = ["alloc", "bilock", "sink", "unstable"] }
@ -61,3 +62,6 @@ vergen = "3.0.4"
[dev-dependencies]
env_logger = "0.8"
tokio = { version = "1.0", features = ["macros", "parking_lot"] }
[features]
with-dns-sd = ["dns-sd"]

View file

@ -12,6 +12,9 @@ use thiserror::Error;
use tokio::sync::{mpsc::error::SendError, oneshot::error::RecvError};
use url::ParseError;
#[cfg(feature = "with-dns-sd")]
use dns_sd::DNSError;
#[derive(Debug)]
pub struct Error {
pub kind: ErrorKind,
@ -283,6 +286,13 @@ impl From<DecodeError> for Error {
}
}
#[cfg(feature = "with-dns-sd")]
impl From<DNSError> for Error {
fn from(err: DNSError) -> Self {
Self::new(ErrorKind::Unavailable, err)
}
}
impl From<http::Error> for Error {
fn from(err: http::Error) -> Self {
if err.is::<InvalidHeaderName>()

View file

@ -11,6 +11,7 @@ edition = "2018"
aes-ctr = "0.6"
base64 = "0.13"
cfg-if = "1.0"
dns-sd = { version = "0.1.3", optional = true }
form_urlencoded = "1.0"
futures-core = "0.3"
futures-util = "0.3"
@ -24,8 +25,6 @@ sha-1 = "0.9"
thiserror = "1.0"
tokio = { version = "1.0", features = ["parking_lot", "sync", "rt"] }
dns-sd = { version = "0.1.3", optional = true }
[dependencies.librespot-core]
path = "../core"
default_features = false