Преглед на файлове

Move action to own file

Samuel W. Flint преди 5 години
родител
ревизия
4aef6a9c92
променени са 2 файла, в които са добавени 29 реда и са изтрити 10 реда
  1. 25 0
      src/action.rs
  2. 4 10
      src/config.rs

+ 25 - 0
src/action.rs

@@ -0,0 +1,25 @@
+use serde::{Deserialize, Serialize};
+use std::fmt;
+
+#[derive(Serialize, Deserialize)]
+pub struct Action {
+    #[serde(default)]
+    name: String,
+    #[serde(default)]
+    description: String,
+    #[serde(default)]
+    command: String,
+    #[serde(default)]
+    disabled: bool,
+}
+
+impl fmt::Display for Action {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+        write!(f, "Action {}:\n\t\"{}\"\n\tCommand: \"{}\"\n\tDisabled: {}",
+               self.name,
+               self.description,
+               self.command,
+               self.disabled
+        );
+    }
+}

+ 4 - 10
src/config.rs

@@ -17,6 +17,10 @@ use crate::repotype::{
     RepoType
 };
 
+use crate::action::{
+    Action
+};
+
 #[derive(Serialize, Deserialize)]
 pub struct Config {
     #[serde(rename(serialize = "repo_type", deserialize = "repo_type"), default)]
@@ -29,16 +33,6 @@ pub struct Config {
     groups: HashMap<String, Group>,
 }
 
-#[derive(Serialize, Deserialize)]
-pub struct Action {
-    #[serde(default)]
-    name: String,
-    #[serde(default)]
-    command: String,
-    #[serde(default)]
-    disabled: bool,
-}
-
 #[derive(Serialize, Deserialize)]
 pub struct Group {
     #[serde(default)]