Skip to main content

ontocore_edit/
change.rs

1use ontocore_obo::OboPatchOp;
2use ontocore_owl::PatchOp;
3use serde::{Deserialize, Serialize};
4
5/// A single semantic edit, represented as a format-specific patch op until
6/// RDF/XML and OWL/XML adapters land (v0.21).
7#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
8#[serde(tag = "format", rename_all = "snake_case")]
9pub enum SemanticChange {
10    Turtle { change: PatchOp },
11    Obo { change: OboPatchOp },
12}
13
14impl SemanticChange {
15    pub fn turtle(change: PatchOp) -> Self {
16        Self::Turtle { change }
17    }
18
19    pub fn obo(change: OboPatchOp) -> Self {
20        Self::Obo { change }
21    }
22
23    pub fn is_turtle(&self) -> bool {
24        matches!(self, Self::Turtle { .. })
25    }
26
27    pub fn is_obo(&self) -> bool {
28        matches!(self, Self::Obo { .. })
29    }
30}