Skip to content

Commit

Permalink
draft: use enums
Browse files Browse the repository at this point in the history
  • Loading branch information
ritiek committed Jun 17, 2021
1 parent 9f7a9c5 commit 40d824f
Showing 1 changed file with 33 additions and 5 deletions.
38 changes: 33 additions & 5 deletions src/lib.rs
Expand Up @@ -192,6 +192,34 @@ where
}
}

enum CoverartType {
Front,
Back,
}

impl CoverartType {
pub(crate) fn as_str(&self) -> &'static str {
match self {
CoverartType::Front => "front",
CoverartType::Back => "back",
}
}

enum CoverartResolution {
Res250,
Res500,
Res1200,
}

impl CoverartResolution {
pub(crate) fn as_str(&self) -> &'static str {
match self {
CoverartResolution::Res250 => "250",
CoverartResolution::Res500 => "500",
CoverartResolution::Res1200 => "1200",
}
}

impl<'a, T> FetchCoverartQuery<T>
where
T: Clone + FetchCoverart<'a>,
Expand All @@ -202,27 +230,27 @@ where
}

pub fn front(&mut self) -> &mut Self {
self.0.path.push_str(&format!("/{}", "front"));
self.0.path.push_str(&format!("/{}", CoverartType::Front.as_str()));
self
}

pub fn back(&mut self) -> &mut Self {
self.0.path.push_str(&format!("/{}", "back"));
self.0.path.push_str(&format!("/{}", CoverartType::Back.as_str()));
self
}

pub fn res_250(&mut self) -> &mut Self {
self.0.path.push_str(&format!("-{}", "250"));
self.0.path.push_str(&format!("-{}", CoverartResolution::Res250.as_str()));
self
}

pub fn res_500(&mut self) -> &mut Self {
self.0.path.push_str(&format!("-{}", "500"));
self.0.path.push_str(&format!("-{}", CoverartResolution::Res500.as_str()));
self
}

pub fn res_1200(&mut self) -> &mut Self {
self.0.path.push_str(&format!("-{}", "1200"));
self.0.path.push_str(&format!("-{}", CoverartResolution::Res1200.as_str()));
self
}

Expand Down

0 comments on commit 40d824f

Please sign in to comment.