Add module/command trait
This commit is contained in:
parent
ba91e7ee26
commit
99a2670803
2 changed files with 13 additions and 1 deletions
11
src/module/command.rs
Normal file
11
src/module/command.rs
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
use std::result::Result;
|
||||||
|
|
||||||
|
use super::ModuleError;
|
||||||
|
use storage::backend::{StorageBackend, StorageBackendError};
|
||||||
|
|
||||||
|
type CommandError = Result<ModuleError, StorageBackendError>;
|
||||||
|
type CommandResult = Result<(), Result<ModuleError, CommandError>>;
|
||||||
|
|
||||||
|
pub trait ExecutableCommand {
|
||||||
|
fn exec(StorageBackend) -> CommandResult;
|
||||||
|
}
|
|
@ -7,6 +7,7 @@ use std::path::Path;
|
||||||
use std::result::Result;
|
use std::result::Result;
|
||||||
|
|
||||||
use storage::backend::{StorageBackend, StorageBackendError};
|
use storage::backend::{StorageBackend, StorageBackendError};
|
||||||
|
use self::command::ExecutableCommand;
|
||||||
mod command;
|
mod command;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
@ -51,7 +52,7 @@ pub trait Module {
|
||||||
fn execute(&self, rt : &Runtime) -> ModuleResult;
|
fn execute(&self, rt : &Runtime) -> ModuleResult;
|
||||||
fn shutdown(&self, rt : &Runtime) -> ModuleResult;
|
fn shutdown(&self, rt : &Runtime) -> ModuleResult;
|
||||||
|
|
||||||
fn getCommandBuilder<T>() -> F
|
fn getCommandBuilder<T, F>() -> F
|
||||||
where F: FnOnce(StorageBackend) -> T,
|
where F: FnOnce(StorageBackend) -> T,
|
||||||
T: ExecutableCommand;
|
T: ExecutableCommand;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue