From 3a0a55362fd98c74bfb14df320bcacafd0c57835 Mon Sep 17 00:00:00 2001 From: jelemux Date: Mon, 19 Oct 2020 22:46:45 +0200 Subject: break things down into their most basic parts --- excluded/model.rs | 88 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 excluded/model.rs (limited to 'excluded/model.rs') diff --git a/excluded/model.rs b/excluded/model.rs new file mode 100644 index 0000000..39e4c96 --- /dev/null +++ b/excluded/model.rs @@ -0,0 +1,88 @@ +use chrono::NaiveDateTime; +use crate::validation::{self, *}; + +pub struct BCard { + pub name: Option, + pub nickname: Option, + pub label: Option>, + pub address: Option>, + pub emails: Option>>, + pub title: Option, + pub role: Option, + pub organization: Option, + pub urls: Option>>, + pub telephones: Option>>, + pub revision: Option, +} + +impl BCard { + pub 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 { + pub prefix: Option, + pub first_name: Option, + pub middle_name: Option, + pub family_name: Option, + pub suffix: Option, +} + +impl Name { + pub fn new() -> Self { + Self { + prefix: None, + first_name: None, + middle_name: None, + family_name: None, + suffix: None, + } + } +} + +impl Validation for Name { + fn validate(&self) -> std::result::Result<(), ValidationError> { todo!() } +} + +pub enum WorkHomeType { + Home, + Work, +} + +pub struct TypedProperty { + pub p_type: Option, + pub value: T, +} + +pub struct Address { + pub street: Option, + pub city: Option, + pub locality: Option, + pub postal_code: Option, + pub country: Option, +} \ No newline at end of file -- cgit v1.2.3