Add service enum for form data

This commit is contained in:
Valentin Brandl 2019-05-04 15:37:29 +02:00
parent 4556d6a04a
commit d5e6bf7839
No known key found for this signature in database
GPG Key ID: 30D341DD34118D7D

View File

@ -4,6 +4,34 @@ pub(crate) trait Service {
fn commit_url(repo: &str, commit_ref: &str) -> String; fn commit_url(repo: &str, commit_ref: &str) -> String;
} }
#[derive(Deserialize, Serialize)]
pub(crate) enum FormService {
#[serde(rename = "github")]
GitHub,
#[serde(rename = "gitlab")]
Gitlab,
#[serde(rename = "bitbucket")]
Bitbucket,
}
impl FormService {
pub(crate) fn url(&self) -> &str {
match self {
FormService::GitHub => "github.com",
FormService::Gitlab => "gitlab.com",
FormService::Bitbucket => "bitbucket.org",
}
}
pub(crate) fn service(&self) -> &str {
match self {
FormService::GitHub => "github",
FormService::Gitlab => "gitlab",
FormService::Bitbucket => "bitbucket",
}
}
}
pub(crate) struct GitHub; pub(crate) struct GitHub;
impl Service for GitHub { impl Service for GitHub {