Parcourir la source

Move repotype to its own file

Samuel W. Flint il y a 5 ans
Parent
commit
58bce72e56
2 fichiers modifiés avec 31 ajouts et 14 suppressions
  1. 4 14
      src/config.rs
  2. 27 0
      src/repotype.rs

+ 4 - 14
src/config.rs

@@ -13,6 +13,10 @@ use crate::repository::{
     Repository
 };
 
+use crate::repotype::{
+    RepoType
+};
+
 #[derive(Serialize, Deserialize)]
 pub struct Config {
     #[serde(rename(serialize = "repo_type", deserialize = "repo_type"), default)]
@@ -25,20 +29,6 @@ pub struct Config {
     groups: HashMap<String, Group>,
 }
 
-#[derive(Serialize, Deserialize)]
-pub struct RepoType {
-    #[serde(default)]
-    name: String,
-    #[serde(default)]
-    description: String,
-    #[serde(default)]
-    create: String,
-    #[serde(default)]
-    inward: String,
-    #[serde(default)]
-    outward: String,
-}
-
 #[derive(Serialize, Deserialize)]
 pub struct Action {
     #[serde(default)]

+ 27 - 0
src/repotype.rs

@@ -0,0 +1,27 @@
+use serde::{Deserialize, Serialize};
+use std::fmt;
+
+#[derive(Serialize, Deserialize)]
+pub struct RepoType {
+    #[serde(default)]
+    name: String,
+    #[serde(default)]
+    description: String,
+    #[serde(default)]
+    create: String,
+    #[serde(default)]
+    inward: String,
+    #[serde(default)]
+    outward: String,
+}
+
+impl fmt::Display for RepoType {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+        write!(f, "Repository type {}:\n\t\"{}\"\n\tCreation Command: {}\n\tInward Sync: {}\n\tOutward Sync: {}",
+               self.name,
+               self.description,
+               self.create,
+               self.inward,
+               self.outward);
+    }
+}