From 84c2dab4200c37c818d83c95f85445ee00d83bf6 Mon Sep 17 00:00:00 2001 From: jelemux Date: Sun, 18 Oct 2020 22:40:57 +0200 Subject: initial commit --- src/model.rs | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 src/model.rs (limited to 'src/model.rs') diff --git a/src/model.rs b/src/model.rs new file mode 100644 index 0000000..cac0820 --- /dev/null +++ b/src/model.rs @@ -0,0 +1,76 @@ +use chrono::NaiveDateTime; +use crate::validation::{self, *}; + +pub struct BCard { + name: Option, + nickname: Option, + label: Option>, + address: Option>, + emails: Option>>, + title: Option, + role: Option, + organization: Option, + urls: Option>>, + telephones: Option>>, + revision: Option, +} + +impl BCard { + fn new() -> Self { + Self { + name: None, + nickname: None, + label: None, + address: None, + emails: None, + title: None, + role: None, + organization: None, + urls: None, + telephones: None, + revision: None, + } + } +} + +impl Validation for BCard { + fn validate(&self) -> Result<(), ValidationError> { + let mut result = Ok(()); + result = match &self.name { + Some(n) => validation::add_results(result, n.validate()), + None => Err( ValidationError{ messages: vec![String::from("Name cannot be empty")] } ), + }; + // TODO add some more validation + result + } +} + +pub struct Name { + prefix: Option, + first_name: Option, + middle_name: Option, + family_name: Option, + suffix: Option, +} + +impl Validation for Name { + fn validate(&self) -> std::result::Result<(), ValidationError> { todo!() } +} + +pub enum WorkHomeType { + Home, + Work, +} + +pub struct TypedProperty { + p_type: Option, + value: T, +} + +pub struct Address { + street: Option, + city: Option, + locality: Option, + postal_code: Option, + country: Option, +} \ No newline at end of file -- cgit v1.2.3