use yewtil::ptr::Irc; use crate::viewmodel::telephone::Telephone; use crate::viewmodel::address::Address; use crate::viewmodel::name::Name; /// Type that represents the data structure of a vcard. #[derive(Clone, Debug)] pub struct VCardData { pub names: Vec>, pub addresses: Vec>, pub telephones: Vec>, } 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(), } } make_vec_adder_fn!( fn add_name names => name: Irc ); make_vec_adder_fn!( fn add_address addresses => address: Irc
); make_vec_adder_fn!( fn add_telephone telephones => telephone: Irc ); }