changed enum layout
This commit is contained in:
parent
f24a4f72df
commit
399b9b8c59
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue