obographs_dev/
model.rs

1//! The module with Obographs types.
2
3#[cfg(feature = "serde")]
4use serde::{Deserialize, Serialize};
5
6#[derive(Clone, Debug)]
7#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
8pub struct GraphDocument {
9    pub graphs: Vec<Graph>,
10    pub meta: Option<Box<Meta>>,
11}
12
13#[derive(Clone, Debug)]
14#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
15pub struct Graph {
16    pub id: String,
17    pub lbl: Option<String>,
18    pub meta: Option<Box<Meta>>,
19    pub nodes: Vec<Node>,
20    pub edges: Vec<Edge>,
21    // TODO: continue with adding the following:
22    //  - equivalentNodesSets
23    //  - logicalDefinitionAxioms
24    //  - domainRangeAxioms
25    //  - propertyChainAxioms
26}
27
28#[derive(Clone, Debug)]
29#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
30pub enum RdfTypes {
31    #[cfg_attr(feature = "serde", serde(rename(serialize = "CLASS", deserialize = "CLASS")))]
32    Class,
33    #[cfg_attr(feature = "serde", serde(rename(serialize = "INDIVIDUAL", deserialize = "INDIVIDUAL")))]
34    Individual,
35    #[cfg_attr(feature = "serde", serde(rename(serialize = "PROPERTY", deserialize = "PROPERTY")))]
36    Property,
37}
38
39#[derive(Clone, Debug)]
40#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
41pub struct Node {
42    pub id: String,
43    pub lbl: Option<String>,
44    #[cfg_attr(feature = "serde", serde(rename(serialize = "type", deserialize = "type")))]
45    pub rdf_type: Option<RdfTypes>,
46    pub meta: Option<Meta>,
47}
48
49#[derive(Clone, Debug)]
50#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
51pub struct Edge {
52    pub sub: String,
53    pub pred: String,
54    pub obj: String,
55    pub meta: Option<Meta>,
56}
57
58#[derive(Clone, Debug)]
59#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
60pub struct Meta {
61    pub definition: Option<DefinitionPropertyValue>,
62    #[cfg_attr(feature = "serde", serde(default))]
63    pub comments: Vec<String>,
64    #[cfg_attr(feature = "serde", serde(default))]
65    pub subsets: Vec<String>,
66    #[cfg_attr(feature = "serde", serde(default))]
67    pub synonyms: Vec<SynonymPropertyValue>,
68    #[cfg_attr(feature = "serde", serde(default))]
69    pub xrefs: Vec<XrefPropertyValue>,
70    #[cfg_attr(
71        feature = "serde",
72        serde(
73            default,
74            rename(serialize = "basicPropertyValues", deserialize = "basicPropertyValues")
75        )
76    )]
77    pub basic_property_values: Vec<BasicPropertyValue>,
78    pub version: Option<String>,
79    pub deprecated: Option<bool>,
80}
81
82#[derive(Clone, Debug)]
83#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
84pub struct BasicPropertyValue {
85    pub pred: String,
86    pub val: String,
87    pub xrefs: Option<Vec<String>>,
88    pub meta: Option<Box<Meta>>,
89}
90
91#[derive(Clone, Debug)]
92#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
93pub struct DefinitionPropertyValue {
94    pub pred: Option<String>,
95    pub val: String,
96    pub xrefs: Option<Vec<String>>,
97    pub meta: Option<Box<Meta>>,
98}
99
100#[derive(Clone, Debug)]
101#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
102pub struct SynonymPropertyValue {
103    pub pred: String,
104    pub val: String,
105    pub xrefs: Option<Vec<String>>,
106    pub meta: Option<Box<Meta>>,
107    #[cfg_attr(
108        feature = "serde",
109        serde(rename(serialize = "synonymType", deserialize = "synonymType"))
110    )]
111    pub synonym_type: Option<String>,
112}
113
114#[derive(Clone, Debug)]
115#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
116pub struct XrefPropertyValue {
117    pub pred: Option<String>,
118    pub val: String,
119    pub xrefs: Option<Vec<String>>,
120    pub meta: Option<Box<Meta>>,
121    pub lbl: Option<String>,
122}