From d5e6bf78399f06a757257db33add4957afc67a35 Mon Sep 17 00:00:00 2001 From: Valentin Brandl Date: Sat, 4 May 2019 15:37:29 +0200 Subject: [PATCH] Add service enum for form data --- src/service.rs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/service.rs b/src/service.rs index f234ff3..b9300e2 100644 --- a/src/service.rs +++ b/src/service.rs @@ -4,6 +4,34 @@ pub(crate) trait Service { 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; impl Service for GitHub {