graphforge_knowledge/research/
enums.rs1use super::{ClaimRelationKind, ResearchCategory, ResearchDecisionKind, ResearchSubjectKind};
3use crate::{KnowledgeError, invalid};
4impl ResearchCategory {
5 #[must_use]
7 pub const fn as_str(self) -> &'static str {
8 match self {
9 Self::MachineExtraction => "machine_extraction",
10 Self::AnalystAssertion => "analyst_assertion",
11 Self::Interpretation => "interpretation",
12 Self::Hypothesis => "hypothesis",
13 Self::Theory => "theory",
14 Self::Annotation => "annotation",
15 }
16 }
17 pub(super) fn parse(value: &str) -> Result<Self, KnowledgeError> {
18 match value {
19 "machine_extraction" => Ok(Self::MachineExtraction),
20 "analyst_assertion" => Ok(Self::AnalystAssertion),
21 "interpretation" => Ok(Self::Interpretation),
22 "hypothesis" => Ok(Self::Hypothesis),
23 "theory" => Ok(Self::Theory),
24 "annotation" => Ok(Self::Annotation),
25 _ => Err(invalid(
26 "ResearchCategory",
27 "unsupported closed registry value",
28 )),
29 }
30 }
31}
32impl ClaimRelationKind {
33 #[must_use]
35 pub const fn as_str(self) -> &'static str {
36 match self {
37 Self::AlternativeTo => "alternative_to",
38 Self::Contradicts => "contradicts",
39 Self::Disputes => "disputes",
40 Self::Refines => "refines",
41 Self::Supersedes => "supersedes",
42 Self::Supports => "supports",
43 }
44 }
45 pub(super) fn parse(value: &str) -> Result<Self, KnowledgeError> {
46 match value {
47 "alternative_to" => Ok(Self::AlternativeTo),
48 "contradicts" => Ok(Self::Contradicts),
49 "disputes" => Ok(Self::Disputes),
50 "refines" => Ok(Self::Refines),
51 "supersedes" => Ok(Self::Supersedes),
52 "supports" => Ok(Self::Supports),
53 _ => Err(invalid(
54 "ClaimRelationKind",
55 "unsupported closed registry value",
56 )),
57 }
58 }
59}
60impl ResearchSubjectKind {
61 #[must_use]
63 pub const fn as_str(self) -> &'static str {
64 match self {
65 Self::Node => "node",
66 Self::Edge => "edge",
67 Self::Assertion => "assertion",
68 }
69 }
70 pub(super) fn parse(value: &str) -> Result<Self, KnowledgeError> {
71 match value {
72 "node" => Ok(Self::Node),
73 "edge" => Ok(Self::Edge),
74 "assertion" => Ok(Self::Assertion),
75 _ => Err(invalid(
76 "ResearchSubjectKind",
77 "unsupported closed registry value",
78 )),
79 }
80 }
81}
82impl ResearchDecisionKind {
83 #[must_use]
85 pub const fn as_str(self) -> &'static str {
86 match self {
87 Self::Integrate => "integrate",
88 Self::Promote => "promote",
89 Self::Revoke => "revoke",
90 }
91 }
92 pub(super) fn parse(value: &str) -> Result<Self, KnowledgeError> {
93 match value {
94 "integrate" => Ok(Self::Integrate),
95 "promote" => Ok(Self::Promote),
96 "revoke" => Ok(Self::Revoke),
97 _ => Err(invalid(
98 "ResearchDecisionKind",
99 "unsupported closed registry value",
100 )),
101 }
102 }
103}