summaryrefslogtreecommitdiff
path: root/src/model.rs
diff options
context:
space:
mode:
authorjelemux <jeremias.weber@protonmail.com>2020-10-19 22:46:45 +0200
committerjelemux <jeremias.weber@protonmail.com>2020-10-19 22:46:45 +0200
commit3a0a55362fd98c74bfb14df320bcacafd0c57835 (patch)
treead7f91af95df638bfbc58c48c97f34340ae37a8c /src/model.rs
parent84c2dab4200c37c818d83c95f85445ee00d83bf6 (diff)
downloadwasm-card-3a0a55362fd98c74bfb14df320bcacafd0c57835.tar.gz
wasm-card-3a0a55362fd98c74bfb14df320bcacafd0c57835.tar.bz2
break things down into their most basic parts
Diffstat (limited to 'src/model.rs')
-rw-r--r--src/model.rs76
1 files changed, 0 insertions, 76 deletions
diff --git a/src/model.rs b/src/model.rs
deleted file mode 100644
index cac0820..0000000
--- a/src/model.rs
+++ /dev/null
@@ -1,76 +0,0 @@
-use chrono::NaiveDateTime;
-use crate::validation::{self, *};
-
-pub struct BCard {
- name: Option<Name>,
- nickname: Option<String>,
- label: Option<TypedProperty<String>>,
- address: Option<TypedProperty<Address>>,
- emails: Option<Vec<TypedProperty<String>>>,
- title: Option<String>,
- role: Option<String>,
- organization: Option<String>,
- urls: Option<Vec<TypedProperty<String>>>,
- telephones: Option<Vec<TypedProperty<String>>>,
- revision: Option<NaiveDateTime>,
-}
-
-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<String>,
- first_name: Option<String>,
- middle_name: Option<String>,
- family_name: Option<String>,
- suffix: Option<String>,
-}
-
-impl Validation for Name {
- fn validate(&self) -> std::result::Result<(), ValidationError> { todo!() }
-}
-
-pub enum WorkHomeType {
- Home,
- Work,
-}
-
-pub struct TypedProperty<T> {
- p_type: Option<WorkHomeType>,
- value: T,
-}
-
-pub struct Address {
- street: Option<String>,
- city: Option<String>,
- locality: Option<String>,
- postal_code: Option<String>,
- country: Option<String>,
-} \ No newline at end of file