This repository has been archived by the owner on Jul 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
types.rs
72 lines (64 loc) · 1.92 KB
/
types.rs
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
use serde::{Deserialize, Serialize};
use types::{Source, Unit};
use crate::types::CaBr2Document;
#[derive(Deserialize, Serialize)]
#[serde(rename_all = "camelCase", tag = "version")]
#[allow(clippy::large_enum_variant)]
pub enum CaBr2DocumentFormat {
#[serde(rename = "1")]
V1(CaBr2Document),
}
#[derive(Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct CaBr2DocumentV0 {
pub header: HeaderV0,
pub substance_data: Vec<SubstanceDataV0>,
pub human_and_environment_danger: Vec<String>,
pub rules_of_conduct: Vec<String>,
pub in_case_of_danger: Vec<String>,
pub disposal: Vec<String>,
}
#[derive(Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct HeaderV0 {
pub document_title: String,
pub organisation: String,
pub lab_course: String,
pub name: String,
pub place: String,
pub assistant: String,
pub preparation: String,
}
#[derive(Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct SubstanceDataV0 {
pub name: DataV0<String>,
pub alternative_names: Vec<String>,
pub cas: DataV0<Option<String>>,
pub molecular_formula: DataV0<Option<String>>,
pub molar_mass: DataV0<Option<String>>,
pub melting_point: DataV0<Option<String>>,
pub boiling_point: DataV0<Option<String>>,
pub water_hazard_class: DataV0<Option<String>>,
pub h_phrases: DataV0<Vec<(String, String)>>,
pub p_phrases: DataV0<Vec<(String, String)>>,
pub signal_word: DataV0<Option<String>>,
pub symbols: DataV0<Vec<String>>,
pub lethal_dose: DataV0<Option<String>>,
pub mak: DataV0<Option<String>>,
pub amount: Option<AmountV0>,
pub source: Source,
pub checked: bool,
}
#[derive(Debug, Deserialize, Serialize)]
pub struct AmountV0 {
pub value: String,
pub unit: Unit,
}
#[derive(Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct DataV0<T> {
#[serde(skip_serializing_if = "Option::is_none")]
pub modified_data: Option<T>,
pub original_data: T,
}