Add struct for passing environment of command to command execute function
This commit is contained in:
parent
a9a33321f7
commit
55361f71fe
1 changed files with 7 additions and 4 deletions
|
@ -9,10 +9,13 @@ use storage::backend::{StorageBackend, StorageBackendError};
|
||||||
pub type CommandError = Result<ModuleError, StorageBackendError>;
|
pub type CommandError = Result<ModuleError, StorageBackendError>;
|
||||||
pub type CommandResult = Result<(), Result<ModuleError, CommandError>>;
|
pub type CommandResult = Result<(), Result<ModuleError, CommandError>>;
|
||||||
|
|
||||||
|
pub struct CommandEnv<'a> {
|
||||||
|
pub rt: &'a Runtime<'a>,
|
||||||
|
pub matches: &'a ArgMatches<'a, 'a>,
|
||||||
|
pub backend: StorageBackend
|
||||||
|
}
|
||||||
|
|
||||||
pub trait ExecutableCommand {
|
pub trait ExecutableCommand {
|
||||||
fn get_callname() -> &'static str;
|
fn get_callname() -> &'static str;
|
||||||
fn exec(&self,
|
fn exec(&self, env: CommandEnv) -> CommandResult;
|
||||||
rt: &Runtime,
|
|
||||||
matches: &ArgMatches<'a, 'a>,
|
|
||||||
s: StorageBackend) -> CommandResult;
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue