changed enum layout

This commit is contained in:
Mitchell 2020-08-16 17:15:34 +01:00
parent f24a4f72df
commit 399b9b8c59
1 changed files with 32 additions and 3 deletions

View File

@ -7,8 +7,27 @@ use std::ops::Index;
use zeroize::Zeroize;
#[derive(Clone, Debug)]
pub enum Commands {
Request(Option<HashMap<String, String>>),
pub enum Commands<T> {
// Common fields:
executable: T,
params: Option<HashMap<String, String>>,
// Variants:
Request {},
Info {},
Connect {},
Disconnect {},
ClientUpdate {},
ClientInfo {},
ClientRemove {},
Client {},
Success {},
Error {},
/*Request(Option<HashMap<String, String>>),
Info(Option<HashMap<String, String>>),
Connect(Option<HashMap<String, String>>),
@ -20,7 +39,11 @@ pub enum Commands {
Client(Option<HashMap<String, String>>),
Success(Option<HashMap<String, String>>),
Error(Option<HashMap<String, String>>),
Error(Option<HashMap<String, String>>),*/
}
trait Operations {
fn execute(&self);
}
impl Commands {
@ -51,6 +74,12 @@ impl Commands {
}
}
impl<T> Operations for Commands<T> {
fn execute(&self) {
self.executable.run();
}
}
impl PartialEq for Commands {
fn eq(&self, other: &Self) -> bool {
match (self, other) {