lab_resource_manager/domain/aggregates/identity_link/value_objects/
external_system.rs

1use serde::{Deserialize, Serialize};
2use std::str::FromStr;
3
4/// 外部システムの種類
5#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
6#[serde(rename_all = "lowercase")]
7pub enum ExternalSystem {
8    /// Slack
9    Slack,
10}
11
12impl ExternalSystem {
13    /// 文字列表現を取得
14    pub fn as_str(&self) -> &str {
15        match self {
16            ExternalSystem::Slack => "slack",
17        }
18    }
19}
20
21impl FromStr for ExternalSystem {
22    type Err = String;
23
24    fn from_str(s: &str) -> Result<Self, Self::Err> {
25        match s.to_lowercase().as_str() {
26            "slack" => Ok(ExternalSystem::Slack),
27            _ => Err(format!("Unknown external system: {}", s)),
28        }
29    }
30}