1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
use crate::owl::{Annotation, ClassConstructor};
#[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize)]
pub struct DisjointClasses {
pub classes: Vec<ClassConstructor>,
pub annotations: Vec<Annotation>,
}
impl DisjointClasses {
pub fn new(classes: Vec<ClassConstructor>, annotations: Vec<Annotation>) -> Self {
Self {
classes,
annotations,
}
}
}
impl From<DisjointClasses> for ClassConstructor {
fn from(c: DisjointClasses) -> Self {
ClassConstructor::DisjointClasses(c)
}
}
impl From<DisjointClasses> for Box<ClassConstructor> {
fn from(c: DisjointClasses) -> Self {
Box::new(ClassConstructor::DisjointClasses(c))
}
}
impl ClassConstructor {
pub fn disjoint_classes(&self) -> Option<&DisjointClasses> {
match self {
ClassConstructor::DisjointClasses(d) => Some(d),
_ => None,
}
}
}
#[cfg(feature = "wasm")]
mod wasm {
use wasm_bindgen::prelude::wasm_bindgen;
#[wasm_bindgen(typescript_custom_section)]
const WASM_API: &'static str = r#"
export type DisjointClasses = {
classes: Array<ClassConstructor>,
annotations: Array<Annotation>,
};
"#;
}