owlish/owl/datatypes/constructors/
datatype_definition.rs1use super::{DataComplementOf, DataIntersectionOf, DataOneOf, DataUnionOf, DatatypeRestriction};
2use crate::owl::{Annotation, DataPropertyIRI};
3
4#[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize)]
5pub enum DatatypeDefinitionConstructor {
6 DatatypeRestriction(DatatypeRestriction),
7 DataComplementOf(DataComplementOf),
8 DataIntersectionOf(DataIntersectionOf),
9 DataUnionOf(DataUnionOf),
10 DataOneOf(DataOneOf),
11}
12
13#[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize)]
14pub struct DatatypeDefinition {
15 #[serde(rename = "dataPropertyIRI")]
16 pub data_property_iri: DataPropertyIRI,
17 #[serde(rename = "datatype")]
18 pub datatype: DatatypeDefinitionConstructor,
19 #[serde(rename = "annotations")]
20 pub annotations: Vec<Annotation>,
21}
22
23impl DatatypeDefinition {
24 pub fn new(
25 data_property_iri: DataPropertyIRI,
26 datatype_definition: DatatypeDefinitionConstructor,
27 annotations: Vec<Annotation>,
28 ) -> Self {
29 Self {
30 data_property_iri,
31 datatype: datatype_definition,
32 annotations,
33 }
34 }
35}
36
37#[cfg(feature = "wasm")]
38mod wasm {
39 use wasm_bindgen::prelude::wasm_bindgen;
40
41 #[wasm_bindgen(typescript_custom_section)]
42 const WASM_API1: &'static str = r#"
43export interface DatatypeDefinitionConstructor {
44 DatatypeRestriction?: DatatypeRestriction
45 DataComplementOf?: DataComplementOf
46 DataIntersectionOf?: DataIntersectionOf
47 DataUnionOf?: DataUnionOf
48 DataOneOf?: DataOneOf
49}
50"#;
51
52 #[wasm_bindgen(typescript_custom_section)]
53 const WASM_API2: &'static str = r#"
54/**
55 * [DataProperty IRI, DatatypeDefinitionConstructor, annotations]
56 */
57export type DatatypeDefinition = {
58 dataPropertyIRI: IRI,
59 datatype: DatatypeDefinitionConstructor,
60 annotations: Array<Annotation>,
61};
62"#;
63}