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) and the `memoryType` field
6/// (deprecated v0.1 alias, retained for backward compatibility). A MIF
7/// document must carry one of the two; since MIF 1.4.0 a document with only
8/// `memoryType` satisfies the schema's type requirement. See the MIF schema
9/// (`mif.schema.json`) for the authoritative definition.
10#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
11#[serde(rename_all = "lowercase")]
12pub enum ConceptType {
13    /// Declarative knowledge.
14    Semantic,
15    /// Time-bound records.
16    Episodic,
17    /// How-to knowledge.
18    Procedural,
19}
20
21#[cfg(test)]
22mod tests {
23    use super::ConceptType;
24
25    #[test]
26    fn round_trips_through_json() {
27        for value in [
28            ConceptType::Semantic,
29            ConceptType::Episodic,
30            ConceptType::Procedural,
31        ] {
32            let json = serde_json::to_string(&value).unwrap();
33            let parsed: ConceptType = serde_json::from_str(&json).unwrap();
34            assert_eq!(value, parsed);
35        }
36    }
37
38    #[test]
39    fn serializes_lowercase() {
40        let json = serde_json::to_string(&ConceptType::Episodic).unwrap();
41        assert_eq!(json, "\"episodic\"");
42    }
43}