Add Aspect type for hook system
This commit is contained in:
parent
3e62b71605
commit
be1ba5be4b
2 changed files with 50 additions and 0 deletions
49
libimagstore/src/hook/aspect.rs
Normal file
49
libimagstore/src/hook/aspect.rs
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
use store::FileLockEntry;
|
||||||
|
use storeid::StoreId;
|
||||||
|
use hook::Hook;
|
||||||
|
use hook::result::HookResult;
|
||||||
|
use hook::accessor::{StoreIdAccessor, MutableHookDataAccessor, NonMutableHookDataAccessor};
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct Aspect {
|
||||||
|
name: String,
|
||||||
|
hooks: Vec<Box<Hook>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Aspect {
|
||||||
|
|
||||||
|
pub fn new(name: String) -> Aspect {
|
||||||
|
Aspect {
|
||||||
|
name: name,
|
||||||
|
hooks: vec![],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn name(&self) -> &String {
|
||||||
|
&self.name
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn register_hook(&mut self, h: Box<Hook>) {
|
||||||
|
self.hooks.push(h);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
impl StoreIdAccessor for Aspect {
|
||||||
|
fn access(&self, id: &StoreId) -> HookResult<()> {
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl MutableHookDataAccessor for Aspect {
|
||||||
|
fn access_mut(&self, fle: &mut FileLockEntry) -> HookResult<()> {
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl NonMutableHookDataAccessor for Aspect {
|
||||||
|
fn access(&self, fle: &FileLockEntry) -> HookResult<()> {
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ use self::error::HookError;
|
||||||
use store::FileLockEntry;
|
use store::FileLockEntry;
|
||||||
|
|
||||||
pub mod accessor;
|
pub mod accessor;
|
||||||
|
pub mod aspect;
|
||||||
pub mod create;
|
pub mod create;
|
||||||
pub mod delete;
|
pub mod delete;
|
||||||
pub mod error;
|
pub mod error;
|
||||||
|
|
Loading…
Reference in a new issue