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
#[cfg(feature = "read_write")]
use crate::read_write::component::Component;
#[derive(Debug, Clone, PartialEq, PartialOrd)]
pub struct Org {
pub org: String,
pub unit: String,
pub office: String,
}
impl Org {
#[must_use]
pub const fn new(org: String, unit: String, office: String) -> Self {
Self { org, unit, office }
}
}
#[cfg(feature = "read_write")]
impl From<Org> for Component {
fn from(org: Org) -> Self {
Self {
name: "ORG".to_string(),
values: vec![vec![org.org], vec![org.unit], vec![org.office]],
..Self::default()
}
}
}
#[cfg(feature = "read_write")]
impl From<Component> for Org {
fn from(mut comp: Component) -> Self {
Self {
org: comp
.values
.get_mut(0)
.and_then(Vec::pop)
.unwrap_or_default(),
unit: comp
.values
.get_mut(1)
.and_then(Vec::pop)
.unwrap_or_default(),
office: comp
.values
.get_mut(2)
.and_then(Vec::pop)
.unwrap_or_default(),
}
}
}