basyx_rs/submodel_element/
range.rs

1// SPDX-FileCopyrightText: 2021 Fraunhofer Institute for Experimental Software Engineering IESE
2// SPDX-FileCopyrightText: 2023 Jan Hecht
3//
4// SPDX-License-Identifier: MIT
5
6use super::EmbeddedDataSpecification;
7use crate::LangString as LangStringTextType;
8use crate::{qualifier::Qualifier, reference::Reference, Extension};
9use crate::{DataTypeDefXsd, LangString as LangStringNameType};
10use serde::{Deserialize, Serialize};
11
12// #[cfg(feature = "explorer")]
13// use super::ValueType;
14
15#[derive(Clone, PartialEq, Debug, Deserialize, Serialize)]
16pub struct Range {
17    // Referable
18    // HasExtension
19    #[serde(skip_serializing_if = "Option::is_none")]
20    pub extensions: Option<Vec<Extension>>,
21
22    #[serde(skip_serializing_if = "Option::is_none")]
23    pub category: Option<String>,
24
25    #[serde(skip_serializing_if = "Option::is_none")]
26    #[serde(rename = "idShort")]
27    pub id_short: Option<String>,
28
29    #[serde(skip_serializing_if = "Option::is_none")]
30    #[serde(rename = "displayName")]
31    pub display_name: Option<Vec<LangStringNameType>>,
32
33    #[serde(skip_serializing_if = "Option::is_none")]
34    pub description: Option<Vec<LangStringTextType>>,
35
36    // HasSemantics
37    #[serde(skip_serializing_if = "Option::is_none")]
38    #[serde(rename = "semanticId")]
39    pub semantic_id: Option<Reference>,
40
41    #[serde(skip_serializing_if = "Option::is_none")]
42    #[serde(rename = "supplementalSemanticIds")]
43    pub supplemental_semantic_ids: Option<Vec<Reference>>,
44
45    // Qualifiable
46    #[serde(skip_serializing_if = "Option::is_none")]
47    pub qualifiers: Option<Vec<Qualifier>>,
48
49    // HasDataSpecification
50    #[serde(skip_serializing_if = "Option::is_none")]
51    #[serde(rename = "embeddedDataSpecifications")]
52    pub embedded_data_specifications: Option<Vec<EmbeddedDataSpecification>>,
53
54    // Range
55    #[cfg(feature = "explorer")]
56    #[serde(skip_serializing_if = "Option::is_none")]
57    pub min: Option<String>,
58
59    // #[cfg(not(feature = "explorer"))]
60    // #[serde(skip_serializing_if = "Option::is_none")]
61    // pub min: Option<Value>,
62    #[cfg(feature = "explorer")]
63    #[serde(skip_serializing_if = "Option::is_none")]
64    pub max: Option<String>,
65    // #[cfg(not(feature = "explorer"))]
66    // #[serde(skip_serializing_if = "Option::is_none")]
67    // pub max: Option<Value>,
68    //#[cfg(feature = "explorer")]
69    pub value_type: DataTypeDefXsd,
70    //#[cfg(not(feature = "explorer"))]
71    //pub value_type: String,
72}
73
74// TODO implement after clarification
75// impl Range {
76//     pub fn new(
77//         id_short: String,
78//         min: Option<Value>,
79//         max: Option<Value>,
80//         value_type: DataObjectTypeName,
81//     ) -> Self {
82//         Self {
83//             #[cfg(feature = "explorer")]
84//             min: {
85//                 if let Some(v) = min {
86//                     v.to_string()
87//                 } else {
88//                     String::from("")
89//                 }
90//             },
91//             #[cfg(not(feature = "explorer"))]
92//             min,
93//             #[cfg(feature = "explorer")]
94//             max: {
95//                 if let Some(v) = max {
96//                     v.to_string()
97//                 } else {
98//                     String::from("")
99//                 }
100//             },
101//             #[cfg(not(feature = "explorer"))]
102//             max,
103//             semantic_id: None,
104//             embedded_data_specification: vec![],
105//             id_short,
106//             category: None,
107//             model_type: ModelType::Range,
108//             #[cfg(feature = "explorer")]
109//             value_type: ValueType::new(value_type),
110//             #[cfg(not(feature = "explorer"))]
111//             value_type: value_type.to_string(),
112//             kind: None,
113//             qualifiers: vec![],
114//         }
115//     }
116// }