Module should only provide functionality to get a list of commands it can execute
These commands can then be executed.
This commit is contained in:
parent
86286cce1b
commit
cbd85b3d8e
2 changed files with 3 additions and 6 deletions
|
@ -7,5 +7,6 @@ type CommandError = Result<ModuleError, StorageBackendError>;
|
||||||
type CommandResult = Result<(), Result<ModuleError, CommandError>>;
|
type CommandResult = Result<(), Result<ModuleError, CommandError>>;
|
||||||
|
|
||||||
pub trait ExecutableCommand {
|
pub trait ExecutableCommand {
|
||||||
fn exec(StorageBackend) -> CommandResult;
|
fn get_callname() -> &'static str;
|
||||||
|
fn exec(&self, rt: &Runtime, s: StorageBackend) -> CommandResult;
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,13 +49,9 @@ pub trait Module {
|
||||||
fn new(rt : &Runtime) -> Self;
|
fn new(rt : &Runtime) -> Self;
|
||||||
fn callnames() -> &'static [&'static str];
|
fn callnames() -> &'static [&'static str];
|
||||||
fn name(&self) -> &'static str;
|
fn name(&self) -> &'static str;
|
||||||
|
|
||||||
fn execute(&self, rt : &Runtime) -> ModuleResult;
|
|
||||||
fn shutdown(&self, rt : &Runtime) -> ModuleResult;
|
fn shutdown(&self, rt : &Runtime) -> ModuleResult;
|
||||||
|
|
||||||
fn getCommandBuilder<T, F>() -> F
|
fn get_commands<C: ExecutableCommand>(&self, rt: &Runtime) -> Vec<C>;
|
||||||
where F: FnOnce(StorageBackend) -> T,
|
|
||||||
T: ExecutableCommand;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue