summaryrefslogtreecommitdiff
path: root/src/model/vcard.rs
diff options
context:
space:
mode:
authorjelemux <jeremias.weber@protonmail.com>2021-02-17 17:06:48 +0100
committerjelemux <jeremias.weber@protonmail.com>2021-02-17 17:06:48 +0100
commitcb310a66e94db4e0c4f7d0373a670156b012412a (patch)
tree501fd4ed17d892d693d4123fffaca8d942144e3b /src/model/vcard.rs
parentbe3367dd2921eb30ae7970d233b83ac3af861952 (diff)
parent0660151a8b641fa0a23dde2598132029970f7ae4 (diff)
downloadwasm-card-cb310a66e94db4e0c4f7d0373a670156b012412a.tar.gz
wasm-card-cb310a66e94db4e0c4f7d0373a670156b012412a.tar.bz2
Merge branch 'main' of codeberg.org:jelemux/wasm-card
Diffstat (limited to 'src/model/vcard.rs')
-rw-r--r--src/model/vcard.rs40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/model/vcard.rs b/src/model/vcard.rs
new file mode 100644
index 0000000..ee7e28e
--- /dev/null
+++ b/src/model/vcard.rs
@@ -0,0 +1,40 @@
+use crate::model::address::Address;
+use crate::model::dates::Dates;
+use crate::model::name::Name;
+use crate::model::organizational::Organizational;
+use crate::model::telephone::Telephone;
+
+/// Type that represents the data structure of a vcard.
+#[derive(Clone, Debug)]
+pub struct VCardData {
+ pub names: Vec<Name>,
+ pub addresses: Vec<Address>,
+ pub telephones: Vec<Telephone>,
+ pub datess: Vec<Dates>,
+ pub organizationals: Vec<Organizational>,
+}
+
+macro_rules! make_vec_adder_fn {
+ ( fn $fnname:ident $property:ident => $($arg_name:ident : $arg_type:ty),* ) => {
+ pub fn $fnname(&mut self, $( $arg_name : $arg_type ),*) {
+ $(self.$property.push($arg_name);)*
+ }
+ };
+}
+
+impl VCardData {
+ pub fn new() -> Self {
+ Self {
+ names: Vec::new(),
+ addresses: Vec::new(),
+ telephones: Vec::new(),
+ datess: Vec::new(),
+ organizationals: Vec::new(),
+ }
+ }
+ make_vec_adder_fn!( fn add_name names => name: Name );
+ make_vec_adder_fn!( fn add_address addresses => address: Address );
+ make_vec_adder_fn!( fn add_telephone telephones => telephone: Telephone );
+ make_vec_adder_fn!( fn add_dates datess => dates: Dates );
+ make_vec_adder_fn!( fn add_organizational organizationals => organizational: Organizational );
+}