From 5b7fc61723e1ff24e4760f545709610205708e43 Mon Sep 17 00:00:00 2001
From: Werner <26710260+GuilhermeWerner@users.noreply.github.com>
Date: Sun, 26 Dec 2021 18:44:17 -0300
Subject: [PATCH] Split Payload and PayloadType

---
 Source/Instruction.rs      | 10 +++++++---
 Source/InstructionTable.rs |  4 ++--
 Source/Payload.rs          | 10 ----------
 Source/PayloadType.rs      | 10 ++++++++++
 Source/lib.rs              |  4 ++++
 5 files changed, 23 insertions(+), 15 deletions(-)
 create mode 100644 Source/PayloadType.rs

diff --git a/Source/Instruction.rs b/Source/Instruction.rs
index 5773527..77cad1b 100644
--- a/Source/Instruction.rs
+++ b/Source/Instruction.rs
@@ -1,6 +1,5 @@
-use crate::Machine;
-use crate::Payload::PayloadType;
 use crate::Types::Byte;
+use crate::{Machine, PayloadType};
 
 pub struct Instruction {
     pub code: Byte,
@@ -13,7 +12,12 @@ pub type InstructionFunction = fn(machine: &mut Machine) -> bool;
 
 impl Instruction {
     #[inline]
-    pub fn New(code: Byte, name: &str, payload: PayloadType, function: InstructionFunction) -> Self {
+    pub fn New(
+        code: Byte,
+        name: &str,
+        payload: PayloadType,
+        function: InstructionFunction,
+    ) -> Self {
         Self {
             code,
             name: name.to_string(),
diff --git a/Source/InstructionTable.rs b/Source/InstructionTable.rs
index bb7a2ef..8c0829d 100644
--- a/Source/InstructionTable.rs
+++ b/Source/InstructionTable.rs
@@ -1,8 +1,7 @@
-use crate::Instruction;
 use crate::Instructions::*;
 use crate::Operations::*;
-use crate::Payload::PayloadType;
 use crate::Types::Byte;
+use crate::{Instruction, PayloadType};
 use std::collections::HashMap;
 
 pub struct InstructionTable {
@@ -19,6 +18,7 @@ impl Default for InstructionTable {
 
 impl InstructionTable {
     #[inline]
+    #[rustfmt::skip]
     pub fn New() -> Self {
         let mut table = InstructionTable::default();
 
diff --git a/Source/Payload.rs b/Source/Payload.rs
index 589980e..1fd2728 100644
--- a/Source/Payload.rs
+++ b/Source/Payload.rs
@@ -8,16 +8,6 @@ pub type TwoRegisters = (Byte, Byte);
 pub type ThreeRegisters = (Byte, Byte, Byte);
 pub type FourRegisters = (Byte, Byte, Byte, Byte);
 
-pub enum PayloadType {
-    Nothing,
-    Register,
-    RegisterAddress,
-    AddressRegister,
-    TwoRegisters,
-    ThreeRegisters,
-    FourRegisters,
-}
-
 #[inline]
 pub fn GetRegister(vm: &mut Machine) -> Register {
     vm.ReadByte(None)
diff --git a/Source/PayloadType.rs b/Source/PayloadType.rs
new file mode 100644
index 0000000..58026cd
--- /dev/null
+++ b/Source/PayloadType.rs
@@ -0,0 +1,10 @@
+
+pub enum PayloadType {
+    Nothing,
+    Register,
+    RegisterAddress,
+    AddressRegister,
+    TwoRegisters,
+    ThreeRegisters,
+    FourRegisters,
+}
diff --git a/Source/lib.rs b/Source/lib.rs
index e9f8469..06de90d 100644
--- a/Source/lib.rs
+++ b/Source/lib.rs
@@ -23,6 +23,10 @@ pub use self::_Limits::*;
 mod _Machine;
 pub use self::_Machine::*;
 
+#[path = "PayloadType.rs"]
+mod _PayloadType;
+pub use self::_PayloadType::*;
+
 #[path = "Registry.rs"]
 mod _Registry;
 pub use self::_Registry::*;