summaryrefslogtreecommitdiff
path: root/src/viewmodel/address.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/viewmodel/address.rs')
-rw-r--r--src/viewmodel/address.rs57
1 files changed, 1 insertions, 56 deletions
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<properties::Address, AddressView> for Address {
+impl VCardPropertyInputObject<AddressView> for Address {
fn new() -> Self {
Self {
post_office_box: String::new(),
@@ -106,55 +102,4 @@ impl VCardPropertyInputObject<properties::Address, AddressView> for Address {
self.code.is_empty() &&
self.country.is_empty()
}
- fn to_vcard_property(&self) -> Result<properties::Address, Error> { // 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