From 99a267080342ff9a04b11aad76fec3906c87ab18 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 10 Nov 2015 19:29:18 +0100 Subject: [PATCH] Add module/command trait --- src/module/command.rs | 11 +++++++++++ src/module/mod.rs | 3 ++- 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 src/module/command.rs diff --git a/src/module/command.rs b/src/module/command.rs new file mode 100644 index 00000000..e83ce232 --- /dev/null +++ b/src/module/command.rs @@ -0,0 +1,11 @@ +use std::result::Result; + +use super::ModuleError; +use storage::backend::{StorageBackend, StorageBackendError}; + +type CommandError = Result; +type CommandResult = Result<(), Result>; + +pub trait ExecutableCommand { + fn exec(StorageBackend) -> CommandResult; +} diff --git a/src/module/mod.rs b/src/module/mod.rs index d0f711f2..2cc5aeb9 100644 --- a/src/module/mod.rs +++ b/src/module/mod.rs @@ -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() -> F + fn getCommandBuilder() -> F where F: FnOnce(StorageBackend) -> T, T: ExecutableCommand;