blob: 44191e8601d8223dd7493cf9a7e62b585dfac39b (
plain)
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
|
#[macro_export]
macro_rules! make_getter_function_for_optional {
($fnname:ident, $name:expr, $mapper:ty) => {
pub fn $fnname(&self) -> Option<$mapper> {
self.0.get_only($name).cloned().map(From::from)
}
}
}
#[macro_export]
macro_rules! make_getter_function_for_values {
($fnname:ident, $name:expr, $mapper:ty) => {
pub fn $fnname(&self) -> Vec<$mapper> {
self.0
.get_all($name)
.iter()
.map(Clone::clone)
.map(From::from)
.collect()
}
}
}
#[macro_export]
macro_rules! create_data_type {
( $name:ident ) => {
#[derive(Eq, PartialEq, Debug)]
pub struct $name(String, $crate::param::Parameters);
impl $name {
pub fn new(raw: String, params: $crate::param::Parameters) -> $name {
$name(raw, params)
}
pub fn from_raw(raw: String) -> $name {
$name(raw, BTreeMap::new())
}
pub fn raw(&self) -> &String {
&self.0
}
pub fn into_raw(self) -> String {
self.0
}
pub fn params(&self) -> &$crate::param::Parameters {
&self.1
}
}
impl From<Property> for $name {
fn from(p: Property) -> $name {
$name::new(p.raw_value, p.params)
}
}
}
}
#[cfg(feature = "timeconversions")]
pub const DATE_TIME_FMT : &'static str = "%Y%m%dT%H%M%SZ";
#[cfg(feature = "timeconversions")]
pub const DATE_FMT : &'static str = "%Y%m%d";
|