From 94a0e361e180223adf2bc9760c8810dfa3c2681f Mon Sep 17 00:00:00 2001 From: jelemux Date: Thu, 28 Jan 2021 22:24:32 +0100 Subject: use different vcard library --- src/viewmodel/telephone.rs | 56 +--------------------------------------------- 1 file changed, 1 insertion(+), 55 deletions(-) (limited to 'src/viewmodel/telephone.rs') diff --git a/src/viewmodel/telephone.rs b/src/viewmodel/telephone.rs index f90df5d..e5f63f0 100644 --- a/src/viewmodel/telephone.rs +++ b/src/viewmodel/telephone.rs @@ -1,6 +1,3 @@ -use vcard::properties; -use vcard::parameters; -use vcard::values; use std::collections::HashSet; use super::*; use crate::view::telephone::*; @@ -20,7 +17,7 @@ pub struct Telephone { pub text_phone: bool, } -impl VCardPropertyInputObject for Telephone { +impl VCardPropertyInputObject for Telephone { fn new() -> Self { Self { number: String::new(), @@ -112,55 +109,4 @@ impl VCardPropertyInputObject for Telephon self.number.is_empty() && self.extension.is_empty() } - fn to_vcard_property(&self) -> Result { // TODO error handling - let mut telephone = properties::Telephone::from_telephone_value( - values::telephone_value::TelephoneValue::from_telephone_number_str( - self.number.clone(), - match self.extension.is_empty() { - true => None::<&str>, - false => Some(&self.extension), - }, - ).unwrap() - ); - - let type_values = { - let mut type_values = HashSet::new(); - - if self.work { - type_values.insert(values::type_value::TypeValueWithTelephoneType::Work); - } - if self.home { - type_values.insert(values::type_value::TypeValueWithTelephoneType::Home); - } - if self.text { - type_values.insert(values::type_value::TypeValueWithTelephoneType::Text); - } - if self.voice { - type_values.insert(values::type_value::TypeValueWithTelephoneType::Voice); - } - if self.fax { - type_values.insert(values::type_value::TypeValueWithTelephoneType::Fax); - } - if self.cell { - type_values.insert(values::type_value::TypeValueWithTelephoneType::Cell); - } - if self.video { - type_values.insert(values::type_value::TypeValueWithTelephoneType::Video); - } - if self.pager { - type_values.insert(values::type_value::TypeValueWithTelephoneType::Pager); - } - if self.text_phone { - type_values.insert(values::type_value::TypeValueWithTelephoneType::TextPhone); - } - - vcard::Set::from_hash_set(type_values).unwrap() - }; - - if let properties::Telephone::TelephoneValue { ref mut typ, .. } = telephone { - *typ = Some(parameters::typ::TypeWithTelType::from_type_values(type_values)); - } - - Ok(telephone) - } } \ No newline at end of file -- cgit v1.2.3