Add basic interface for BM module

This commit is contained in:
Matthias Beyer 2015-12-20 13:26:14 +01:00
parent 7e77d786bb
commit 00d0bbf4ae
3 changed files with 48 additions and 3 deletions

View file

@ -41,7 +41,7 @@ fn main() {
debug!("Runtime : {:?}", &rt);
if let Some(matches) = rt.config.cli_matches.subcommand_matches("bm") {
let res = BM::new(&rt).exec(matches.subcommand_matches("bm"));
let res = BM::new(&rt).exec(matches.subcommand_matches("bm").unwrap());
info!("BM exited with {}", res);
} else {
info!("No commandline call...")

45
src/module/bm/mod.rs Normal file
View file

@ -0,0 +1,45 @@
use std::fmt::{Debug, Display, Formatter};
use std::fmt;
use clap::ArgMatches;
use runtime::Runtime;
use module::Module;
pub struct BM<'a> {
rt: &'a Runtime<'a>,
}
impl<'a> BM<'a> {
pub fn new(rt: &'a Runtime<'a>) -> BM<'a> {
BM {
rt: rt,
}
}
fn runtime(&self) -> &Runtime {
&self.rt
}
}
impl<'a> Module for BM<'a> {
fn exec(&self, matches: &ArgMatches) -> bool {
unimplemented!()
}
fn name(&self) -> &'static str {
"bm"
}
}
impl<'a> Debug for BM<'a> {
fn fmt(&self, fmt: &mut Formatter) -> fmt::Result {
write!(fmt, "BM");
Ok(())
}
}

View file

@ -11,8 +11,8 @@ use runtime::Runtime;
pub mod bm;
pub mod helpers;
pub trait Module : Debug {
fn new(rt: &Runtime) -> Self;
pub trait Module<'a> : Debug {
fn exec(&self, matches: &ArgMatches) -> bool;
fn name(&self) -> &'static str;
}