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/address.rs | 57 +----------------------------------------------- 1 file changed, 1 insertion(+), 56 deletions(-) (limited to 'src/viewmodel/address.rs') diff --git a/src/viewmodel/address.rs b/src/viewmodel/address.rs index b2257bf..61bd464 100644 --- a/src/viewmodel/address.rs +++ b/src/viewmodel/address.rs @@ -1,7 +1,3 @@ -use vcard::properties; -use vcard::parameters; -use vcard::values::{self, text}; -use std::collections::HashSet; use super::*; use crate::view::address::*; @@ -18,7 +14,7 @@ pub struct Address { pub home: bool, } -impl VCardPropertyInputObject for Address { +impl VCardPropertyInputObject for Address { fn new() -> Self { Self { post_office_box: String::new(), @@ -106,55 +102,4 @@ impl VCardPropertyInputObject for Address { self.code.is_empty() && self.country.is_empty() } - fn to_vcard_property(&self) -> Result { // TODO error handling - let address_value = values::address_value::AddressValue::from_components( - match self.post_office_box.is_empty() { - true => None, - false => Some(text::Component::from_str(&self.post_office_box).unwrap()), - }, - match self.extension.is_empty() { - true => None, - false => Some(text::Component::from_str(&self.extension).unwrap()), - }, - match self.street.is_empty() { - true => None, - false => Some(text::Component::from_str(&self.street).unwrap()), - }, - match self.locality.is_empty() { - true => None, - false => Some(text::Component::from_str(&self.locality).unwrap()), - }, - match self.region.is_empty() { - true => None, - false => Some(text::Component::from_str(&self.region).unwrap()), - }, - match self.code.is_empty() { - true => None, - false => Some(text::Component::from_str(&self.code).unwrap()), - }, - match self.country.is_empty() { - true => None, - false => Some(text::Component::from_str(&self.country).unwrap()), - }, - ); - - let mut address = properties::Address::from_address_value(address_value); - - let type_values = { - let mut type_values = HashSet::new(); - - if self.work { - type_values.insert(values::type_value::TypeValue::Work); - } - if self.home { - type_values.insert(values::type_value::TypeValue::Home); - } - - vcard::Set::from_hash_set(type_values).unwrap() - }; - - address.typ = Some(parameters::typ::Type::from_type_values(type_values)); - - Ok(address) - } } \ No newline at end of file -- cgit v1.2.3