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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
match self.vcard_data.get_mut() {
Some(vcard_builder) => *vcard_builder = vcard_builder.with_name(
parameters!(),
name.last_name.is_empty().then(|| name.last_name),
name.first_name.is_empty().then(|| name.first_name),
name.middle_name.is_empty().then(|| name.middle_name),
name.prefix.is_empty().then(|| name.prefix),
name.suffix.is_empty().then(|| name.suffix)
),
None => (),
};
--------------------------------------------------------------
let mut types = String::new();
if address.work {
types.push_str("WORK");
}
if address.home {
if types.is_empty() {
types.push(',');
}
types.push_str("HOME")
}
match self.vcard_data.get_mut() {
Some(vcard_builder) => *vcard_builder = vcard_builder.with_adr(
parameters!("TYPE" => types),
address.post_office_box.is_empty().then(|| address.post_office_box),
address.extension.is_empty().then(|| address.extension),
address.street.is_empty().then(|| address.street),
address.locality.is_empty().then(|| address.locality),
address.region.is_empty().then(|| address.region),
address.code.is_empty().then(|| address.code),
address.country.is_empty().then(|| address.country),
),
None => (),
};
----------------------------------------------------------------
let mut types = String::new();
if telephone.work {
types.push_str("WORK");
}
if telephone.home {
if types.is_empty() {
types.push(',');
}
types.push_str("HOME")
}
if telephone.text {
if types.is_empty() {
types.push(',');
}
types.push_str("TEXT")
}
if telephone.voice {
if types.is_empty() {
types.push(',');
}
types.push_str("VOICE")
}
if telephone.fax {
if types.is_empty() {
types.push(',');
}
types.push_str("FAX")
}
if telephone.cell {
if types.is_empty() {
types.push(',');
}
types.push_str("CELL")
}
if telephone.video {
if types.is_empty() {
types.push(',');
}
types.push_str("VIDEO")
}
if telephone.pager {
if types.is_empty() {
types.push(',');
}
types.push_str("PAGER")
}
if telephone.text_phone {
if types.is_empty() {
types.push(',');
}
types.push_str("TEXTPHONE")
}
match self.vcard_data.get_mut() {
Some(vcard_builder) => *vcard_builder = vcard_builder.with_tel(
parameters!("TYPE" => types),
telephone.number,
),
None => (),
};
|