summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2021-10-24 11:21:11 +0200
committerMatthias Beyer <mail@beyermatthias.de>2021-10-24 12:02:00 +0200
commitab66b143d9acca14ac6ca26cf13cd2ec4a34c010 (patch)
tree2f0c37f5a43b055211e5f972868389eb68e4b294
parentac0f83ae012b3eeb3c05d5a04d5f80fc1f7b2af7 (diff)
Split model definition into multiple modules
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r--service-person/src/main.rs2
-rw-r--r--service-person/src/model.rs32
-rw-r--r--service-person/src/model/address.rs11
-rw-r--r--service-person/src/model/age.rs5
-rw-r--r--service-person/src/model/city.rs5
-rw-r--r--service-person/src/model/country.rs5
-rw-r--r--service-person/src/model/mod.rs20
-rw-r--r--service-person/src/model/name.rs6
-rw-r--r--service-person/src/model/person.rs9
-rw-r--r--service-person/src/model/street.rs5
10 files changed, 67 insertions, 33 deletions
diff --git a/service-person/src/main.rs b/service-person/src/main.rs
index 001888f..1983c28 100644
--- a/service-person/src/main.rs
+++ b/service-person/src/main.rs
@@ -14,7 +14,7 @@ use diesel::r2d2::Pool;
mod model;
-use model::*;
+use crate::model::*;
embed_migrations!("migrations");
diff --git a/service-person/src/model.rs b/service-person/src/model.rs
deleted file mode 100644
index aa81312..0000000
--- a/service-person/src/model.rs
+++ /dev/null
@@ -1,32 +0,0 @@
-use serde::Deserialize;
-
-#[derive(Debug, Deserialize)]
-pub struct Name(String);
-
-#[derive(Debug, Deserialize)]
-pub struct Age(usize);
-
-#[derive(Debug, Deserialize)]
-pub struct Street(String);
-
-#[derive(Debug, Deserialize)]
-pub struct City(String);
-
-#[derive(Debug, Deserialize)]
-pub struct Country(String);
-
-#[derive(Debug, Deserialize)]
-pub struct Address {
- country: Country,
- city: City,
- street: Street,
- number: usize,
-}
-
-#[derive(Debug, Deserialize)]
-pub struct Person {
- name: Name,
- age: Age,
- addr: Address,
-}
-
diff --git a/service-person/src/model/address.rs b/service-person/src/model/address.rs
new file mode 100644
index 0000000..d09240d
--- /dev/null
+++ b/service-person/src/model/address.rs
@@ -0,0 +1,11 @@
+use serde::Deserialize;
+
+use crate::model::*;
+
+#[derive(Debug, Deserialize)]
+pub struct Address {
+ country: Country,
+ city: City,
+ street: Street,
+ number: usize,
+}
diff --git a/service-person/src/model/age.rs b/service-person/src/model/age.rs
new file mode 100644
index 0000000..7c7420c
--- /dev/null
+++ b/service-person/src/model/age.rs
@@ -0,0 +1,5 @@
+use serde::Deserialize;
+
+#[derive(Debug, Deserialize)]
+pub struct Age(usize);
+
diff --git a/service-person/src/model/city.rs b/service-person/src/model/city.rs
new file mode 100644
index 0000000..3c82e73
--- /dev/null
+++ b/service-person/src/model/city.rs
@@ -0,0 +1,5 @@
+use serde::Deserialize;
+
+#[derive(Debug, Deserialize)]
+pub struct City(String);
+
diff --git a/service-person/src/model/country.rs b/service-person/src/model/country.rs
new file mode 100644
index 0000000..b642bf7
--- /dev/null
+++ b/service-person/src/model/country.rs
@@ -0,0 +1,5 @@
+use serde::Deserialize;
+
+#[derive(Debug, Deserialize)]
+pub struct Country(String);
+
diff --git a/service-person/src/model/mod.rs b/service-person/src/model/mod.rs
new file mode 100644
index 0000000..48eeeed
--- /dev/null
+++ b/service-person/src/model/mod.rs
@@ -0,0 +1,20 @@
+pub mod address;
+pub use address::*;
+
+pub mod age;
+pub use age::*;
+
+pub mod city;
+pub use city::*;
+
+pub mod country;
+pub use country::*;
+
+pub mod name;
+pub use name::*;
+
+pub mod person;
+pub use person::*;
+
+pub mod street;
+pub use street::*;
diff --git a/service-person/src/model/name.rs b/service-person/src/model/name.rs
new file mode 100644
index 0000000..5b5c6d6
--- /dev/null
+++ b/service-person/src/model/name.rs
@@ -0,0 +1,6 @@
+use serde::Deserialize;
+
+#[derive(Debug, Deserialize)]
+pub struct Name(String);
+
+
diff --git a/service-person/src/model/person.rs b/service-person/src/model/person.rs
new file mode 100644
index 0000000..338d6ff
--- /dev/null
+++ b/service-person/src/model/person.rs
@@ -0,0 +1,9 @@
+use serde::Deserialize;
+use crate::model::*;
+
+#[derive(Debug, Deserialize)]
+pub struct Person {
+ name: Name,
+ age: Age,
+ addr: Address,
+}
diff --git a/service-person/src/model/street.rs b/service-person/src/model/street.rs
new file mode 100644
index 0000000..3b132fa
--- /dev/null
+++ b/service-person/src/model/street.rs
@@ -0,0 +1,5 @@
+use serde::Deserialize;
+
+#[derive(Debug, Deserialize)]
+pub struct Street(String);
+