aboutsummaryrefslogtreecommitdiffstats
path: root/src/themes.rs
diff options
context:
space:
mode:
authorboasting-squirrel <boasting.squirrel@gmail.com>2019-04-07 11:27:25 +0000
committerboasting-squirrel <boasting.squirrel@gmail.com>2019-04-07 11:27:25 +0000
commitbbdafc3e121942c95ba81db1cba30fe438d88dfb (patch)
tree26edf6679242462eff4d97c0ee14f84b055003ae /src/themes.rs
parentFix CSS bug (diff)
downloadminiserve-bbdafc3e121942c95ba81db1cba30fe438d88dfb.tar.gz
miniserve-bbdafc3e121942c95ba81db1cba30fe438d88dfb.zip
Use strum to reduce boilerplate on ColorScheme enum + removed useless Debug derives
Diffstat (limited to 'src/themes.rs')
-rw-r--r--src/themes.rs17
1 files changed, 4 insertions, 13 deletions
diff --git a/src/themes.rs b/src/themes.rs
index 8635c8f..328a2e8 100644
--- a/src/themes.rs
+++ b/src/themes.rs
@@ -3,7 +3,7 @@ use structopt::clap::{_clap_count_exprs, arg_enum};
use strum_macros::EnumIter;
arg_enum! {
- #[derive(Debug, Deserialize, Clone, EnumIter)]
+ #[derive(PartialEq, Deserialize, Clone, EnumIter)]
#[serde(rename_all = "lowercase")]
pub enum ColorScheme {
Archlinux,
@@ -15,7 +15,9 @@ arg_enum! {
impl ColorScheme {
/// Returns the URL-compatible name of a color scheme
- pub fn to_string(&self) -> String {
+ /// This must correspond to the name of the variant, in lowercase
+ /// See https://github.com/svenstaro/miniserve/pull/55 for explanations
+ pub fn to_slug(&self) -> String {
match &self {
ColorScheme::Archlinux => "archlinux",
ColorScheme::Zenburn => "zenburn",
@@ -35,17 +37,6 @@ impl ColorScheme {
}
}
- /// Returns the name of a color scheme
- pub fn get_name(&self) -> String {
- match &self {
- ColorScheme::Archlinux => "Archlinux",
- ColorScheme::Zenburn => "Zenburn",
- ColorScheme::Monokai => "Monokai",
- ColorScheme::Squirrel => "Squirrel",
- }
- .to_string()
- }
-
/// Retrieves the color palette associated to a color scheme
pub fn get_theme(self) -> Theme {
match self {