kmp_domain/value_objects/
relation_semantic_class.rs1use serde::{Deserialize, Serialize};
2
3use crate::DomainError;
4
5#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
6#[serde(rename_all = "snake_case")]
7pub enum RelationSemanticClass {
8 Structural,
9 Causal,
10 Motivational,
11 Procedural,
12 Evidential,
13 Constraint,
14}
15
16impl RelationSemanticClass {
17 pub fn parse(value: &str) -> Result<Self, DomainError> {
18 match value.trim() {
19 "structural" => Ok(Self::Structural),
20 "causal" => Ok(Self::Causal),
21 "motivational" => Ok(Self::Motivational),
22 "procedural" => Ok(Self::Procedural),
23 "evidential" => Ok(Self::Evidential),
24 "constraint" => Ok(Self::Constraint),
25 other => Err(DomainError::InvalidState(format!(
26 "invalid relation semantic_class `{other}`"
27 ))),
28 }
29 }
30
31 pub fn as_str(&self) -> &'static str {
32 match self {
33 Self::Structural => "structural",
34 Self::Causal => "causal",
35 Self::Motivational => "motivational",
36 Self::Procedural => "procedural",
37 Self::Evidential => "evidential",
38 Self::Constraint => "constraint",
39 }
40 }
41
42 pub fn salience_rank(&self) -> u8 {
49 match self {
50 Self::Causal => 0,
51 Self::Motivational => 1,
52 Self::Evidential => 2,
53 Self::Constraint => 3,
54 Self::Procedural => 4,
55 Self::Structural => 5,
56 }
57 }
58}