get_commands() can return a HashMap<str, fn()>, which is command name -> command function
This commit is contained in:
parent
a24d3175dd
commit
84571bef0a
1 changed files with 3 additions and 1 deletions
|
@ -4,6 +4,7 @@ use std::fmt::Formatter;
|
||||||
use std::fmt::Result as FMTResult;
|
use std::fmt::Result as FMTResult;
|
||||||
use std::fmt::Display;
|
use std::fmt::Display;
|
||||||
use std::result::Result;
|
use std::result::Result;
|
||||||
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use storage::backend::StorageBackend;
|
use storage::backend::StorageBackend;
|
||||||
use self::command::ExecutableCommand;
|
use self::command::ExecutableCommand;
|
||||||
|
@ -43,6 +44,7 @@ impl Display for ModuleError {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type ModuleResult = Result<(), ModuleError>;
|
pub type ModuleResult = Result<(), ModuleError>;
|
||||||
|
pub type CommandMap<'a> = HashMap<&'a str, fn(&Runtime)>;
|
||||||
|
|
||||||
pub trait Module {
|
pub trait Module {
|
||||||
|
|
||||||
|
@ -51,7 +53,7 @@ pub trait Module {
|
||||||
fn name(&self) -> &'static str;
|
fn name(&self) -> &'static str;
|
||||||
fn shutdown(&self, rt : &Runtime) -> ModuleResult;
|
fn shutdown(&self, rt : &Runtime) -> ModuleResult;
|
||||||
|
|
||||||
fn get_commands<C: ExecutableCommand>(&self, rt: &Runtime) -> Vec<C>;
|
fn get_commands(&self, rt: &Runtime) -> CommandMap;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue