Add module/command trait

This commit is contained in:
Matthias Beyer 2015-11-10 19:29:18 +01:00
parent ba91e7ee26
commit 99a2670803
2 changed files with 13 additions and 1 deletions

11
src/module/command.rs Normal file
View 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;
}

View file

@ -7,6 +7,7 @@ use std::path::Path;
use std::result::Result;
use storage::backend::{StorageBackend, StorageBackendError};
use self::command::ExecutableCommand;
mod command;
#[derive(Debug)]
@ -51,7 +52,7 @@ pub trait Module {
fn execute(&self, rt : &Runtime) -> ModuleResult;
fn shutdown(&self, rt : &Runtime) -> ModuleResult;
fn getCommandBuilder<T>() -> F
fn getCommandBuilder<T, F>() -> F
where F: FnOnce(StorageBackend) -> T,
T: ExecutableCommand;