Skip to main content

mif_core/
concept.rs

1use serde::{Deserialize, Serialize};
2
3/// MIF's three-way knowledge taxonomy.
4///
5/// Shared by the `conceptType` field (current, required on a MIF document)
6/// and the `memoryType` field (deprecated v0.1 alias, retained on the
7/// document for backward compatibility). See the MIF schema
8/// (`mif.schema.json`) for the authoritative definition.
9#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
10#[serde(rename_all = "lowercase")]
11pub enum ConceptType {
12    /// Declarative knowledge.
13    Semantic,
14    /// Time-bound records.
15    Episodic,
16    /// How-to knowledge.
17    Procedural,
18}
19
20#[cfg(test)]
21mod tests {
22    use super::ConceptType;
23
24    #[test]
25    fn round_trips_through_json() {
26        for value in [
27            ConceptType::Semantic,
28            ConceptType::Episodic,
29            ConceptType::Procedural,
30        ] {
31            let json = serde_json::to_string(&value).unwrap();
32            let parsed: ConceptType = serde_json::from_str(&json).unwrap();
33            assert_eq!(value, parsed);
34        }
35    }
36
37    #[test]
38    fn serializes_lowercase() {
39        let json = serde_json::to_string(&ConceptType::Episodic).unwrap();
40        assert_eq!(json, "\"episodic\"");
41    }
42}