Add boilerplate for create hook

This commit is contained in:
Matthias Beyer 2016-05-15 00:47:56 +02:00
parent da0c4cf06b
commit 1f6a983a51

View file

@ -0,0 +1,54 @@
use toml::Value;
use libimagstore::storeid::StoreId;
use libimagstore::hook::Hook;
use libimagstore::hook::result::HookResult;
use libimagstore::hook::position::HookPosition;
use libimagstore::hook::accessor::{HookDataAccessor, HookDataAccessorProvider};
use libimagstore::hook::accessor::StoreIdAccessor;
#[derive(Debug)]
pub struct CreateHook {
position: HookPosition,
config: Option<Value>,
}
impl CreateHook {
pub fn new(p: HookPosition) -> CreateHook {
CreateHook {
position: p,
config: None,
}
}
}
impl Hook for CreateHook {
fn name(&self) -> &'static str {
"stdhook_git_create"
}
fn set_config(&mut self, config: &Value) {
self.config = Some(config.clone());
}
}
impl HookDataAccessorProvider for CreateHook {
fn accessor(&self) -> HookDataAccessor {
HookDataAccessor::StoreIdAccess(self)
}
}
impl StoreIdAccessor for CreateHook {
fn access(&self, id: &StoreId) -> HookResult<()> {
debug!("[GIT CREATE HOOK]: {:?}", id);
Ok(())
}
}