From 89059bb7da412d6902eceb69047d1e155a4335ba Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 27 Sep 2018 14:42:58 +0200 Subject: [PATCH] Fix: Use VcardBuilder instead of Vcard itself The current implementation does not panic on VcardBuilder::build(), so we unwrap() that directly. Should be fixed in future versions of either rust-vobject or here, so that we error appropriately. Signed-off-by: Matthias Beyer --- bin/domain/imag-contact/src/create.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bin/domain/imag-contact/src/create.rs b/bin/domain/imag-contact/src/create.rs index d5ae4131..18de82c9 100644 --- a/bin/domain/imag-contact/src/create.rs +++ b/bin/domain/imag-contact/src/create.rs @@ -39,6 +39,7 @@ use std::path::PathBuf; use std::fs::OpenOptions; use vobject::vcard::Vcard; +use vobject::vcard::VcardBuilder; use vobject::write_component; use toml_query::read::TomlValueReadExt; use toml::Value; @@ -208,7 +209,7 @@ pub fn create(rt: &Runtime) { } fn parse_toml_into_vcard(toml: Value, uuid: String) -> Option { - let mut vcard = Vcard::default().with_uid(uuid); + let mut vcard = VcardBuilder::new().with_uid(uuid); { // parse name debug!("Parsing name"); @@ -448,6 +449,9 @@ fn parse_toml_into_vcard(toml: Value, uuid: String) -> Option { } + let vcard = vcard + .build() + .unwrap(); // TODO: This unwrap does not fail with rust-vobject, why is there a Result<> returned? Some(vcard) }