Skip to content

Commit

Permalink
Merge pull request #684 from Plecra/remove-lazy-static
Browse files Browse the repository at this point in the history
Remove lazy_static as a dependency
  • Loading branch information
Eric S. Londres authored Oct 2, 2020
2 parents 7e346c8 + 58faee5 commit 7c34e6b
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 50 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ futures = "0.1"
gethostname = "0.2.0"
hex = "0.4"
keyring = { version = "0.9.0", optional = true }
lazy_static = "1.4.0"
libc = "0.2.73"
log = "0.4.6"
percent-encoding = "2.1.0"
Expand Down
76 changes: 28 additions & 48 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use crate::{
utils,
};
use gethostname::gethostname;
use lazy_static::lazy_static;
use librespot::{
core::{cache::Cache, config::DeviceType as LSDeviceType, config::SessionConfig, version},
playback::config::{Bitrate as LSBitrate, PlayerConfig},
Expand All @@ -18,26 +17,16 @@ use url::Url;

const CONFIG_FILE_NAME: &str = "spotifyd.conf";

lazy_static! {
static ref BACKEND_VALUES: Vec<&'static str> = {
let mut vec = Vec::new();

if cfg!(feature = "alsa_backend") {
vec.push("alsa");
}
if cfg!(feature = "pulseaudio_backend") {
vec.push("pulseaudio");
}
if cfg!(feature = "portaudio_backend") {
vec.push("portaudio");
}
if cfg!(feature = "rodio_backend") {
vec.push("rodio");
}

vec
};
}
static BACKEND_VALUES: &[&str] = &[
#[cfg(feature = "alsa_backend")]
"alsa",
#[cfg(feature = "pulseaudio_backend")]
"pulseaudio",
#[cfg(feature = "portaudio_backend")]
"portaudio",
#[cfg(feature = "rodio_backend")]
"rodio",
];

/// The backend used by librespot
#[derive(Clone, Copy, Debug, Deserialize, PartialEq, StructOpt)]
Expand Down Expand Up @@ -74,18 +63,13 @@ impl ToString for Backend {
}
}

lazy_static! {
static ref VOLUME_CONTROLLER_VALUES: Vec<&'static str> = {
let mut vec = vec!["softvol"];

if cfg!(feature = "alsa_backend") {
vec.push("alsa");
vec.push("alsa_linear");
}

vec
};
}
static VOLUME_CONTROLLER_VALUES: &[&str] = &[
"softvol",
#[cfg(feature = "alsa_backend")]
"alsa",
#[cfg(feature = "alsa_backend")]
"alsa_linear",
];

#[derive(Clone, Copy, Debug, Deserialize, PartialEq, StructOpt)]
#[serde(rename_all = "snake_case")]
Expand All @@ -109,18 +93,16 @@ impl FromStr for VolumeController {
}
}

lazy_static! {
static ref DEVICETYPE_VALUES: Vec<&'static str> = vec![
"computer",
"tablet",
"smartphone",
"speaker",
"tv",
"avr",
"stb",
"audiodongle"
];
}
static DEVICETYPE_VALUES: &[&str] = &[
"computer",
"tablet",
"smartphone",
"speaker",
"tv",
"avr",
"stb",
"audiodongle",
];

// Spotify's device type (copied from it's config.rs)
#[derive(Clone, Copy, Debug, Deserialize, PartialEq, StructOpt)]
Expand Down Expand Up @@ -185,9 +167,7 @@ impl ToString for DeviceType {
}
}

lazy_static! {
static ref BITRATE_VALUES: Vec<&'static str> = vec!["96", "160", "320"];
}
static BITRATE_VALUES: &[&str] = &["96", "160", "320"];

/// Spotify's audio bitrate
#[derive(Clone, Copy, Debug, Deserialize, PartialEq, StructOpt)]
Expand Down

0 comments on commit 7c34e6b

Please sign in to comment.