summaryrefslogtreecommitdiff
path: root/src/viewmodel/address.rs
diff options
context:
space:
mode:
authorjelemux <jeremias.weber@protonmail.com>2021-01-28 22:24:32 +0100
committerjelemux <jeremias.weber@protonmail.com>2021-01-28 22:24:32 +0100
commit94a0e361e180223adf2bc9760c8810dfa3c2681f (patch)
treed29de5300d0ff0ba636f48eca8df43bb5256b49c /src/viewmodel/address.rs
parent3f0892368bcf475fdae39f24ef51b82b3013535f (diff)
downloadwasm-card-94a0e361e180223adf2bc9760c8810dfa3c2681f.tar.gz
wasm-card-94a0e361e180223adf2bc9760c8810dfa3c2681f.tar.bz2
use different vcard library
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