Skip to main content

relay_knowledge/domain/core/
entity.rs

1use serde::{Deserialize, Serialize};
2
3/// A minimal entity model used by early graph-building code.
4#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
5pub struct KnowledgeEntity {
6    id: String,
7    label: String,
8}
9
10impl KnowledgeEntity {
11    /// Creates a new knowledge entity with a stable identifier and display label.
12    pub fn new(id: impl Into<String>, label: impl Into<String>) -> Self {
13        Self {
14            id: id.into(),
15            label: label.into(),
16        }
17    }
18
19    /// Returns the stable entity identifier.
20    pub fn id(&self) -> &str {
21        &self.id
22    }
23
24    /// Returns the human-readable entity label.
25    pub fn label(&self) -> &str {
26        &self.label
27    }
28}
29
30#[cfg(test)]
31#[path = "entity_tests.rs"]
32mod tests;