stoa_core/
relationship.rs1use serde::{Deserialize, Serialize};
4
5pub const DEFAULT_ENTITY_TYPES: &[&str] = &[
8 "person", "project", "library", "service", "tool", "file", "decision", "concept",
9];
10
11pub const DEFAULT_RELATIONSHIP_TYPES: &[&str] = &[
13 "uses",
14 "depends_on",
15 "instance_of",
16 "caused",
17 "fixed",
18 "supersedes",
19 "contradicts",
20 "cites",
21 "mentions",
22];
23
24#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
28#[serde(transparent)]
29pub struct EntityType(pub String);
30
31impl EntityType {
32 #[must_use]
34 pub fn as_str(&self) -> &str {
35 &self.0
36 }
37}
38
39impl std::fmt::Display for EntityType {
40 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
41 f.write_str(&self.0)
42 }
43}
44
45#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
48#[serde(transparent)]
49pub struct RelationshipType(pub String);
50
51impl RelationshipType {
52 #[must_use]
54 pub fn as_str(&self) -> &str {
55 &self.0
56 }
57}
58
59impl std::fmt::Display for RelationshipType {
60 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
61 f.write_str(&self.0)
62 }
63}
64
65#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
70pub struct Relationship {
71 #[serde(rename = "type")]
73 pub kind: RelationshipType,
74 pub target: String,
76 #[serde(default, skip_serializing_if = "Option::is_none")]
78 pub confidence: Option<f64>,
79 #[serde(default, skip_serializing_if = "Vec::is_empty")]
81 pub sources: Vec<String>,
82}